summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-03-09 23:40:08 +0100
committerChristian König <[email protected]>2011-03-09 23:40:08 +0100
commit0f07da0a1c87e1c7b53700c33d6b1f8f03c1fe11 (patch)
tree1be795fdab4d292c7015d3456d7d9aea714af99d /src/gallium/auxiliary
parent37a548c9d1db6bbf8712277f678d850f34d0e445 (diff)
[g3dvl] move idct out of mc code
iDCT and MC now look good, but sp_video_context is a total mess
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/vl/vl_idct.c21
-rw-r--r--src/gallium/auxiliary/vl/vl_idct.h3
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c205
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h25
4 files changed, 42 insertions, 212 deletions
diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c
index f191a898edd..e0307376a38 100644
--- a/src/gallium/auxiliary/vl/vl_idct.c
+++ b/src/gallium/auxiliary/vl/vl_idct.c
@@ -476,6 +476,15 @@ init_textures(struct vl_idct *idct, struct vl_idct_buffer *buffer)
buffer->sampler_views.all[i] = idct->pipe->create_sampler_view(idct->pipe, buffer->textures.all[i], &sampler_view);
}
+ template.target = PIPE_TEXTURE_2D;
+ /* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
+ template.format = PIPE_FORMAT_R16_SNORM;
+ template.width0 = idct->buffer_width;
+ template.height0 = idct->buffer_height;
+ template.depth0 = 1;
+
+ buffer->destination = idct->pipe->screen->resource_create(idct->pipe->screen, &template);
+
return true;
}
@@ -577,9 +586,8 @@ vl_idct_cleanup(struct vl_idct *idct)
pipe_resource_reference(&idct->matrix, NULL);
}
-bool
-vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
- struct pipe_resource *dst)
+struct pipe_resource *
+vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer)
{
struct pipe_surface template;
@@ -587,14 +595,12 @@ vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
assert(buffer);
assert(idct);
- assert(dst);
pipe_resource_reference(&buffer->textures.individual.matrix, idct->matrix);
pipe_resource_reference(&buffer->textures.individual.transpose, idct->matrix);
- pipe_resource_reference(&buffer->destination, dst);
if (!init_textures(idct, buffer))
- return false;
+ return NULL;
/* init state */
buffer->viewport[0].scale[0] = buffer->textures.individual.intermediate->width0;
@@ -640,7 +646,7 @@ vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
buffer->fb_state[i].zsbuf = NULL;
}
- return true;
+ return buffer->destination;
}
void
@@ -685,7 +691,6 @@ vl_idct_map_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer)
void
vl_idct_add_block(struct vl_idct_buffer *buffer, unsigned x, unsigned y, short *block)
{
- //struct vertex2s v;
unsigned tex_pitch;
short *texels;
diff --git a/src/gallium/auxiliary/vl/vl_idct.h b/src/gallium/auxiliary/vl/vl_idct.h
index 0ff12cf466d..264ad2bd226 100644
--- a/src/gallium/auxiliary/vl/vl_idct.h
+++ b/src/gallium/auxiliary/vl/vl_idct.h
@@ -97,8 +97,7 @@ bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
void vl_idct_cleanup(struct vl_idct *idct);
-bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
- struct pipe_resource *dst);
+struct pipe_resource *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);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index 160388ad049..5b675349481 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -481,68 +481,6 @@ cleanup_pipe_state(struct vl_mpeg12_mc_renderer *r)
r->pipe->delete_rasterizer_state(r->pipe, r->rs_state);
}
-static bool
-init_buffers(struct vl_mpeg12_mc_renderer *r)
-{
- struct pipe_resource *idct_matrix;
- unsigned chroma_width, chroma_height, chroma_blocks_x, chroma_blocks_y;
-
- assert(r);
-
- if (!(idct_matrix = vl_idct_upload_matrix(r->pipe)))
- return false;
-
- if (!vl_idct_init(&r->idct_y, r->pipe, r->buffer_width, r->buffer_height,
- 2, 2, TGSI_SWIZZLE_X, idct_matrix))
- return false;
-
- if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- chroma_width = r->buffer_width / 2;
- chroma_height = r->buffer_height / 2;
- chroma_blocks_x = 1;
- chroma_blocks_y = 1;
- } else if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
- chroma_width = r->buffer_width;
- chroma_height = r->buffer_height / 2;
- chroma_blocks_x = 2;
- chroma_blocks_y = 1;
- } else {
- chroma_width = r->buffer_width;
- chroma_height = r->buffer_height;
- chroma_blocks_x = 2;
- chroma_blocks_y = 2;
- }
-
- if(!vl_idct_init(&r->idct_cr, r->pipe, chroma_width, chroma_height,
- chroma_blocks_x, chroma_blocks_y, TGSI_SWIZZLE_Y, idct_matrix))
- return false;
-
- if(!vl_idct_init(&r->idct_cb, r->pipe, chroma_width, chroma_height,
- chroma_blocks_x, chroma_blocks_y, TGSI_SWIZZLE_Z, idct_matrix))
- return false;
-
- r->vs = create_vert_shader(r);
- r->fs = create_frag_shader(r);
-
- if (r->vs == NULL || r->fs == NULL)
- return false;
-
- return true;
-}
-
-static void
-cleanup_buffers(struct vl_mpeg12_mc_renderer *r)
-{
- assert(r);
-
- r->pipe->delete_vs_state(r->pipe, r->vs);
- r->pipe->delete_fs_state(r->pipe, r->fs);
-
- vl_idct_cleanup(&r->idct_y);
- vl_idct_cleanup(&r->idct_cr);
- vl_idct_cleanup(&r->idct_cb);
-}
-
static struct pipe_sampler_view
*find_or_create_sampler_view(struct vl_mpeg12_mc_renderer *r, struct pipe_surface *surface)
{
@@ -571,41 +509,6 @@ static struct pipe_sampler_view
}
static void
-grab_blocks(struct vl_mpeg12_mc_renderer *r,
- struct vl_mpeg12_mc_buffer *buffer,
- unsigned mbx, unsigned mby,
- unsigned cbp, short *blocks)
-{
- unsigned tb = 0;
- unsigned x, y;
-
- assert(r);
- assert(blocks);
-
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x, ++tb) {
- if (cbp & (*r->empty_block_mask)[0][y][x]) {
- vl_idct_add_block(&buffer->idct_y, mbx * 2 + x, mby * 2 + y, blocks);
- blocks += BLOCK_WIDTH * BLOCK_HEIGHT;
- }
- }
- }
-
- /* TODO: Implement 422, 444 */
- assert(r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
-
- for (tb = 1; tb < 3; ++tb) {
- if (cbp & (*r->empty_block_mask)[tb][0][0]) {
- if(tb == 1)
- vl_idct_add_block(&buffer->idct_cb, mbx, mby, blocks);
- else
- vl_idct_add_block(&buffer->idct_cr, mbx, mby, blocks);
- blocks += BLOCK_WIDTH * BLOCK_HEIGHT;
- }
- }
-}
-
-static void
texview_map_delete(const struct keymap *map,
const void *key, void *data,
void *user)
@@ -649,12 +552,15 @@ vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
if (!init_pipe_state(renderer))
goto error_pipe_state;
- if (!init_buffers(renderer))
- goto error_buffers;
+ renderer->vs = create_vert_shader(renderer);
+ renderer->fs = create_frag_shader(renderer);
+
+ if (renderer->vs == NULL || renderer->fs == NULL)
+ goto error_shaders;
return true;
-error_buffers:
+error_shaders:
cleanup_pipe_state(renderer);
error_pipe_state:
@@ -669,13 +575,15 @@ vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer)
util_delete_keymap(renderer->texview_map, renderer->pipe);
cleanup_pipe_state(renderer);
- cleanup_buffers(renderer);
+
+ renderer->pipe->delete_vs_state(renderer->pipe, renderer->vs);
+ renderer->pipe->delete_fs_state(renderer->pipe, renderer->fs);
}
bool
-vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer)
+vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
+ struct pipe_resource *y, struct pipe_resource *cr, struct pipe_resource *cb)
{
- struct pipe_resource template;
struct pipe_sampler_view sampler_view;
unsigned i;
@@ -686,41 +594,9 @@ vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg1
buffer->past = NULL;
buffer->future = NULL;
- memset(&template, 0, sizeof(struct pipe_resource));
- template.target = PIPE_TEXTURE_2D;
- /* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
- template.format = PIPE_FORMAT_R16_SNORM;
- template.last_level = 0;
- template.width0 = renderer->buffer_width;
- template.height0 = renderer->buffer_height;
- template.depth0 = 1;
- template.array_size = 1;
- template.usage = PIPE_USAGE_STATIC;
- template.bind = PIPE_BIND_SAMPLER_VIEW;
- template.flags = 0;
-
- buffer->textures.individual.y = renderer->pipe->screen->resource_create(renderer->pipe->screen, &template);
-
- if (!vl_idct_init_buffer(&renderer->idct_y, &buffer->idct_y, buffer->textures.individual.y))
- return false;
-
- if (renderer->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- template.width0 = renderer->buffer_width / 2;
- template.height0 = renderer->buffer_height / 2;
- }
- else if (renderer->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422)
- template.height0 = renderer->buffer_height / 2;
-
- buffer->textures.individual.cb =
- renderer->pipe->screen->resource_create(renderer->pipe->screen, &template);
- buffer->textures.individual.cr =
- renderer->pipe->screen->resource_create(renderer->pipe->screen, &template);
-
- if (!vl_idct_init_buffer(&renderer->idct_cb, &buffer->idct_cb, buffer->textures.individual.cb))
- return false;
-
- if (!vl_idct_init_buffer(&renderer->idct_cr, &buffer->idct_cr, buffer->textures.individual.cr))
- return false;
+ pipe_resource_reference(&buffer->textures.individual.y, y);
+ pipe_resource_reference(&buffer->textures.individual.cr, cr);
+ pipe_resource_reference(&buffer->textures.individual.cb, cb);
for (i = 0; i < 3; ++i) {
u_sampler_view_default_template(&sampler_view,
@@ -749,41 +625,21 @@ vl_mpeg12_mc_cleanup_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mp
pipe_resource_reference(&buffer->textures.all[i], NULL);
}
- vl_idct_cleanup_buffer(&renderer->idct_y, &buffer->idct_y);
- vl_idct_cleanup_buffer(&renderer->idct_cb, &buffer->idct_cb);
- vl_idct_cleanup_buffer(&renderer->idct_cr, &buffer->idct_cr);
-
pipe_surface_reference(&buffer->surface, NULL);
pipe_surface_reference(&buffer->past, NULL);
pipe_surface_reference(&buffer->future, NULL);
}
void
-vl_mpeg12_mc_map_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer)
+vl_mpeg12_mc_set_surfaces(struct vl_mpeg12_mc_renderer *renderer,
+ struct vl_mpeg12_mc_buffer *buffer,
+ struct pipe_surface *surface,
+ struct pipe_surface *past,
+ struct pipe_surface *future,
+ struct pipe_fence_handle **fence)
{
assert(renderer && buffer);
-
- vl_idct_map_buffers(&renderer->idct_y, &buffer->idct_y);
- vl_idct_map_buffers(&renderer->idct_cr, &buffer->idct_cr);
- vl_idct_map_buffers(&renderer->idct_cb, &buffer->idct_cb);
-}
-
-void
-vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
- struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_surface *surface,
- struct pipe_surface *past,
- struct pipe_surface *future,
- unsigned num_macroblocks,
- struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
- struct pipe_fence_handle **fence)
-{
- unsigned i;
-
- assert(renderer && buffer);
assert(surface);
- assert(num_macroblocks);
- assert(mpeg12_macroblocks);
if (surface != buffer->surface) {
pipe_surface_reference(&buffer->surface, surface);
@@ -795,23 +651,6 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
assert(buffer->past == past);
assert(buffer->future == future);
}
-
- for (i = 0; i < num_macroblocks; ++i) {
- struct pipe_mpeg12_macroblock *mb = &mpeg12_macroblocks[i];
-
- assert(mb->base.codec == PIPE_VIDEO_CODEC_MPEG12);
- grab_blocks(renderer, buffer, mb->mbx, mb->mby, mb->cbp, mb->blocks);
- }
-}
-
-void
-vl_mpeg12_mc_unmap_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer)
-{
- assert(renderer && buffer);
-
- vl_idct_unmap_buffers(&renderer->idct_y, &buffer->idct_y);
- vl_idct_unmap_buffers(&renderer->idct_cr, &buffer->idct_cr);
- vl_idct_unmap_buffers(&renderer->idct_cb, &buffer->idct_cb);
}
void
@@ -824,10 +663,6 @@ vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mp
if (not_empty_num_instances == 0 && empty_num_instances == 0)
return;
- vl_idct_flush(&renderer->idct_y, &buffer->idct_y, not_empty_num_instances);
- vl_idct_flush(&renderer->idct_cr, &buffer->idct_cr, not_empty_num_instances);
- vl_idct_flush(&renderer->idct_cb, &buffer->idct_cb, not_empty_num_instances);
-
renderer->fb_state.cbufs[0] = buffer->surface;
renderer->pipe->bind_rasterizer_state(renderer->pipe, renderer->rs_state);
renderer->pipe->set_framebuffer_state(renderer->pipe, &renderer->fb_state);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
index 86a6518e3c2..db8f2fff749 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
@@ -50,8 +50,6 @@ struct vl_mpeg12_mc_renderer
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state fb_state;
- struct vl_idct idct_y, idct_cr, idct_cb;
-
void *rs_state;
void *vs, *fs;
@@ -67,8 +65,6 @@ struct vl_mpeg12_mc_renderer
struct vl_mpeg12_mc_buffer
{
- struct vl_idct_buffer idct_y, idct_cb, idct_cr;
-
union
{
struct pipe_sampler_view *all[5];
@@ -93,22 +89,17 @@ bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
-bool vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
+bool vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
+ struct pipe_resource *y, struct pipe_resource *cr, struct pipe_resource *cb);
void vl_mpeg12_mc_cleanup_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
-void vl_mpeg12_mc_map_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
-
-void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
- struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_surface *surface,
- struct pipe_surface *past,
- struct pipe_surface *future,
- unsigned num_macroblocks,
- struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
- struct pipe_fence_handle **fence);
-
-void vl_mpeg12_mc_unmap_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
+void vl_mpeg12_mc_set_surfaces(struct vl_mpeg12_mc_renderer *renderer,
+ struct vl_mpeg12_mc_buffer *buffer,
+ struct pipe_surface *surface,
+ struct pipe_surface *past,
+ struct pipe_surface *future,
+ struct pipe_fence_handle **fence);
void vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
unsigned not_empty_start_instance, unsigned not_empty_num_instances,