aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-04-10 18:46:31 +0200
committerChristian König <[email protected]>2011-04-10 18:46:31 +0200
commit31109e1be20d7c94521879c3221a9f77bacbdb8d (patch)
tree0163f6a26c26b7c55888766c30e5ea4ac8fd797c
parent8b0a9cc62c36bb48d2d7b488787eb2966bcbf7f2 (diff)
[g3dvl] also use video buffer for idct intermediate
-rw-r--r--src/gallium/auxiliary/vl/vl_idct.c36
-rw-r--r--src/gallium/auxiliary/vl/vl_idct.h4
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_decoder.c54
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_decoder.h1
-rw-r--r--src/gallium/auxiliary/vl/vl_video_buffer.c12
5 files changed, 52 insertions, 55 deletions
diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c
index dc4a9bbb8c9..5d5ead31f7d 100644
--- a/src/gallium/auxiliary/vl/vl_idct.c
+++ b/src/gallium/auxiliary/vl/vl_idct.c
@@ -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;
diff --git a/src/gallium/auxiliary/vl/vl_idct.h b/src/gallium/auxiliary/vl/vl_idct.h
index 5d3784ce6c0..4ad798a855b 100644
--- a/src/gallium/auxiliary/vl/vl_idct.h
+++ b/src/gallium/auxiliary/vl/vl_idct.h
@@ -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);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 31163b9d08e..afb69e9c3bf 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -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);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
index e90f8d3880b..9be807198fe 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
@@ -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
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
index 5ea0dfa3736..b1d8fd85dcd 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -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);