From b8a6e0e6fc451096d684a1e18529ab4879cdba0a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Sun, 17 Apr 2011 18:53:22 +0200 Subject: [PATCH] [g3dvl] give mv their own vertex buffer back --- src/gallium/auxiliary/vl/vl_defines.h | 3 + src/gallium/auxiliary/vl/vl_mc.c | 25 +- src/gallium/auxiliary/vl/vl_mc.h | 7 +- src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 54 ++-- src/gallium/auxiliary/vl/vl_mpeg12_decoder.h | 10 +- src/gallium/auxiliary/vl/vl_vertex_buffers.c | 230 ++++++++++++------ src/gallium/auxiliary/vl/vl_vertex_buffers.h | 32 ++- src/gallium/auxiliary/vl/vl_video_buffer.h | 2 +- src/gallium/include/pipe/p_video_state.h | 14 +- .../state_trackers/xorg/xvmc/surface.c | 20 +- 10 files changed, 246 insertions(+), 151 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_defines.h b/src/gallium/auxiliary/vl/vl_defines.h index 668991f904f..7568db027e6 100644 --- a/src/gallium/auxiliary/vl/vl_defines.h +++ b/src/gallium/auxiliary/vl/vl_defines.h @@ -35,4 +35,7 @@ #define BLOCK_WIDTH 8 #define BLOCK_HEIGHT 8 +#define VL_MAX_PLANES 3 +#define VL_MAX_REF_FRAMES 2 + #endif diff --git a/src/gallium/auxiliary/vl/vl_mc.c b/src/gallium/auxiliary/vl/vl_mc.c index 707a4a27077..2624d0502c1 100644 --- a/src/gallium/auxiliary/vl/vl_mc.c +++ b/src/gallium/auxiliary/vl/vl_mc.c @@ -612,17 +612,12 @@ prepare_pipe_4_rendering(struct vl_mc_buffer *buffer) } void -vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref, - unsigned not_empty_start_instance, unsigned not_empty_num_instances, - unsigned empty_start_instance, unsigned empty_num_instances) +vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref) { struct vl_mc *renderer; assert(buffer && ref); - if (not_empty_num_instances == 0 && empty_num_instances == 0) - return; - prepare_pipe_4_rendering(buffer); renderer = buffer->renderer; @@ -633,24 +628,19 @@ vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref, renderer->pipe->set_fragment_sampler_views(renderer->pipe, 1, &ref); renderer->pipe->bind_fragment_sampler_states(renderer->pipe, 1, &renderer->sampler_ref); - if (not_empty_num_instances > 0) - util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, - not_empty_start_instance, not_empty_num_instances); - - if (empty_num_instances > 0) - util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, - empty_start_instance, empty_num_instances); + util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0, + renderer->buffer_width / MACROBLOCK_WIDTH * + renderer->buffer_height / MACROBLOCK_HEIGHT); } void -vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, - unsigned not_empty_start_instance, unsigned not_empty_num_instances) +vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, unsigned num_instances) { struct vl_mc *renderer; assert(buffer); - if (not_empty_num_instances == 0) + if (num_instances == 0) return; prepare_pipe_4_rendering(buffer); @@ -663,6 +653,5 @@ vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, renderer->pipe->set_fragment_sampler_views(renderer->pipe, 1, &buffer->source); renderer->pipe->bind_fragment_sampler_states(renderer->pipe, 1, &renderer->sampler_ycbcr); - util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, - not_empty_start_instance, not_empty_num_instances); + util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances); } diff --git a/src/gallium/auxiliary/vl/vl_mc.h b/src/gallium/auxiliary/vl/vl_mc.h index e5b16b5b9da..bc2b0e7f149 100644 --- a/src/gallium/auxiliary/vl/vl_mc.h +++ b/src/gallium/auxiliary/vl/vl_mc.h @@ -75,11 +75,8 @@ void vl_mc_cleanup_buffer(struct vl_mc_buffer *buffer); void vl_mc_set_surface(struct vl_mc_buffer *buffer, struct pipe_surface *surface); -void vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref, - unsigned not_empty_start_instance, unsigned not_empty_num_instances, - unsigned empty_start_instance, unsigned empty_num_instances); +void vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref); -void vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, - unsigned not_empty_start_instance, unsigned not_empty_num_instances); +void vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, unsigned num_instances); #endif /* vl_mc_h */ diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 6d10cd16e32..1d8f0f92c37 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -293,6 +293,7 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder) dec->pipe->delete_vertex_elements_state(dec->pipe, dec->ves_mv[i]); pipe_resource_reference(&dec->quads.buffer, NULL); + pipe_resource_reference(&dec->pos.buffer, NULL); FREE(dec); } @@ -389,15 +390,9 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder) buffer->base.add_macroblocks = vl_mpeg12_buffer_add_macroblocks; buffer->base.unmap = vl_mpeg12_buffer_unmap; - buffer->vertex_bufs.individual.quad.stride = dec->quads.stride; - buffer->vertex_bufs.individual.quad.buffer_offset = dec->quads.buffer_offset; - pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, dec->quads.buffer); - - buffer->vertex_bufs.individual.stream = vl_vb_init(&buffer->vertex_stream, dec->pipe, - dec->base.width / MACROBLOCK_WIDTH * - dec->base.height / MACROBLOCK_HEIGHT); - if (!buffer->vertex_bufs.individual.stream.buffer) - goto error_vertex_stream; + vl_vb_init(&buffer->vertex_stream, dec->pipe, + dec->base.width / MACROBLOCK_WIDTH, + dec->base.height / MACROBLOCK_HEIGHT); formats[0] = formats[1] = formats[2] =dec->mc_source_format; buffer->mc_source = vl_video_buffer_init(dec->base.context, dec->pipe, @@ -461,7 +456,9 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer, struct pipe_sampler_view **sv[2]; struct pipe_surface **surfaces; - unsigned ne_start, ne_num, e_start, e_num; + struct pipe_vertex_buffer vb[3]; + + unsigned num_instances; unsigned i, j; assert(buf); @@ -474,9 +471,10 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer, surfaces = dst->get_surfaces(dst); - vl_vb_restart(&buf->vertex_stream, &ne_start, &ne_num, &e_start, &e_num); + num_instances = vl_vb_restart(&buf->vertex_stream); - dec->pipe->set_vertex_buffers(dec->pipe, 2, buf->vertex_bufs.all); + vb[0] = dec->quads; + vb[1] = dec->pos; for (i = 0; i < VL_MAX_PLANES; ++i) { vl_mc_set_surface(&buf->mc[i], surfaces[i]); @@ -484,18 +482,25 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer, for (j = 0; j < 2; ++j) { if (sv[j] == NULL) continue; + vb[2] = vl_vb_get_mv(&buf->vertex_stream, j);; + dec->pipe->set_vertex_buffers(dec->pipe, 3, vb); + dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_mv[j]); - vl_mc_render_ref(&buf->mc[i], sv[j][i], ne_start, ne_num, e_start, e_num); + vl_mc_render_ref(&buf->mc[i], sv[j][i]); } + } - dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_eb[i]); + vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream); + dec->pipe->set_vertex_buffers(dec->pipe, 2, vb); + for (i = 0; i < VL_MAX_PLANES; ++i) { + dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_eb[i]); if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) - vl_idct_flush(i == 0 ? &dec->idct_y : &dec->idct_c, &buf->idct[i], ne_num); - - vl_mc_render_ycbcr(&buf->mc[i], ne_start, ne_num); + vl_idct_flush(i == 0 ? &dec->idct_y : &dec->idct_c, &buf->idct[i], num_instances); + vl_mc_render_ycbcr(&buf->mc[i], num_instances); } + dec->pipe->flush(dec->pipe, fence); } @@ -503,11 +508,10 @@ static void vl_mpeg12_decoder_clear_buffer(struct pipe_video_decode_buffer *buffer) { struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer *)buffer; - unsigned ne_start, ne_num, e_start, e_num; assert(buf); - vl_vb_restart(&buf->vertex_stream, &ne_start, &ne_num, &e_start, &e_num); + vl_vb_restart(&buf->vertex_stream); } static bool @@ -691,18 +695,24 @@ vl_create_mpeg12_decoder(struct pipe_video_context *context, dec->base.flush_buffer = vl_mpeg12_decoder_flush_buffer; dec->base.clear_buffer = vl_mpeg12_decoder_clear_buffer; + dec->base.width = align(width, MACROBLOCK_WIDTH); + dec->base.height = align(height, MACROBLOCK_HEIGHT); + dec->pipe = pipe; dec->quads = vl_vb_upload_quads(dec->pipe, 2, 2); + dec->pos = vl_vb_upload_pos( + dec->pipe, + dec->base.width / MACROBLOCK_WIDTH, + dec->base.height / MACROBLOCK_HEIGHT + ); + for (i = 0; i < VL_MAX_PLANES; ++i) dec->ves_eb[i] = vl_vb_get_ves_eb(dec->pipe, i); for (i = 0; i < 2; ++i) dec->ves_mv[i] = vl_vb_get_ves_mv(dec->pipe, i); - dec->base.width = align(width, MACROBLOCK_WIDTH); - dec->base.height = align(height, MACROBLOCK_HEIGHT); - /* TODO: Implement 422, 444 */ assert(dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420); dec->empty_block_mask = &const_empty_block_mask_420; diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h index ffb9e56a13c..2bd5591b463 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h @@ -52,6 +52,8 @@ struct vl_mpeg12_decoder enum pipe_format mc_source_format; struct pipe_vertex_buffer quads; + struct pipe_vertex_buffer pos; + void *ves_eb[VL_MAX_PLANES]; void *ves_mv[2]; @@ -71,14 +73,6 @@ struct vl_mpeg12_buffer struct pipe_video_buffer *idct_intermediate; struct pipe_video_buffer *mc_source; - union - { - struct pipe_vertex_buffer all[2]; - struct { - struct pipe_vertex_buffer quad, stream; - } individual; - } vertex_bufs; - struct vl_idct_buffer idct[VL_MAX_PLANES]; struct vl_mc_buffer mc[VL_MAX_PLANES]; diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c index 84dfc9eccf6..c923686b06e 100644 --- a/src/gallium/auxiliary/vl/vl_vertex_buffers.c +++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.c @@ -37,7 +37,11 @@ struct vl_vertex_stream uint8_t dct_type_field; uint8_t dummy[2]; uint8_t eb[3][2][2]; - struct vertex4s mv[4]; +}; + +struct vl_mv_vertex_stream +{ + struct vertex4s mv[2]; }; /* vertices for a quad covering a block */ @@ -96,6 +100,52 @@ vl_vb_upload_quads(struct pipe_context *pipe, unsigned blocks_x, unsigned blocks return quad; } +struct pipe_vertex_buffer +vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height) +{ + struct pipe_vertex_buffer pos; + struct pipe_transfer *buf_transfer; + struct vertex2s *v; + + unsigned x, y; + + assert(pipe); + + /* create buffer */ + pos.stride = sizeof(struct vertex2s); + pos.buffer_offset = 0; + pos.buffer = pipe_buffer_create + ( + pipe->screen, + PIPE_BIND_VERTEX_BUFFER, + PIPE_USAGE_STATIC, + sizeof(struct vertex2s) * width * height + ); + + if(!pos.buffer) + return pos; + + /* and fill it */ + v = pipe_buffer_map + ( + pipe, + pos.buffer, + PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, + &buf_transfer + ); + + for ( y = 0; y < height; ++y) { + for ( x = 0; x < width; ++x, ++v) { + v->x = x; + v->y = y; + } + } + + pipe_buffer_unmap(pipe, buf_transfer); + + return pos; +} + static struct pipe_vertex_element vl_vb_get_quad_vertex_element(void) { @@ -159,50 +209,83 @@ vl_vb_get_ves_mv(struct pipe_context *pipe, int motionvector) { struct pipe_vertex_element vertex_elems[NUM_VS_INPUTS]; + assert(pipe); + memset(&vertex_elems, 0, sizeof(vertex_elems)); vertex_elems[VS_I_RECT] = vl_vb_get_quad_vertex_element(); - assert(pipe); - /* Position element */ vertex_elems[VS_I_VPOS].src_format = PIPE_FORMAT_R16G16_SSCALED; + vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 1, 1); + /* motion vector TOP element */ - vertex_elems[VS_I_MV_TOP].src_offset = offsetof(struct vl_vertex_stream, mv[motionvector * 2]); vertex_elems[VS_I_MV_TOP].src_format = PIPE_FORMAT_R16G16B16A16_SSCALED; /* motion vector BOTTOM element */ vertex_elems[VS_I_MV_BOTTOM].src_format = PIPE_FORMAT_R16G16B16A16_SSCALED; - vl_vb_element_helper(&vertex_elems[VS_I_VPOS], NUM_VS_INPUTS - 1, 1); + vl_vb_element_helper(&vertex_elems[VS_I_MV_TOP], 2, 2); return pipe->create_vertex_elements_state(pipe, NUM_VS_INPUTS, vertex_elems); } -struct pipe_vertex_buffer -vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe, unsigned size) +void +vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe, unsigned width, unsigned height) { - struct pipe_vertex_buffer buf; + unsigned i; assert(buffer); - buffer->size = size; - buffer->num_not_empty = 0; - buffer->num_empty = 0; + buffer->width = width; + buffer->height = height; + buffer->num_instances = 0; - buf.stride = sizeof(struct vl_vertex_stream); - buf.buffer_offset = 0; - buf.buffer = pipe_buffer_create + buffer->resource = pipe_buffer_create ( pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM, - sizeof(struct vl_vertex_stream) * size + sizeof(struct vl_vertex_stream) * width * height ); - pipe_resource_reference(&buffer->resource, buf.buffer); + for (i = 0; i < VL_MAX_REF_FRAMES; ++i) { + buffer->mv[i].resource = pipe_buffer_create + ( + pipe->screen, + PIPE_BIND_VERTEX_BUFFER, + PIPE_USAGE_STREAM, + sizeof(struct vl_mv_vertex_stream) * width * height + ); + } vl_vb_map(buffer, pipe); +} + +struct pipe_vertex_buffer +vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer) +{ + struct pipe_vertex_buffer buf; + + assert(buffer); + + buf.stride = sizeof(struct vl_vertex_stream); + buf.buffer_offset = 0; + buf.buffer = buffer->resource; + + return buf; +} + +struct pipe_vertex_buffer +vl_vb_get_mv(struct vl_vertex_buffer *buffer, int motionvector) +{ + struct pipe_vertex_buffer buf; + + assert(buffer); + + buf.stride = sizeof(struct vl_mv_vertex_stream); + buf.buffer_offset = 0; + buf.buffer = buffer->mv[motionvector].resource; return buf; } @@ -210,110 +293,119 @@ vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe, unsigned void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe) { + unsigned i; + assert(buffer && pipe); - buffer->start = pipe_buffer_map + buffer->buffer = pipe_buffer_map ( pipe, buffer->resource, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, &buffer->transfer ); - buffer->end = buffer->start + buffer->resource->width0 / sizeof(struct vl_vertex_stream); + + for (i = 0; i < VL_MAX_REF_FRAMES; ++i) { + buffer->mv[i].vertex_stream = pipe_buffer_map + ( + pipe, + buffer->mv[i].resource, + PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, + &buffer->mv[i].transfer + ); + } + } static void -get_motion_vectors(struct pipe_mpeg12_macroblock *mb, struct vertex4s mv[4]) +get_motion_vectors(enum pipe_mpeg12_motion_type mo_type, struct pipe_motionvector *src, struct vertex4s dst[2]) { - if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) { - mv[0].x = mv[1].x = mb->mv[0].top.x; - mv[0].y = mv[1].y = mb->mv[0].top.y; - mv[0].z = mv[1].z = 0; - - mv[2].x = mv[3].x = mb->mv[1].top.x; - mv[2].y = mv[3].y = mb->mv[1].top.y; - mv[2].z = mv[3].z = 0; + if (mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) { + dst[0].x = dst[1].x = src->top.x; + dst[0].y = dst[1].y = src->top.y; + dst[0].z = dst[1].z = 0; } else { - mv[0].x = mb->mv[0].top.x; - mv[0].y = mb->mv[0].top.y; - mv[0].z = mb->mv[0].top.field_select ? 3 : 1; - - mv[1].x = mb->mv[0].bottom.x; - mv[1].y = mb->mv[0].bottom.y; - mv[1].z = mb->mv[0].bottom.field_select ? 3 : 1; + dst[0].x = src->top.x; + dst[0].y = src->top.y; + dst[0].z = src->top.field_select ? 3 : 1; - mv[2].x = mb->mv[1].top.x; - mv[2].y = mb->mv[1].top.y; - mv[2].z = mb->mv[1].top.field_select ? 3 : 1; - - mv[3].x = mb->mv[1].bottom.x; - mv[3].y = mb->mv[1].bottom.y; - mv[3].z = mb->mv[1].bottom.field_select ? 3 : 1; + dst[1].x = src->bottom.x; + dst[1].y = src->bottom.y; + dst[1].z = src->bottom.field_select ? 3 : 1; } - mv[0].w = mv[1].w = mb->mv[0].wheight; - mv[2].w = mv[3].w = mb->mv[1].wheight; + dst[0].w = src->top.wheight; + dst[1].w = src->bottom.wheight; } void vl_vb_add_block(struct vl_vertex_buffer *buffer, struct pipe_mpeg12_macroblock *mb, const unsigned (*empty_block_mask)[3][2][2]) { - struct vl_vertex_stream *stream; unsigned i, j, k; + unsigned mv_pos; assert(buffer); assert(mb); - assert(buffer->num_not_empty + buffer->num_empty < buffer->size); + assert(buffer->num_instances < buffer->width * buffer->height); - if(mb->cbp) - stream = buffer->start + buffer->num_not_empty++; - else - stream = buffer->end - ++buffer->num_empty; + if(mb->cbp) { + struct vl_vertex_stream *stream; + stream = buffer->buffer + buffer->num_instances++; - stream->pos.x = mb->mbx; - stream->pos.y = mb->mby; + stream->pos.x = mb->mbx; + stream->pos.y = mb->mby; - for ( i = 0; i < 3; ++i) - for ( j = 0; j < 2; ++j) - for ( k = 0; k < 2; ++k) - stream->eb[i][j][k] = !(mb->cbp & (*empty_block_mask)[i][j][k]); + for ( i = 0; i < 3; ++i) + for ( j = 0; j < 2; ++j) + for ( k = 0; k < 2; ++k) + stream->eb[i][j][k] = !(mb->cbp & (*empty_block_mask)[i][j][k]); - stream->dct_type_field = mb->dct_type == PIPE_MPEG12_DCT_TYPE_FIELD; - stream->mb_type_intra = mb->dct_intra; + stream->dct_type_field = mb->dct_type == PIPE_MPEG12_DCT_TYPE_FIELD; + stream->mb_type_intra = mb->dct_intra; + } - get_motion_vectors(mb, stream->mv); + mv_pos = mb->mbx + mb->mby * buffer->width; + get_motion_vectors(mb->mo_type, &mb->mv[0], buffer->mv[0].vertex_stream[mv_pos].mv); + get_motion_vectors(mb->mo_type, &mb->mv[1], buffer->mv[1].vertex_stream[mv_pos].mv); } void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe) { + unsigned i; + assert(buffer && pipe); pipe_buffer_unmap(pipe, buffer->transfer); + for (i = 0; i < VL_MAX_REF_FRAMES; ++i) { + pipe_buffer_unmap(pipe, buffer->mv[i].transfer); + } } -void -vl_vb_restart(struct vl_vertex_buffer *buffer, - unsigned *not_empty_start_instance, unsigned *not_empty_num_instances, - unsigned *empty_start_instance, unsigned *empty_num_instances) +unsigned +vl_vb_restart(struct vl_vertex_buffer *buffer) { - assert(buffer); + unsigned num_instances; - *not_empty_start_instance = 0; - *not_empty_num_instances = buffer->num_not_empty; - *empty_start_instance = buffer->size - buffer->num_empty; - *empty_num_instances = buffer->num_empty; + assert(buffer); - buffer->num_not_empty = 0; - buffer->num_empty = 0; + num_instances = buffer->num_instances; + buffer->num_instances = 0; + return num_instances; } void vl_vb_cleanup(struct vl_vertex_buffer *buffer) { + unsigned i; + assert(buffer); pipe_resource_reference(&buffer->resource, NULL); + + for (i = 0; i < VL_MAX_REF_FRAMES; ++i) { + pipe_resource_reference(&buffer->mv[i].resource, NULL); + } } diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.h b/src/gallium/auxiliary/vl/vl_vertex_buffers.h index 62f7bf00508..bafaff7a311 100644 --- a/src/gallium/auxiliary/vl/vl_vertex_buffers.h +++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.h @@ -30,6 +30,7 @@ #include #include +#include "vl_defines.h" #include "vl_types.h" /* vertex buffers act as a todo list @@ -54,25 +55,36 @@ enum VS_INPUT struct vl_vertex_buffer { - unsigned size; - unsigned num_not_empty; - unsigned num_empty; + unsigned width, height; + unsigned num_instances; + struct pipe_resource *resource; struct pipe_transfer *transfer; - struct vl_vertex_stream *start; - struct vl_vertex_stream *end; + struct vl_vertex_stream *buffer; + + struct { + struct pipe_resource *resource; + struct pipe_transfer *transfer; + struct vl_mv_vertex_stream *vertex_stream; + } mv[VL_MAX_REF_FRAMES]; }; struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe, unsigned blocks_x, unsigned blocks_y); +struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height); + void *vl_vb_get_ves_eb(struct pipe_context *pipe, int component); void *vl_vb_get_ves_mv(struct pipe_context *pipe, int motionvector); -struct pipe_vertex_buffer vl_vb_init(struct vl_vertex_buffer *buffer, - struct pipe_context *pipe, - unsigned max_blocks); +void vl_vb_init(struct vl_vertex_buffer *buffer, + struct pipe_context *pipe, + unsigned width, unsigned height); + +struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer); + +struct pipe_vertex_buffer vl_vb_get_mv(struct vl_vertex_buffer *buffer, int motionvector); void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe); @@ -81,9 +93,7 @@ void vl_vb_add_block(struct vl_vertex_buffer *buffer, struct pipe_mpeg12_macrobl void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe); -void vl_vb_restart(struct vl_vertex_buffer *buffer, - unsigned *not_empty_start_instance, unsigned *not_empty_num_instances, - unsigned *empty_start_instance, unsigned *empty_num_instances); +unsigned vl_vb_restart(struct vl_vertex_buffer *buffer); void vl_vb_cleanup(struct vl_vertex_buffer *buffer); diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h index f5c424cf296..960acd28060 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.h +++ b/src/gallium/auxiliary/vl/vl_video_buffer.h @@ -31,7 +31,7 @@ #include #include -#define VL_MAX_PLANES 3 +#include "vl_defines.h" /** * implementation of a planar ycbcr buffer diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 72a27938847..2cf5ea4d975 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -69,10 +69,13 @@ struct pipe_macroblock enum pipe_video_codec codec; }; -struct pipe_mpeg12_motionvector +struct pipe_motionvector { - signed x, y; - bool field_select; + struct { + signed x, y; + bool field_select; + unsigned wheight:8; + } top, bottom; }; struct pipe_mpeg12_macroblock @@ -84,10 +87,7 @@ struct pipe_mpeg12_macroblock enum pipe_mpeg12_motion_type mo_type; bool dct_intra; enum pipe_mpeg12_dct_type dct_type; - struct { - unsigned wheight:8; - struct pipe_mpeg12_motionvector top, bottom; - } mv[2]; + struct pipe_motionvector mv[2]; unsigned cbp; short *blocks; }; diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index f22d315c90d..9752497eb30 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -114,28 +114,28 @@ MacroBlocksToPipe(struct pipe_screen *screen, switch (xvmc_mb->macroblock_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) { case XVMC_MB_TYPE_MOTION_FORWARD: - mb->mv[0].wheight = 255; - mb->mv[1].wheight = 0; + mb->mv[0].top.wheight = mb->mv[0].bottom.wheight = 255; + mb->mv[1].top.wheight = mb->mv[1].bottom.wheight = 0; break; case (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD): - mb->mv[0].wheight = 127; - mb->mv[1].wheight = 127; + mb->mv[0].top.wheight = mb->mv[0].bottom.wheight = 127; + mb->mv[1].top.wheight = mb->mv[1].bottom.wheight = 127; break; case XVMC_MB_TYPE_MOTION_BACKWARD: - mb->mv[0].wheight = 0; - mb->mv[1].wheight = 255; + mb->mv[0].top.wheight = mb->mv[0].bottom.wheight = 0; + mb->mv[1].top.wheight = mb->mv[1].bottom.wheight = 255; break; default: /* workaround for xines xxmc video out plugin */ if (!(xvmc_mb->macroblock_type & ~XVMC_MB_TYPE_PATTERN)) { - mb->mv[0].wheight = 255; - mb->mv[1].wheight = 0; + mb->mv[0].top.wheight = mb->mv[0].bottom.wheight = 255; + mb->mv[1].top.wheight = mb->mv[1].bottom.wheight = 0; } else { - mb->mv[0].wheight = 0; - mb->mv[1].wheight = 0; + mb->mv[0].top.wheight = mb->mv[0].bottom.wheight = 0; + mb->mv[1].top.wheight = mb->mv[1].bottom.wheight = 0; } break; } -- 2.30.2