[Mesa-dev] [PATCH 10/11] vbo: map indirect buffer and extract params if doing sw primitive restart

Brian Paul brianp at vmware.com
Mon Nov 4 06:47:27 PST 2013


On 11/04/2013 02:09 AM, Chris Forbes wrote:
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>   src/mesa/vbo/vbo_primitive_restart.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
>
> diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c
> index 48d04e1..ffe0c41 100644
> --- a/src/mesa/vbo/vbo_primitive_restart.c
> +++ b/src/mesa/vbo/vbo_primitive_restart.c
> @@ -180,6 +180,33 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
>      GLboolean map_ib = ib->obj->Name && !ib->obj->Pointer;
>      void *ptr;
>
> +   /* If there is an indirect buffer, map it and extract the draw params */
> +   if (indirect && prims[0].is_indirect) {
> +      struct _mesa_prim new_prim = *prims;
> +      struct _mesa_index_buffer new_ib = *ib;
> +      const uint32_t *indirect_params;
> +      ctx->Driver.MapBufferRange(ctx, 0, indirect->Size, GL_MAP_READ_BIT,
> +            (struct gl_buffer_object *)indirect);

Let's check the return value of MapBufferRange for NULL.  In the past 
I've had to add fixes for stuff like that when there's buffer allocation 
failures when tons of buffers are allocated by the app (some viewperf 
tests, for example).


> +
> +      assert(nr_prims == 1);
> +      indirect_params = (const uint32_t *) ADD_POINTERS(indirect->Pointer,
> +            new_prim.indirect_offset);
> +
> +      new_prim.is_indirect = 0;
> +      new_prim.count = indirect_params[0];
> +      new_prim.num_instances = indirect_params[1];
> +      new_prim.start = indirect_params[2];
> +      new_prim.basevertex = indirect_params[3];
> +      new_prim.base_instance = indirect_params[4];
> +
> +      new_ib.count = new_prim.count;
> +
> +      prims = &new_prim;
> +      ib = &new_ib;
> +
> +      ctx->Driver.UnmapBuffer(ctx, (struct gl_buffer_object *)indirect);
> +   }
> +
>      /* Find the sub-primitives. These are regions in the index buffer which
>       * are split based on the primitive restart index value.
>       */
>



More information about the mesa-dev mailing list