From d128c091c74f3cd862bd12a381bc521cae42264c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Sat, 13 Nov 2010 14:06:47 +0100 Subject: [PATCH] [g3dvl] use quads instead of triangles --- src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 105 +++++++++++------------ 1 file changed, 48 insertions(+), 57 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 9cbc015..ddfd0b7 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -111,21 +111,12 @@ enum MACROBLOCK_TYPE NUM_MACROBLOCK_TYPES }; -/* vertices for two triangles covering four block */ -static const struct vertex2f const_rectangle[4][2][3] = { - { - { {0.0f, 0.0f}, {0.0f, 0.5f}, {0.5f, 0.0f} }, - { {0.5f, 0.0f}, {0.0f, 0.5f}, {0.5f, 0.5f} } - }, { - { {0.5f, 0.0f}, {0.5f, 0.5f}, {1.0f, 0.0f} }, - { {1.0f, 0.0f}, {0.5f, 0.5f}, {1.0f, 0.5f} } - }, { - { {0.0f, 0.5f}, {0.0f, 1.0f}, {0.5f, 0.5f} }, - { {0.5f, 0.5f}, {0.0f, 1.0f}, {0.5f, 1.0f} } - }, { - { {0.5f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f} }, - { {1.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 1.0f} } - } +/* vertices for four quads covering the blocks */ +static const struct vertex2f const_quads[4][4] = { + { {0.0f, 0.0f}, {0.5f, 0.0f}, {0.5f, 0.5f}, {0.0f, 0.5f} }, + { {0.5f, 0.0f}, {1.0f, 0.0f}, {1.0f, 0.5f}, {0.5f, 0.5f} }, + { {0.0f, 0.5f}, {0.5f, 0.5f}, {0.5f, 1.0f}, {0.0f, 1.0f} }, + { {0.5f, 0.5f}, {1.0f, 0.5f}, {1.0f, 1.0f}, {0.5f, 1.0f} }, }; static void * @@ -762,36 +753,36 @@ init_buffers(struct vl_mpeg12_mc_renderer *r) } r->vertex_bufs.individual.rect.stride = sizeof(struct vertex2f); - r->vertex_bufs.individual.rect.max_index = 24 * r->macroblocks_per_batch - 1; + r->vertex_bufs.individual.rect.max_index = 16 * r->macroblocks_per_batch - 1; r->vertex_bufs.individual.rect.buffer_offset = 0; r->vertex_bufs.individual.rect.buffer = pipe_buffer_create ( r->pipe->screen, PIPE_BIND_VERTEX_BUFFER, - sizeof(struct vertex2f) * 24 * r->macroblocks_per_batch + sizeof(struct vertex2f) * 16 * r->macroblocks_per_batch ); r->vertex_bufs.individual.ycbcr.stride = sizeof(struct vert_stream_0); - r->vertex_bufs.individual.ycbcr.max_index = 24 * r->macroblocks_per_batch - 1; + r->vertex_bufs.individual.ycbcr.max_index = 16 * r->macroblocks_per_batch - 1; r->vertex_bufs.individual.ycbcr.buffer_offset = 0; /* XXX: Create with usage DYNAMIC or STREAM */ r->vertex_bufs.individual.ycbcr.buffer = pipe_buffer_create ( r->pipe->screen, PIPE_BIND_VERTEX_BUFFER, - sizeof(struct vert_stream_0) * 24 * r->macroblocks_per_batch + sizeof(struct vert_stream_0) * 16 * r->macroblocks_per_batch ); for (i = 0; i < 2; ++i) { r->vertex_bufs.individual.ref[i].stride = sizeof(struct vertex2f) * 2; - r->vertex_bufs.individual.ref[i].max_index = 24 * r->macroblocks_per_batch - 1; + r->vertex_bufs.individual.ref[i].max_index = 16 * r->macroblocks_per_batch - 1; r->vertex_bufs.individual.ref[i].buffer_offset = 0; /* XXX: Create with usage DYNAMIC or STREAM */ r->vertex_bufs.individual.ref[i].buffer = pipe_buffer_create ( r->pipe->screen, PIPE_BIND_VERTEX_BUFFER, - sizeof(struct vertex2f) * 2 * 24 * r->macroblocks_per_batch + sizeof(struct vertex2f) * 2 * 16 * r->macroblocks_per_batch ); } @@ -881,7 +872,7 @@ init_const_buffers(struct vl_mpeg12_mc_renderer *r) ); for ( i = 0; i < r->macroblocks_per_batch; ++i) - memcpy(rect + i * 24, &const_rectangle, sizeof(const_rectangle)); + memcpy(rect + i * 16, &const_quads, sizeof(const_quads)); pipe_buffer_unmap(r->pipe, r->vertex_bufs.individual.rect.buffer, buf_transfer); @@ -968,7 +959,7 @@ gen_block_verts(struct vert_stream_0 *vb, struct pipe_mpeg12_macroblock *mb, v.interlaced = mb->dct_type == PIPE_MPEG12_DCT_TYPE_FIELD ? 1.0f : 0.0f; - for ( i = 0; i < 6; ++i ) + for ( i = 0; i < 4; ++i ) memcpy(vb + i, &v, sizeof(v)); } @@ -996,13 +987,13 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r, assert(ref_vb && ref_vb[1]); - vb = ref_vb[1] + pos * 2 * 24; + vb = ref_vb[1] + pos * 2 * 16; mo_vec[0].x = mb->pmv[0][1][0]; mo_vec[0].y = mb->pmv[0][1][1]; if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) { - for (i = 0; i < 24 * 2; i += 2) { + for (i = 0; i < 16 * 2; i += 2) { vb[i].x = mo_vec[0].x; vb[i].y = mo_vec[0].y; } @@ -1016,7 +1007,7 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r, if(mb->mvfs[0][1]) mo_vec[0].y += 2; if(!mb->mvfs[1][1]) mo_vec[1].y -= 2; - for (i = 0; i < 24 * 2; i += 2) { + for (i = 0; i < 16 * 2; i += 2) { vb[i].x = mo_vec[0].x; vb[i].y = mo_vec[0].y; vb[i + 1].x = mo_vec[1].x; @@ -1033,7 +1024,7 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r, assert(ref_vb && ref_vb[0]); - vb = ref_vb[0] + pos * 2 * 24; + vb = ref_vb[0] + pos * 2 * 16; if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD) { mo_vec[0].x = mb->pmv[0][1][0]; @@ -1065,13 +1056,13 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r, } if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) { - for (i = 0; i < 24 * 2; i += 2) { + for (i = 0; i < 16 * 2; i += 2) { vb[i].x = mo_vec[0].x; vb[i].y = mo_vec[0].y; } } else { - for (i = 0; i < 24 * 2; i += 2) { + for (i = 0; i < 16 * 2; i += 2) { vb[i].x = mo_vec[0].x; vb[i].y = mo_vec[0].y; vb[i + 1].x = mo_vec[1].x; @@ -1083,18 +1074,18 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r, } case PIPE_MPEG12_MACROBLOCK_TYPE_INTRA: { - struct vert_stream_0 *vb = ycbcr_vb + pos * 24; + struct vert_stream_0 *vb = ycbcr_vb + pos * 16; if(mb->dct_type == PIPE_MPEG12_DCT_TYPE_FRAME) { gen_block_verts(vb , mb, 32, 32, 2, 1); - gen_block_verts(vb + 6 , mb, 16, 16, 2, 1); - gen_block_verts(vb + 12, mb, 8, 8, 2, 1); - gen_block_verts(vb + 18, mb, 4, 4, 2, 1); + gen_block_verts(vb + 4 , mb, 16, 16, 2, 1); + gen_block_verts(vb + 8 , mb, 8, 8, 2, 1); + gen_block_verts(vb + 12, mb, 4, 4, 2, 1); } else { gen_block_verts(vb , mb, 32, 8, 2, 1); - gen_block_verts(vb + 6 , mb, 16, 4, 2, 1); - gen_block_verts(vb + 12, mb, 32, 8, 2, 1); - gen_block_verts(vb + 18, mb, 16, 4, 2, 1); + gen_block_verts(vb + 4 , mb, 16, 4, 2, 1); + gen_block_verts(vb + 8 , mb, 32, 8, 2, 1); + gen_block_verts(vb + 12, mb, 16, 4, 2, 1); } break; @@ -1205,9 +1196,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->i_vs); r->pipe->bind_fs_state(r->pipe, r->i_fs); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_INTRA] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_INTRA] * 16; } if (num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] > 0) { @@ -1220,9 +1211,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[0]); r->pipe->bind_fs_state(r->pipe, r->p_fs[0]); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 16; } if (num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] > 0) { @@ -1235,9 +1226,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[1]); r->pipe->bind_fs_state(r->pipe, r->p_fs[1]); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 16; } if (num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] > 0) { @@ -1250,9 +1241,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[0]); r->pipe->bind_fs_state(r->pipe, r->p_fs[0]); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 16; } if (num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] > 0) { @@ -1265,9 +1256,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[1]); r->pipe->bind_fs_state(r->pipe, r->p_fs[1]); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 16; } if (num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] > 0) { @@ -1282,9 +1273,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->b_vs[0]); r->pipe->bind_fs_state(r->pipe, r->b_fs[0]); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 16; } if (num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] > 0) { @@ -1299,9 +1290,9 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->b_vs[1]); r->pipe->bind_fs_state(r->pipe, r->b_fs[1]); - util_draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24); - vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24; + util_draw_arrays(r->pipe, PIPE_PRIM_QUADS, vb_start, + num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 16); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 16; } r->pipe->flush(r->pipe, PIPE_FLUSH_RENDER_CACHE, r->fence); -- 2.7.4