diff options
author | Christian König <[email protected]> | 2011-06-04 23:54:46 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2011-06-04 23:54:46 +0200 |
commit | a6c76c8a90dc8995feed3c61b02dbd8408149036 (patch) | |
tree | c06a8c623635fc987c95d1bb445e4152ee1f4804 /src/gallium/auxiliary/vl | |
parent | f82cfe1eb40b1de9f6d4cbdce2c509e3e429c1d4 (diff) |
[g3dvl] use a vertex element instead of the instance id
Diffstat (limited to 'src/gallium/auxiliary/vl')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 21 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_decoder.h | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_vertex_buffers.c | 56 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_vertex_buffers.h | 16 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_zscan.c | 10 |
5 files changed, 85 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 35bf79261d3..201f3abab13 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -94,7 +94,7 @@ init_zscan_buffer(struct vl_mpeg12_buffer *buffer) formats[0] = formats[1] = formats[2] = dec->zscan_source_format; buffer->zscan_source = vl_video_buffer_init(dec->base.context, dec->pipe, dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT, - align(dec->max_blocks, dec->blocks_per_line) / dec->blocks_per_line, + align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line, 1, PIPE_VIDEO_CHROMA_FORMAT_444, formats, PIPE_USAGE_STATIC); if (!buffer->zscan_source) @@ -563,12 +563,14 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer, } } + vb[2] = dec->block_num; + dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_ycbcr); for (i = 0; i < VL_MAX_PLANES; ++i) { if (!num_ycbcr_blocks[i]) continue; vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, i); - dec->pipe->set_vertex_buffers(dec->pipe, 2, vb); + dec->pipe->set_vertex_buffers(dec->pipe, 3, vb); vl_zscan_render(&buf->zscan[i] , num_ycbcr_blocks[i]); @@ -585,7 +587,7 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer, if (!num_ycbcr_blocks[i]) continue; vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, component); - dec->pipe->set_vertex_buffers(dec->pipe, 2, vb); + dec->pipe->set_vertex_buffers(dec->pipe, 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]); @@ -680,14 +682,10 @@ find_format_config(struct vl_mpeg12_decoder *dec, const struct format_config con static bool init_zscan(struct vl_mpeg12_decoder *dec, const struct format_config* format_config) { - const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT; unsigned num_channels; assert(dec); - dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4); - dec->max_blocks = (dec->base.width * dec->base.height) / block_size_pixels; - dec->zscan_source_format = format_config->zscan_source_format; dec->zscan_linear = vl_zscan_layout(dec->pipe, vl_zscan_linear, dec->blocks_per_line); dec->zscan_normal = vl_zscan_layout(dec->pipe, vl_zscan_normal, dec->blocks_per_line); @@ -696,11 +694,11 @@ init_zscan(struct vl_mpeg12_decoder *dec, const struct format_config* format_con num_channels = dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT ? 4 : 1; if (!vl_zscan_init(&dec->zscan_y, dec->pipe, dec->base.width, dec->base.height, - dec->blocks_per_line, dec->max_blocks, num_channels)) + dec->blocks_per_line, dec->num_blocks, num_channels)) return false; if (!vl_zscan_init(&dec->zscan_c, dec->pipe, dec->chroma_width, dec->chroma_height, - dec->blocks_per_line, dec->max_blocks, num_channels)) + dec->blocks_per_line, dec->num_blocks, num_channels)) return false; return true; @@ -838,6 +836,7 @@ vl_create_mpeg12_decoder(struct pipe_video_context *context, enum pipe_video_chroma_format chroma_format, unsigned width, unsigned height) { + const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT; const struct format_config *format_config; struct vl_mpeg12_decoder *dec; @@ -861,12 +860,16 @@ vl_create_mpeg12_decoder(struct pipe_video_context *context, dec->pipe = pipe; + dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4); + dec->num_blocks = (dec->base.width * dec->base.height) / block_size_pixels; + dec->quads = vl_vb_upload_quads(dec->pipe); dec->pos = vl_vb_upload_pos( dec->pipe, dec->base.width / MACROBLOCK_WIDTH, dec->base.height / MACROBLOCK_HEIGHT ); + dec->block_num = vl_vb_upload_block_num(dec->pipe, dec->num_blocks); dec->ves_ycbcr = vl_vb_get_ves_ycbcr(dec->pipe); dec->ves_mv = vl_vb_get_ves_mv(dec->pipe); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h index 4fc19ff9524..474ae2d5d29 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h @@ -49,12 +49,13 @@ struct vl_mpeg12_decoder unsigned chroma_width, chroma_height; unsigned blocks_per_line; - unsigned max_blocks; + unsigned num_blocks; enum pipe_format zscan_source_format; struct pipe_vertex_buffer quads; struct pipe_vertex_buffer pos; + struct pipe_vertex_buffer block_num; void *ves_ycbcr; void *ves_mv; diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c index c45f96cec51..c0f1449bf80 100644 --- a/src/gallium/auxiliary/vl/vl_vertex_buffers.c +++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.c @@ -125,6 +125,49 @@ vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height) return pos; } +struct pipe_vertex_buffer +vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks) +{ + struct pipe_vertex_buffer buf; + struct pipe_transfer *buf_transfer; + struct vertex2s *v; + unsigned i; + + assert(pipe); + + /* create buffer */ + buf.stride = sizeof(struct vertex2s); + buf.buffer_offset = 0; + buf.buffer = pipe_buffer_create + ( + pipe->screen, + PIPE_BIND_VERTEX_BUFFER, + PIPE_USAGE_STATIC, + sizeof(struct vertex2s) * num_blocks + ); + + if(!buf.buffer) + return buf; + + /* and fill it */ + v = pipe_buffer_map + ( + pipe, + buf.buffer, + PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, + &buf_transfer + ); + + for ( i = 0; i < num_blocks; ++i, ++v) { + v->x = i; + v->y = i; + } + + pipe_buffer_unmap(pipe, buf_transfer); + + return buf; +} + static struct pipe_vertex_element vl_vb_get_quad_vertex_element(void) { @@ -170,7 +213,12 @@ vl_vb_get_ves_ycbcr(struct pipe_context *pipe) vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 1, 1); - return pipe->create_vertex_elements_state(pipe, 2, vertex_elems); + /* block num element */ + vertex_elems[VS_I_BLOCK_NUM].src_format = PIPE_FORMAT_R16G16_SSCALED; + + vl_vb_element_helper(&vertex_elems[VS_I_BLOCK_NUM], 1, 2); + + return pipe->create_vertex_elements_state(pipe, 3, vertex_elems); } void * @@ -249,6 +297,12 @@ error_ycbcr: return false; } +unsigned +vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer) +{ + return 1; +} + struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component) { diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.h b/src/gallium/auxiliary/vl/vl_vertex_buffers.h index 7e727cbca12..74845a42b69 100644 --- a/src/gallium/auxiliary/vl/vl_vertex_buffers.h +++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.h @@ -41,13 +41,15 @@ /* inputs to the vertex shaders */ enum VS_INPUT { - VS_I_RECT, - VS_I_VPOS, + VS_I_RECT = 0, + VS_I_VPOS = 1, - VS_I_MV_TOP, - VS_I_MV_BOTTOM, + VS_I_BLOCK_NUM = 2, - NUM_VS_INPUTS + VS_I_MV_TOP = 2, + VS_I_MV_BOTTOM = 3, + + NUM_VS_INPUTS = 4 }; struct vl_vertex_buffer @@ -71,6 +73,8 @@ struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe); struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height); +struct pipe_vertex_buffer vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks); + void *vl_vb_get_ves_ycbcr(struct pipe_context *pipe); void *vl_vb_get_ves_mv(struct pipe_context *pipe); @@ -79,6 +83,8 @@ bool vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe, unsigned width, unsigned height); +unsigned vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer); + void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe); struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component); diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c index 4af3962209f..2b52d610f8f 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.c +++ b/src/gallium/auxiliary/vl/vl_zscan.c @@ -92,8 +92,8 @@ create_vert_shader(struct vl_zscan *zscan) { struct ureg_program *shader; - struct ureg_src scale, instance; - struct ureg_src vrect, vpos; + struct ureg_src scale; + struct ureg_src vrect, vpos, block_num; struct ureg_dst tmp; struct ureg_dst o_vpos, o_vtex[zscan->num_channels]; @@ -108,11 +108,11 @@ create_vert_shader(struct vl_zscan *zscan) (float)BLOCK_WIDTH / zscan->buffer_width, (float)BLOCK_HEIGHT / zscan->buffer_height); - instance = ureg_DECL_system_value(shader, 0, TGSI_SEMANTIC_INSTANCEID, 0); - vrect = ureg_DECL_vs_input(shader, VS_I_RECT); vpos = ureg_DECL_vs_input(shader, VS_I_VPOS); + block_num = ureg_DECL_system_value(shader, 0, TGSI_SEMANTIC_INSTANCEID, 0); + tmp = ureg_DECL_temporary(shader); o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS); @@ -136,7 +136,7 @@ create_vert_shader(struct vl_zscan *zscan) ureg_MUL(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), ureg_src(tmp), scale); ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 1.0f)); - ureg_MUL(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XW), ureg_scalar(instance, TGSI_SWIZZLE_X), + ureg_MUL(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XW), ureg_scalar(block_num, TGSI_SWIZZLE_X), ureg_imm1f(shader, 1.0f / zscan->blocks_per_line)); ureg_FRC(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X)); |