diff options
author | Younes Manton <[email protected]> | 2008-12-20 16:30:33 -0500 |
---|---|---|
committer | Younes Manton <[email protected]> | 2009-01-10 13:52:06 -0500 |
commit | 3c1b790c313b46e16640d25a93d165646454d3d6 (patch) | |
tree | c899a83ecf7a6d1c4d16e54f3b73d9892ebdbda6 /src/gallium/state_trackers/g3dvl | |
parent | 9beb004885ab5be652bcb733a5fd9ee729f89921 (diff) |
g3dvl: Map vertex bufs once per frame/flush.
Diffstat (limited to 'src/gallium/state_trackers/g3dvl')
-rw-r--r-- | src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c index 426e5ba065a..a31f5c58f46 100644 --- a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c +++ b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c @@ -43,6 +43,14 @@ struct vlFragmentShaderConsts struct vlVertex4f div; }; +struct vlMacroBlockVertexStream0 +{ + struct vlVertex2f pos; + struct vlVertex2f luma_tc; + struct vlVertex2f cb_tc; + struct vlVertex2f cr_tc; +}; + struct vlR16SnormBufferedMC { struct vlRender base; @@ -390,7 +398,9 @@ static inline int vlGrabMacroBlockVB ( struct vlR16SnormBufferedMC *mc, struct vlMpeg2MacroBlock *macroblock, - unsigned int pos + unsigned int pos, + struct vlMacroBlockVertexStream0 *ycbcr_vb, + struct vlVertex2f **ref_vb ) { struct vlVertex2f mo_vec[2]; @@ -398,6 +408,7 @@ static inline int vlGrabMacroBlockVB assert(mc); assert(macroblock); + assert(ycbcr_vb); switch (macroblock->mb_type) { @@ -405,12 +416,9 @@ static inline int vlGrabMacroBlockVB { struct vlVertex2f *vb; - vb = (struct vlVertex2f*)mc->pipe->winsys->buffer_map - ( - mc->pipe->winsys, - mc->vertex_bufs.ref[1].buffer, - PIPE_BUFFER_USAGE_CPU_WRITE - ) + pos * 2 * 24; + assert(ref_vb && ref_vb[1]); + + vb = ref_vb[1] + pos * 2 * 24; mo_vec[0].x = macroblock->PMV[0][1][0] * 0.5f * mc->surface_tex_inv_size.x; mo_vec[0].y = macroblock->PMV[0][1][1] * 0.5f * mc->surface_tex_inv_size.y; @@ -437,8 +445,6 @@ static inline int vlGrabMacroBlockVB } } - mc->pipe->winsys->buffer_unmap(mc->pipe->winsys, mc->vertex_bufs.ref[1].buffer); - /* fall-through */ } case vlMacroBlockTypeFwdPredicted: @@ -446,12 +452,9 @@ static inline int vlGrabMacroBlockVB { struct vlVertex2f *vb; - vb = (struct vlVertex2f*)mc->pipe->winsys->buffer_map - ( - mc->pipe->winsys, - mc->vertex_bufs.ref[0].buffer, - PIPE_BUFFER_USAGE_CPU_WRITE - ) + pos * 2 * 24; + assert(ref_vb && ref_vb[0]); + + vb = ref_vb[0] + pos * 2 * 24; if (macroblock->mb_type == vlMacroBlockTypeBkwdPredicted) { @@ -495,8 +498,6 @@ static inline int vlGrabMacroBlockVB } } - mc->pipe->winsys->buffer_unmap(mc->pipe->winsys, mc->vertex_bufs.ref[0].buffer); - /* fall-through */ } case vlMacroBlockTypeIntra: @@ -512,20 +513,9 @@ static inline int vlGrabMacroBlockVB mc->surface_tex_inv_size.y * (VL_MACROBLOCK_HEIGHT / 2) }; - struct vlMacroBlockVertexStream0 - { - struct vlVertex2f pos; - struct vlVertex2f luma_tc; - struct vlVertex2f cb_tc; - struct vlVertex2f cr_tc; - } *vb; + struct vlMacroBlockVertexStream0 *vb; - vb = (struct vlMacroBlockVertexStream0*)mc->pipe->winsys->buffer_map - ( - mc->pipe->winsys, - mc->vertex_bufs.ycbcr.buffer, - PIPE_BUFFER_USAGE_CPU_WRITE - ) + pos * 24; + vb = ycbcr_vb + pos * 24; SET_BLOCK ( @@ -559,8 +549,6 @@ static inline int vlGrabMacroBlockVB 4, 2, 1, mc->zero_block ); - mc->pipe->winsys->buffer_unmap(mc->pipe->winsys, mc->vertex_bufs.ycbcr.buffer); - break; } default: @@ -607,13 +595,37 @@ static int vlFlush for (i = 1; i < vlNumMacroBlockExTypes; ++i) offset[i] = offset[i - 1] + num_macroblocks[i - 1]; - for (i = 0; i < mc->num_macroblocks; ++i) { - enum vlMacroBlockTypeEx mb_type_ex = vlGetMacroBlockTypeEx(&mc->macroblocks[i]); + struct vlMacroBlockVertexStream0 *ycbcr_vb; + struct vlVertex2f *ref_vb[2]; + + ycbcr_vb = (struct vlMacroBlockVertexStream0*)mc->pipe->winsys->buffer_map + ( + mc->pipe->winsys, + mc->vertex_bufs.ycbcr.buffer, + PIPE_BUFFER_USAGE_CPU_WRITE + ); + + for (i = 0; i < 2; ++i) + ref_vb[i] = (struct vlVertex2f*)mc->pipe->winsys->buffer_map + ( + mc->pipe->winsys, + mc->vertex_bufs.ref[i].buffer, + PIPE_BUFFER_USAGE_CPU_WRITE + ); - vlGrabMacroBlockVB(mc, &mc->macroblocks[i], offset[mb_type_ex]); + for (i = 0; i < mc->num_macroblocks; ++i) + { + enum vlMacroBlockTypeEx mb_type_ex = vlGetMacroBlockTypeEx(&mc->macroblocks[i]); + + vlGrabMacroBlockVB(mc, &mc->macroblocks[i], offset[mb_type_ex], ycbcr_vb, ref_vb); + + offset[mb_type_ex]++; + } - offset[mb_type_ex]++; + mc->pipe->winsys->buffer_unmap(mc->pipe->winsys, mc->vertex_bufs.ycbcr.buffer); + for (i = 0; i < 2; ++i) + mc->pipe->winsys->buffer_unmap(mc->pipe->winsys, mc->vertex_bufs.ref[i].buffer); } for (i = 0; i < 3; ++i) |