[g3dvl] also use video buffer for idct intermediate
authorChristian König <deathsimple@vodafone.de>
Sun, 10 Apr 2011 16:46:31 +0000 (18:46 +0200)
committerChristian König <deathsimple@vodafone.de>
Sun, 10 Apr 2011 16:46:31 +0000 (18:46 +0200)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
src/gallium/auxiliary/vl/vl_video_buffer.c

index dc4a9bbb8c97a5af6ba77d5b4ac30ad77c454a46..5d5ead31f7dbc158a6b31443056bfb4fe2c94fbf 100644 (file)
@@ -455,33 +455,13 @@ cleanup_state(struct vl_idct *idct)
 static bool
 init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
 {
-   struct pipe_resource tex_templ, *tex;
-   struct pipe_sampler_view sv_templ;
+   struct pipe_resource *tex;
    struct pipe_surface surf_templ;
    unsigned i;
 
    assert(idct && buffer);
 
-   memset(&tex_templ, 0, sizeof(tex_templ));
-   tex_templ.target = PIPE_TEXTURE_3D;
-   tex_templ.format = PIPE_FORMAT_R16G16B16A16_SNORM;
-   tex_templ.width0 = idct->buffer_width / NR_RENDER_TARGETS;
-   tex_templ.height0 = idct->buffer_height / 4;
-   tex_templ.depth0 = NR_RENDER_TARGETS;
-   tex_templ.array_size = 1;
-   tex_templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
-   tex_templ.usage = PIPE_USAGE_STATIC;
-
-   tex = idct->pipe->screen->resource_create(idct->pipe->screen, &tex_templ);
-   if (!tex)
-      goto error_tex;
-
-   memset(&sv_templ, 0, sizeof(sv_templ));
-   u_sampler_view_default_template(&sv_templ, tex, tex->format);
-   buffer->sampler_views.individual.intermediate =
-      idct->pipe->create_sampler_view(idct->pipe, tex, &sv_templ);
-   if (!buffer->sampler_views.individual.intermediate)
-         goto error_sampler_view;
+   tex = buffer->sampler_views.individual.intermediate->texture;
 
    buffer->fb_state[0].width = tex->width0;
    buffer->fb_state[0].height = tex->height0;
@@ -502,19 +482,12 @@ init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
    buffer->viewport[0].scale[0] = tex->width0;
    buffer->viewport[0].scale[1] = tex->height0;
 
-   pipe_resource_reference(&tex, NULL);
    return true;
 
 error_surfaces:
    for(i = 0; i < NR_RENDER_TARGETS; ++i)
       pipe_surface_reference(&buffer->fb_state[0].cbufs[i], NULL);
 
-   pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, NULL);
-
-error_sampler_view:
-   pipe_resource_reference(&tex, NULL);
-
-error_tex:
    return false;
 }
 
@@ -644,7 +617,9 @@ vl_idct_cleanup(struct vl_idct *idct)
 
 bool
 vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
-                    struct pipe_sampler_view *source, struct pipe_surface *destination)
+                    struct pipe_sampler_view *source,
+                    struct pipe_sampler_view *intermediate,
+                    struct pipe_surface *destination)
 {
    unsigned i;
 
@@ -656,6 +631,7 @@ vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
    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->matrix);
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, intermediate);
 
    if (!init_intermediate(idct, buffer))
       return false;
index 5d3784ce6c0ff69d6a700ae92be106cf37b73891..4ad798a855bf5eccc649c9ddb7f7d8872fbaa0be 100644 (file)
@@ -82,7 +82,9 @@ void vl_idct_cleanup(struct vl_idct *idct);
 
 /* init a buffer assosiated with agiven idct instance */
 bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
-                         struct pipe_sampler_view *source, struct pipe_surface *destination);
+                         struct pipe_sampler_view *source,
+                         struct pipe_sampler_view *intermediate,
+                         struct pipe_surface *destination);
 
 /* cleanup a buffer of an idct instance */
 void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
index 31163b9d08e2ce2e2e38b8996706ec5541052ad3..afb69e9c3bf0c99c755e55bd90e1e7bedb842f04 100644 (file)
@@ -154,6 +154,7 @@ vl_mpeg12_buffer_destroy(struct pipe_video_decode_buffer *buffer)
 
    if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
       buf->idct_source->destroy(buf->idct_source);
+      buf->idct_intermediate->destroy(buf->idct_intermediate);
       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]);
@@ -266,7 +267,7 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
    struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
    struct vl_mpeg12_buffer *buffer;
 
-   struct pipe_sampler_view **idct_views, **mc_views;
+   struct pipe_sampler_view **idct_source_sv, **idct_intermediate_sv, **mc_source_sv;
    struct pipe_surface **idct_surfaces;
 
    assert(dec);
@@ -309,39 +310,57 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
       if (!buffer->idct_source)
          goto error_idct_source;
 
