[g3dvl] fix vertex buffer size calculation
authorChristian König <deathsimple@vodafone.de>
Sun, 3 Apr 2011 18:49:15 +0000 (20:49 +0200)
committerChristian König <deathsimple@vodafone.de>
Sun, 3 Apr 2011 18:49:15 +0000 (20:49 +0200)
src/gallium/auxiliary/vl/vl_mpeg12_context.c
src/gallium/auxiliary/vl/vl_mpeg12_context.h
src/gallium/auxiliary/vl/vl_vertex_buffers.c

index d8605398d495d2576f6a22657a9c47648ae64984..0eab9e3c614749d4e23af4efb8d9619d4b4f5118 100644 (file)
@@ -332,7 +332,8 @@ vl_mpeg12_create_buffer(struct pipe_video_context *vpipe)
    pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, ctx->quads.buffer);
 
    buffer->vertex_bufs.individual.stream = vl_vb_init(&buffer->vertex_stream, ctx->pipe,
-                                                      ctx->vertex_buffer_size);
+                                                      ctx->buffer_width / MACROBLOCK_WIDTH *
+                                                      ctx->buffer_height / MACROBLOCK_HEIGHT);
    if (!buffer->vertex_bufs.individual.stream.buffer)
       goto error_vertex_stream;
 
@@ -691,7 +692,6 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
    ctx->pot_buffers = pot_buffers;
 
    ctx->quads = vl_vb_upload_quads(ctx->pipe, 2, 2);
-   ctx->vertex_buffer_size = width / MACROBLOCK_WIDTH * height / MACROBLOCK_HEIGHT;
    ctx->ves_y = vl_vb_get_elems_state(ctx->pipe, TGSI_SWIZZLE_X);
    ctx->ves_cb = vl_vb_get_elems_state(ctx->pipe, TGSI_SWIZZLE_Y);
    ctx->ves_cr = vl_vb_get_elems_state(ctx->pipe, TGSI_SWIZZLE_Z);
index a90110bf61b9f97d0424512ae851ecc059182a30..698522f16ea28eba07df467d670df965e9112a6f 100644 (file)
@@ -47,7 +47,6 @@ struct vl_mpeg12_context
    const unsigned (*empty_block_mask)[3][2][2];
 
    struct pipe_vertex_buffer quads;
-   unsigned vertex_buffer_size;
    void *ves_y, *ves_cb, *ves_cr;
 
    struct vl_idct idct_y, idct_c;
index 59aa1e9db75d3ebe341ed13ad4cd1abb5381cd70..1094b76ec0db2e7c3496d86c05146132d6a384cf 100644 (file)
@@ -264,6 +264,7 @@ vl_vb_add_block(struct vl_vertex_buffer *buffer, struct pipe_mpeg12_macroblock *
 
    assert(buffer);
    assert(mb);
+   assert(buffer->num_not_empty + buffer->num_empty < buffer->size);
 
    if(mb->cbp)
       stream = buffer->start + buffer->num_not_empty++;