[g3dvl] keep a pointer in idct buffer to idct object
authorChristian König <deathsimple@vodafone.de>
Wed, 13 Jul 2011 13:01:40 +0000 (15:01 +0200)
committerChristian König <deathsimple@vodafone.de>
Wed, 13 Jul 2011 13:01:40 +0000 (15:01 +0200)
So we always know to which idct object a buffer belongs

src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c

index 744a35603d7143aa4033813e7fcab8ee9d272000..75e76c09f63605f5b80319c588c31106a26e2b03 100644 (file)
@@ -791,6 +791,8 @@ vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
 
    memset(buffer, 0, sizeof(struct vl_idct_buffer));
 
+   buffer->idct = idct;
+
    pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, idct->matrix);
    pipe_sampler_view_reference(&buffer->sampler_views.individual.source, source);
    pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, idct->transpose);
@@ -806,22 +808,24 @@ vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
 }
 
 void
-vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer)
 {
-   assert(idct && buffer);
+   assert(buffer);
 
-   cleanup_source(idct, buffer);
-   cleanup_intermediate(idct, buffer);
+   cleanup_source(buffer->idct, buffer);
+   cleanup_intermediate(buffer->idct, buffer);
 
    pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, NULL);
    pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, NULL);
 }
 
 void
-vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_instances)
+vl_idct_flush(struct vl_idct_buffer *buffer, unsigned num_instances)
 {
-   assert(idct);
+   struct vl_idct *idct;
    assert(buffer);
+   
+   idct = buffer->idct;
 
    idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state);
    idct->pipe->bind_blend_state(idct->pipe, idct->blend);
@@ -844,14 +848,13 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_
 }
 
 void
-vl_idct_prepare_stage2(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+vl_idct_prepare_stage2(struct vl_idct_buffer *buffer)
 {
-   assert(idct);
    assert(buffer);
 
    /* second stage */
-   idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state);
-   idct->pipe->bind_fragment_sampler_states(idct->pipe, 2, idct->samplers);
-   idct->pipe->set_fragment_sampler_views(idct->pipe, 2, buffer->sampler_views.stage[1]);
+   buffer->idct->pipe->bind_rasterizer_state(buffer->idct->pipe, buffer->idct->rs_state);
+   buffer->idct->pipe->bind_fragment_sampler_states(buffer->idct->pipe, 2, buffer->idct->samplers);
+   buffer->idct->pipe->set_fragment_sampler_views(buffer->idct->pipe, 2, buffer->sampler_views.stage[1]);
 }
 
index 119a53dbf27c68505d86b37eb9dc8fe2401c5d50..98e2c795564be544021c34f6cfc564d7cd18ce7e 100644 (file)
@@ -58,6 +58,8 @@ struct vl_idct
 /* a set of buffers to work with */
 struct vl_idct_buffer
 {
+   struct vl_idct *idct;
+   
    struct pipe_viewport_state viewport_mismatch;
    struct pipe_viewport_state viewport;
 
@@ -107,13 +109,13 @@ vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
 
 /* cleanup a buffer of an idct instance */
 void
-vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
+vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer);
 
 /* flush the buffer and start rendering, vertex buffers needs to be setup before calling this */
 void
-vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_verts);
+vl_idct_flush(struct vl_idct_buffer *buffer, unsigned num_verts);
 
 void
-vl_idct_prepare_stage2(struct vl_idct *idct, struct vl_idct_buffer *buffer);
+vl_idct_prepare_stage2(struct vl_idct_buffer *buffer);
 
 #endif
index 7bb5a695e40617722cec930bec07d50e19233037..98b0adabb2bb268b2d2ad0c83aea97acddc09369 100644 (file)
@@ -177,7 +177,7 @@ init_idct_buffer(struct vl_mpeg12_buffer *buffer)
 
 error_plane:
    for (; i > 0; --i)
-      vl_idct_cleanup_buffer(i == 1 ? &dec->idct_c : &dec->idct_y, &buffer->idct[i - 1]);
+      vl_idct_cleanup_buffer(&buffer->idct[i - 1]);
 
 error_mc_source_sv:
 error_source_sv:
@@ -188,14 +188,15 @@ static void
 cleanup_idct_buffer(struct vl_mpeg12_buffer *buf)
 {
    struct vl_mpeg12_decoder *dec;
+   unsigned i;
+   
    assert(buf);
 
    dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
    assert(dec);
 
-   vl_idct_cleanup_buffer(&dec->idct_y, &buf->idct[0]);
-   vl_idct_cleanup_buffer(&dec->idct_c, &buf->idct[1]);
-   vl_idct_cleanup_buffer(&dec->idct_c, &buf->idct[2]);
+   for (i = 0; i < 3; ++i)
+      vl_idct_cleanup_buffer(&buf->idct[0]);
 }
 
 static bool
@@ -574,7 +575,7 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
       vl_zscan_render(&buf->zscan[i] , num_ycbcr_blocks[i]);
 
       if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
-         vl_idct_flush(i == 0 ? &dec->idct_y : &dec->idct_c, &buf->idct[i], num_ycbcr_blocks[i]);
+         vl_idct_flush(&buf->idct[i], num_ycbcr_blocks[i]);
    }
 
    mc_source_sv = dec->mc_source->get_sampler_view_planes(dec->mc_source);
@@ -589,7 +590,7 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
          dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
 
          if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
-            vl_idct_prepare_stage2(component == 0 ? &dec->idct_y : &dec->idct_c, &buf->idct[component]);
+            vl_idct_prepare_stage2(&buf->idct[component]);
          else {
             dec->base.context->set_fragment_sampler_views(dec->base.context, 1, &mc_source_sv[component]);
             dec->base.context->bind_fragment_sampler_states(dec->base.context, 1, &dec->sampler_ycbcr);