+      buffer->idct_intermediate = vl_video_buffer_init(dec->base.context, dec->pipe,
+                                                       dec->base.width / 4, dec->base.height / 4, 4,
+                                                       dec->base.chroma_format, 3,
+                                                       idct_source_formats,
+                                                       PIPE_USAGE_STATIC);
 
-      idct_views = buffer->idct_source->get_sampler_views(buffer->idct_source);
-      if (!idct_views)
-         goto error_idct_views;
+      if (!buffer->idct_intermediate)
+         goto error_idct_intermediate;
+
+      idct_source_sv = buffer->idct_source->get_sampler_views(buffer->idct_source);
+      if (!idct_source_sv)
+         goto error_idct_source_sv;
+
+      idct_intermediate_sv = buffer->idct_intermediate->get_sampler_views(buffer->idct_intermediate);
+      if (!idct_intermediate_sv)
+         goto error_idct_intermediate_sv;
 
       idct_surfaces = buffer->mc_source->get_surfaces(buffer->mc_source);
       if (!idct_surfaces)
          goto error_idct_surfaces;
 
       if (!vl_idct_init_buffer(&dec->idct_y, &buffer->idct[0],
-                               idct_views[0], idct_surfaces[0]))
+                               idct_source_sv[0],
+                               idct_intermediate_sv[0],
+                               idct_surfaces[0]))
          goto error_idct_y;
 
       if (!vl_idct_init_buffer(&dec->idct_c, &buffer->idct[1],
-                               idct_views[1], idct_surfaces[1]))
+                               idct_source_sv[1],
+                               idct_intermediate_sv[1],
+                               idct_surfaces[1]))
          goto error_idct_cb;
 
       if (!vl_idct_init_buffer(&dec->idct_c, &buffer->idct[2],
-                               idct_views[2], idct_surfaces[2]))
+                               idct_source_sv[2],
+                               idct_intermediate_sv[2],
+                               idct_surfaces[2]))
          goto error_idct_cr;
    }
 
-   mc_views = buffer->mc_source->get_sampler_views(buffer->mc_source);
-   if (!mc_views)
-      goto error_mc_views;
+   mc_source_sv = buffer->mc_source->get_sampler_views(buffer->mc_source);
+   if (!mc_source_sv)
+      goto error_mc_source_sv;
 
-   if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[0], mc_views[0]))
+   if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[0], mc_source_sv[0]))
       goto error_mc_y;
 
-   if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[1], mc_views[1]))
+   if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[1], mc_source_sv[1]))
       goto error_mc_cb;
 
-   if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[2], mc_views[2]))
+   if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[2], mc_source_sv[2]))
       goto error_mc_cr;
 
    return &buffer->base;
@@ -353,7 +372,7 @@ error_mc_cb:
    vl_mpeg12_mc_cleanup_buffer(&buffer->mc[0]);
 
 error_mc_y:
-error_mc_views:
+error_mc_source_sv:
    if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
       vl_idct_cleanup_buffer(&dec->idct_c, &buffer->idct[2]);
 
@@ -367,7 +386,12 @@ error_idct_cb:
 
 error_idct_y:
 error_idct_surfaces:
-error_idct_views:
+error_idct_intermediate_sv:
+error_idct_source_sv:
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+      buffer->idct_intermediate->destroy(buffer->idct_intermediate);
+
+error_idct_intermediate:
    if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
       buffer->idct_source->destroy(buffer->idct_source);
 
index e90f8d3880b64ca52fbc13048613ecc24bfef678..9be807198fe83459d38834b010ff9d9f325efb14 100644 (file)
@@ -64,6 +64,7 @@ struct vl_mpeg12_buffer
    struct vl_vertex_buffer vertex_stream;
 
    struct pipe_video_buffer *idct_source;
+   struct pipe_video_buffer *idct_intermediate;
    struct pipe_video_buffer *mc_source;
 
    union
index 5ea0dfa37362c13d13ac22634c119210445c73be..b1d8fd85dcd08aee46000eed377e02245c5e16c6 100644 (file)
@@ -153,7 +153,7 @@ vl_video_buffer_init(struct pipe_video_context *context,
    buffer->num_planes = num_planes;
 
    memset(&templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D;
    templ.format = resource_formats[0];
    templ.width0 = width;
    templ.height0 = height;
@@ -173,16 +173,10 @@ vl_video_buffer_init(struct pipe_video_context *context,
 
    templ.format = resource_formats[1];
    if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
-      if (depth > 1)
-         templ.depth0 /= 2;
-      else
-         templ.width0 /= 2;
+      templ.width0 /= 2;
       templ.height0 /= 2;
    } else if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
-      if (depth > 1)
-         templ.depth0 /= 2;
-      else
-         templ.height0 /= 2;
+      templ.height0 /= 2;
    }
 
    buffer->resources[1] = pipe->screen->resource_create(pipe->screen, &templ);