diff options
author | Christian König <[email protected]> | 2010-11-25 22:10:21 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2010-11-25 22:10:21 +0100 |
commit | 3dd7bf7d39781f3ef4c0b53732945674c9924cdf (patch) | |
tree | 0e695ed2477cc79f5e0dc313c2f63235c397cbcc /src/gallium/auxiliary | |
parent | 9cff90534389c2aad9b58ff04b1a5d624e3d0bdb (diff) |
[g3dvl] no need to keep the idct matrix multiple times
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_idct.c | 104 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_idct.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 13 |
3 files changed, 67 insertions, 54 deletions
diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c index c1550cb365a..5ee4e674d96 100644 --- a/src/gallium/auxiliary/vl/vl_idct.c +++ b/src/gallium/auxiliary/vl/vl_idct.c @@ -384,9 +384,6 @@ init_buffers(struct vl_idct *idct) template.bind = PIPE_BIND_SAMPLER_VIEW; template.flags = 0; - idct->textures.individual.transpose = idct->pipe->screen->resource_create(idct->pipe->screen, &template); - idct->textures.individual.matrix = idct->pipe->screen->resource_create(idct->pipe->screen, &template); - template.format = idct->destination->format; template.width0 = idct->destination->width0; template.height0 = idct->destination->height0; @@ -483,17 +480,8 @@ init_constants(struct vl_idct *idct) struct pipe_transfer *buf_transfer; struct vertex_shader_consts *vs_consts; struct vertex2f *v; - float *f; - - struct pipe_box rect = - { - 0, 0, 0, - BLOCK_WIDTH, - BLOCK_HEIGHT, - 1 - }; - unsigned i, j, pitch; + unsigned i; /* quad vectors */ v = pipe_buffer_map @@ -507,42 +495,6 @@ init_constants(struct vl_idct *idct) memcpy(v + i * 4, &const_quad, sizeof(const_quad)); pipe_buffer_unmap(idct->pipe, idct->vertex_bufs.individual.quad.buffer, buf_transfer); - /* transposed matrix */ - buf_transfer = idct->pipe->get_transfer - ( - idct->pipe, idct->textures.individual.transpose, - u_subresource(0, 0), - PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, - &rect - ); - pitch = buf_transfer->stride / util_format_get_blocksize(buf_transfer->resource->format); - - f = idct->pipe->transfer_map(idct->pipe, buf_transfer); - for(i = 0; i < BLOCK_HEIGHT; ++i) - for(j = 0; j < BLOCK_WIDTH; ++j) - f[i * pitch * 4 + j] = const_matrix[j][i]; // transpose - - idct->pipe->transfer_unmap(idct->pipe, buf_transfer); - idct->pipe->transfer_destroy(idct->pipe, buf_transfer); - - /* matrix */ - buf_transfer = idct->pipe->get_transfer - ( - idct->pipe, idct->textures.individual.matrix, - u_subresource(0, 0), - PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, - &rect - ); - pitch = buf_transfer->stride / util_format_get_blocksize(buf_transfer->resource->format); - - f = idct->pipe->transfer_map(idct->pipe, buf_transfer); - for(i = 0; i < BLOCK_HEIGHT; ++i) - for(j = 0; j < BLOCK_WIDTH; ++j) - f[i * pitch * 4 + j] = const_matrix[j][i]; // transpose - - idct->pipe->transfer_unmap(idct->pipe, buf_transfer); - idct->pipe->transfer_destroy(idct->pipe, buf_transfer); - /* normalisation constants */ vs_consts = pipe_buffer_map ( @@ -610,12 +562,64 @@ cleanup_state(struct vl_idct *idct) idct->pipe->delete_sampler_state(idct->pipe, idct->samplers.all[i]); } +struct pipe_resource * +vl_idct_upload_matrix(struct pipe_context *pipe) +{ + struct pipe_resource template, *matrix; + struct pipe_transfer *buf_transfer; + unsigned i, j, pitch; + float *f; + + struct pipe_box rect = + { + 0, 0, 0, + BLOCK_WIDTH, + BLOCK_HEIGHT, + 1 + }; + + memset(&template, 0, sizeof(struct pipe_resource)); + template.target = PIPE_TEXTURE_2D; + template.format = PIPE_FORMAT_R32G32B32A32_FLOAT; + template.last_level = 0; + template.width0 = 2; + template.height0 = 8; + template.depth0 = 1; + template.usage = PIPE_USAGE_IMMUTABLE; + template.bind = PIPE_BIND_SAMPLER_VIEW; + template.flags = 0; + + matrix = pipe->screen->resource_create(pipe->screen, &template); + + /* matrix */ + buf_transfer = pipe->get_transfer + ( + pipe, matrix, + u_subresource(0, 0), + PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, + &rect + ); + pitch = buf_transfer->stride / util_format_get_blocksize(buf_transfer->resource->format); + + f = pipe->transfer_map(pipe, buf_transfer); + for(i = 0; i < BLOCK_HEIGHT; ++i) + for(j = 0; j < BLOCK_WIDTH; ++j) + f[i * pitch * 4 + j] = const_matrix[j][i]; // transpose + + pipe->transfer_unmap(pipe, buf_transfer); + pipe->transfer_destroy(pipe, buf_transfer); + + return matrix; +} + bool -vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resource *dst) +vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resource *dst, struct pipe_resource *matrix) { assert(idct && pipe && dst); idct->pipe = pipe; + pipe_resource_reference(&idct->textures.individual.matrix, matrix); + pipe_resource_reference(&idct->textures.individual.transpose, matrix); pipe_resource_reference(&idct->destination, dst); init_state(idct); diff --git a/src/gallium/auxiliary/vl/vl_idct.h b/src/gallium/auxiliary/vl/vl_idct.h index 01df3f9103f..ed64a308f3b 100644 --- a/src/gallium/auxiliary/vl/vl_idct.h +++ b/src/gallium/auxiliary/vl/vl_idct.h @@ -97,7 +97,9 @@ struct vl_idct } surfaces; }; -bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resource *dst); +struct pipe_resource *vl_idct_upload_matrix(struct pipe_context *pipe); + +bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resource *dst, struct pipe_resource *matrix); void vl_idct_cleanup(struct vl_idct *idct); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 8099929b8b0..b756f2db611 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -1295,8 +1295,11 @@ vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer, enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode, bool pot_buffers) { + struct pipe_resource *idct_matrix; + assert(renderer); assert(pipe); + /* TODO: Implement other policies */ assert(bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE); /* TODO: Non-pot buffers untested, probably doesn't work without changes to texcoord generation, vert shader, etc */ @@ -1332,13 +1335,16 @@ vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer, renderer->future = NULL; renderer->num_macroblocks = 0; - if(!vl_idct_init(&renderer->idct_y, pipe, renderer->textures.individual.y)) + if(!(idct_matrix = vl_idct_upload_matrix(pipe))) + goto error_idct_matrix; + + if(!vl_idct_init(&renderer->idct_y, pipe, renderer->textures.individual.y, idct_matrix)) goto error_idct_y; - if(!vl_idct_init(&renderer->idct_cr, pipe, renderer->textures.individual.cr)) + if(!vl_idct_init(&renderer->idct_cr, pipe, renderer->textures.individual.cr, idct_matrix)) goto error_idct_cr; - if(!vl_idct_init(&renderer->idct_cb, pipe, renderer->textures.individual.cb)) + if(!vl_idct_init(&renderer->idct_cb, pipe, renderer->textures.individual.cb, idct_matrix)) goto error_idct_cb; return true; @@ -1350,6 +1356,7 @@ error_idct_cr: vl_idct_cleanup(&renderer->idct_y); error_idct_y: +error_idct_matrix: cleanup_buffers(renderer); error_buffers: |