[Mesa-dev] [PATCH 2/3] mesa: move gl_client_array*[] from vbo_draw_func into gl_context
Marek Olšák
maraeo at gmail.com
Mon May 7 11:04:08 PDT 2012
On Mon, May 7, 2012 at 6:24 PM, Brian Paul <brian.e.paul at gmail.com> wrote:
> On Tue, Apr 24, 2012 at 4:00 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> In the future we'd like to treat vertex arrays as a state and
>> not as a parameter to the draw function. This is the first step
>> towards that goal.
>
> Part of the goal is to avoid array re-validation for every draw call,
> right? Maybe say so in the comment.
Will do.
>
> More comments below.
>
>
>>
>> This commit adds:
>> const struct gl_client_array **gl_context::Array::Arrays.
>>
>> The pointer is changed in:
>> * vbo_draw_method
>> * vbo_rebase_prims - unused by gallium
>> * vbo_split_prims - unused by gallium
>> * st_RasterPos
>> ---
>> src/mesa/drivers/dri/i965/brw_draw.c | 2 +-
>> src/mesa/drivers/dri/i965/brw_draw.h | 1 -
>> src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 9 ++++-----
>> src/mesa/main/mtypes.h | 3 +++
>> src/mesa/state_tracker/st_cb_rasterpos.c | 5 ++++-
>> src/mesa/state_tracker/st_draw.c | 2 +-
>> src/mesa/state_tracker/st_draw.h | 2 --
>> src/mesa/state_tracker/st_draw_feedback.c | 2 +-
>> src/mesa/tnl/t_draw.c | 3 ++-
>> src/mesa/tnl/tnl.h | 1 -
>> src/mesa/vbo/vbo.h | 1 -
>> src/mesa/vbo/vbo_context.h | 15 +++++++++++++++
>> src/mesa/vbo/vbo_exec_array.c | 12 ++++++------
>> src/mesa/vbo/vbo_exec_draw.c | 3 +--
>> src/mesa/vbo/vbo_rebase.c | 8 ++++++--
>> src/mesa/vbo/vbo_save_draw.c | 3 +--
>> src/mesa/vbo/vbo_split_copy.c | 9 +++++++--
>> src/mesa/vbo/vbo_split_inplace.c | 9 +++++++--
>> 18 files changed, 59 insertions(+), 31 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
>> index da37b18..30faa95 100644
>> --- a/src/mesa/drivers/dri/i965/brw_draw.c
>> +++ b/src/mesa/drivers/dri/i965/brw_draw.c
>> @@ -531,7 +531,6 @@ retry:
>> }
>>
>> void brw_draw_prims( struct gl_context *ctx,
>> - const struct gl_client_array *arrays[],
>> const struct _mesa_prim *prim,
>> GLuint nr_prims,
>> const struct _mesa_index_buffer *ib,
>> @@ -540,6 +539,7 @@ void brw_draw_prims( struct gl_context *ctx,
>> GLuint max_index,
>> struct gl_transform_feedback_object *tfb_vertcount )
>> {
>> + const struct gl_client_array **arrays = ctx->Array.Arrays;
>> bool retval;
>>
>> if (!_mesa_check_conditional_render(ctx))
>> diff --git a/src/mesa/drivers/dri/i965/brw_draw.h b/src/mesa/drivers/dri/i965/brw_draw.h
>> index b910419..2cc4cb3 100644
>> --- a/src/mesa/drivers/dri/i965/brw_draw.h
>> +++ b/src/mesa/drivers/dri/i965/brw_draw.h
>> @@ -35,7 +35,6 @@ struct brw_context;
>>
>>
>> void brw_draw_prims( struct gl_context *ctx,
>> - const struct gl_client_array *arrays[],
>> const struct _mesa_prim *prims,
>> GLuint nr_prims,
>> const struct _mesa_index_buffer *ib,
>> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
>> index 62fee2e..6358b26 100644
>> --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
>> +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
>> @@ -216,7 +216,7 @@ get_max_client_stride(struct gl_context *ctx, const struct gl_client_array **arr
>> }
>>
>> static void
>> -TAG(vbo_render_prims)(struct gl_context *ctx, const struct gl_client_array **arrays,
>> +TAG(vbo_render_prims)(struct gl_context *ctx,
>> const struct _mesa_prim *prims, GLuint nr_prims,
>> const struct _mesa_index_buffer *ib,
>> GLboolean index_bounds_valid,
>> @@ -448,7 +448,6 @@ vbo_draw_imm(struct gl_context *ctx, const struct gl_client_array **arrays,
>>
>> static void
>> TAG(vbo_render_prims)(struct gl_context *ctx,
>> - const struct gl_client_array **arrays,
>> const struct _mesa_prim *prims, GLuint nr_prims,
>> const struct _mesa_index_buffer *ib,
>> GLboolean index_bounds_valid,
>> @@ -456,6 +455,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
>> struct gl_transform_feedback_object *tfb_vertcount)
>> {
>> struct nouveau_render_state *render = to_render_state(ctx);
>> + const struct gl_client_array **arrays = ctx->Array.Arrays;
>>
>> if (!index_bounds_valid)
>> vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
>> @@ -484,7 +484,6 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
>>
>> static void
>> TAG(vbo_check_render_prims)(struct gl_context *ctx,
>> - const struct gl_client_array **arrays,
>> const struct _mesa_prim *prims, GLuint nr_prims,
>> const struct _mesa_index_buffer *ib,
>> GLboolean index_bounds_valid,
>> @@ -496,12 +495,12 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
>> nouveau_validate_framebuffer(ctx);
>>
>> if (nctx->fallback == HWTNL)
>> - TAG(vbo_render_prims)(ctx, arrays, prims, nr_prims, ib,
>> + TAG(vbo_render_prims)(ctx, prims, nr_prims, ib,
>> index_bounds_valid, min_index, max_index,
>> tfb_vertcount);
>>
>> if (nctx->fallback == SWTNL)
>> - _tnl_vbo_draw_prims(ctx, arrays, prims, nr_prims, ib,
>> + _tnl_vbo_draw_prims(ctx, prims, nr_prims, ib,
>> index_bounds_valid, min_index, max_index,
>> tfb_vertcount);
>> }
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index 2b709de..eb103ad 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -1636,6 +1636,9 @@ struct gl_array_attrib
>>
>> /* GL_ARB_vertex_buffer_object */
>> struct gl_buffer_object *ArrayBufferObj;
>> +
>> + /** Vertex arrays as consumed by a driver. */
>
> The Arrays field is generally set up only by the VBO module, right?
> Maybe say so in the comment.
That's correct. I will update the comment as you propose.
>
>> + const struct gl_client_array **Arrays; /**< 0..VERT_ATTRIB_MAX-1 */
>
> The name is kind of generic and easy to gloss over as a key part of
> the drawing interface.
> I'd be tempted to call it "DrawArrays". What do you think?
It's a derived state, so I'll rename it to "_DrawArrays".
Marek
More information about the mesa-dev
mailing list