summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian König <[email protected]>2010-11-11 15:01:27 +0100
committerChristian König <[email protected]>2010-11-11 15:01:27 +0100
commit99b57bc20e839043ec6160502814085a0976fccc (patch)
treebc7dc8584bcec3f6616ee1324241d02e31facb38 /src
parente406936b9ec46f1b8a41d02edd15f384bb739e32 (diff)
[g3dvl] move stuff from flush into own functions
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c96
1 files changed, 59 insertions, 37 deletions
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index 4616e483f74..0ac258c9667 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -751,6 +751,29 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
return true;
}
+static bool
+init_const_buffers(struct vl_mpeg12_mc_renderer *r)
+{
+ struct pipe_transfer *buf_transfer;
+ struct vertex2f *rect;
+ unsigned i;
+
+ rect = pipe_buffer_map
+ (
+ r->pipe,
+ r->vertex_bufs.individual.rect.buffer,
+ PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+ &buf_transfer
+ );
+
+ for ( i = 0; i < r->macroblocks_per_batch; ++i)
+ memcpy(rect + i * 24, &const_rectangle, sizeof(const_rectangle));
+
+ pipe_buffer_unmap(r->pipe, r->vertex_bufs.individual.rect.buffer, buf_transfer);
+
+ return true;
+}
+
static void
cleanup_buffers(struct vl_mpeg12_mc_renderer *r)
{
@@ -1044,49 +1067,12 @@ flush(struct vl_mpeg12_mc_renderer *r)
{
unsigned num_macroblocks[NUM_MACROBLOCK_TYPES] = { 0 };
unsigned vb_start = 0;
- struct vertex_shader_consts *vs_consts;
- struct pipe_transfer *buf_transfer;
- struct vertex2f *rect;
- unsigned i;
assert(r);
assert(r->num_macroblocks == r->macroblocks_per_batch);
- rect = pipe_buffer_map
- (
- r->pipe,
- r->vertex_bufs.individual.rect.buffer,
- PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
- &buf_transfer
- );
-
- for ( i = 0; i < r->macroblocks_per_batch; ++i)
- memcpy(rect + i * 24, &const_rectangle, sizeof(const_rectangle));
-
- pipe_buffer_unmap(r->pipe, r->vertex_bufs.individual.rect.buffer, buf_transfer);
-
gen_macroblock_stream(r, num_macroblocks);
- r->fb_state.cbufs[0] = r->surface;
-
- r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
- r->pipe->set_viewport_state(r->pipe, &r->viewport);
-
- vs_consts = pipe_buffer_map
- (
- r->pipe, r->vs_const_buf,
- PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
- &buf_transfer
- );
-
- vs_consts->norm.x = 1.0f / r->surface->width;
- vs_consts->norm.y = 1.0f / r->surface->height;
-
- pipe_buffer_unmap(r->pipe, r->vs_const_buf, buf_transfer);
-
- r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
- r->vs_const_buf);
-
if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems_state.individual.i);
@@ -1200,6 +1186,33 @@ flush(struct vl_mpeg12_mc_renderer *r)
}
static void
+update_render_target(struct vl_mpeg12_mc_renderer *r)
+{
+ struct pipe_transfer *buf_transfer;
+ struct vertex_shader_consts *vs_consts;
+
+ vs_consts = pipe_buffer_map
+ (
+ r->pipe, r->vs_const_buf,
+ PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+ &buf_transfer
+ );
+
+ vs_consts->norm.x = 1.0f / r->surface->width;
+ vs_consts->norm.y = 1.0f / r->surface->height;
+
+ pipe_buffer_unmap(r->pipe, r->vs_const_buf, buf_transfer);
+
+ r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
+ r->vs_const_buf);
+
+ r->fb_state.cbufs[0] = r->surface;
+
+ r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
+ r->pipe->set_viewport_state(r->pipe, &r->viewport);
+}
+
+static void
grab_frame_coded_block(short *src, short *dst, unsigned dst_pitch)
{
unsigned y;
@@ -1367,6 +1380,14 @@ vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
return false;
}
+ if (!init_const_buffers(renderer)) {
+ util_delete_keymap(renderer->texview_map, renderer->pipe);
+ cleanup_pipe_state(renderer);
+ cleanup_shaders(renderer);
+ cleanup_buffers(renderer);
+ return false;
+ }
+
renderer->surface = NULL;
renderer->past = NULL;
renderer->future = NULL;
@@ -1434,6 +1455,7 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
pipe_surface_reference(&renderer->past, past);
pipe_surface_reference(&renderer->future, future);
renderer->fence = fence;
+ update_render_target(renderer);
}
while (num_macroblocks) {