vbo: Move vbo_bind_arrays into a dd_driver_functions draw callback.

Factor out that common call into the almost single place.
Remove the _mesa_set_drawing_arrays call from vbo_{exec,save}_draw code
paths as the function is now called through vbo_bind_arrays.
Prepare updating the list of struct gl_vertex_array entries via
calling _vbo_update_inputs for being pushed into those drivers that
finally work on that long list of gl_vertex_array pointers.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
Mathias Fröhlich 2018-03-16 06:34:35 +01:00 committed by Mathias Fröhlich
parent 6307d1be0a
commit c4c56ff303
4 changed files with 27 additions and 46 deletions

View File

@ -309,6 +309,31 @@ vbo_set_indirect_draw_func(struct gl_context *ctx,
}
/**
* Examine the enabled vertex arrays to set the exec->array.inputs[] values.
* These will point to the arrays to actually use for drawing. Some will
* be user-provided arrays, other will be zero-stride const-valued arrays.
*/
static void
vbo_bind_arrays(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
_mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
if (exec->array.recalculate_inputs) {
/* Finally update the inputs array */
_vbo_update_inputs(ctx, &vbo->draw_arrays);
ctx->NewDriverState |= ctx->DriverFlags.NewArray;
exec->array.recalculate_inputs = GL_FALSE;
}
assert(ctx->NewState == 0);
assert(ctx->Array._DrawVAO->NewArrays == 0);
}
void
_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
GLuint nr_prims, const struct _mesa_index_buffer *ib,
@ -317,6 +342,7 @@ _vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
unsigned tfb_stream, struct gl_buffer_object *indirect)
{
struct vbo_context *vbo = vbo_context(ctx);
vbo_bind_arrays(ctx);
vbo->draw_prims(ctx, prims, nr_prims, ib, index_bounds_valid,
min_index, max_index, tfb_vertcount, tfb_stream, indirect);
}
@ -332,6 +358,7 @@ _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
const struct _mesa_index_buffer *ib)
{
struct vbo_context *vbo = vbo_context(ctx);
vbo_bind_arrays(ctx);
vbo->draw_indirect_prims(ctx, mode, indirect_data, indirect_offset,
draw_count, stride, indirect_draw_count_buffer,
indirect_draw_count_offset, ib);

View File

@ -360,30 +360,6 @@ enabled_filter(const struct gl_context *ctx)
}
/**
* Examine the enabled vertex arrays to set the exec->array.inputs[] values.
* These will point to the arrays to actually use for drawing. Some will
* be user-provided arrays, other will be zero-stride const-valued arrays.
*/
static void
vbo_bind_arrays(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
_mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
if (exec->array.recalculate_inputs) {
/* Finally update the inputs array */
_vbo_update_inputs(ctx, &vbo->draw_arrays);
ctx->NewDriverState |= ctx->DriverFlags.NewArray;
exec->array.recalculate_inputs = GL_FALSE;
assert(ctx->NewState == 0);
}
}
/**
* Helper function called by the other DrawArrays() functions below.
* This is where we handle primitive restart for drawing non-indexed
@ -400,8 +376,6 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
if (skip_validated_draw(ctx))
return;
vbo_bind_arrays(ctx);
/* OpenGL 4.5 says that primitive restart is ignored with non-indexed
* draws.
*/
@ -818,8 +792,6 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
if (skip_draw_elements(ctx, count, indices))
return;
vbo_bind_arrays(ctx);
ib.count = count;
ib.index_size = sizeof_ib_type(type);
ib.obj = ctx->Array.VAO->IndexBufferObj;
@ -1251,8 +1223,6 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
return;
}
vbo_bind_arrays(ctx);
min_index_ptr = (uintptr_t) indices[0];
max_index_ptr = 0;
for (i = 0; i < primcount; i++) {
@ -1458,8 +1428,6 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
if (skip_validated_draw(ctx))
return;
vbo_bind_arrays(ctx);
/* init most fields to zero */
memset(&prim, 0, sizeof(prim));
prim.begin = 1;
@ -1557,8 +1525,6 @@ static void
vbo_validated_drawarraysindirect(struct gl_context *ctx,
GLenum mode, const GLvoid *indirect)
{
vbo_bind_arrays(ctx);
ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, (GLsizeiptr) indirect,
1 /* draw_count */ , 16 /* stride */ ,
@ -1580,8 +1546,6 @@ vbo_validated_multidrawarraysindirect(struct gl_context *ctx,
if (primcount == 0)
return;
vbo_bind_arrays(ctx);
ctx->Driver.DrawIndirect(ctx, mode, ctx->DrawIndirectBuffer, offset,
primcount, stride, NULL, 0, NULL);
@ -1597,8 +1561,6 @@ vbo_validated_drawelementsindirect(struct gl_context *ctx,
{
struct _mesa_index_buffer ib;
vbo_bind_arrays(ctx);
ib.count = 0; /* unknown */
ib.index_size = sizeof_ib_type(type);
ib.obj = ctx->Array.VAO->IndexBufferObj;
@ -1626,8 +1588,6 @@ vbo_validated_multidrawelementsindirect(struct gl_context *ctx,
if (primcount == 0)
return;
vbo_bind_arrays(ctx);
/* NOTE: IndexBufferObj is guaranteed to be a VBO. */
ib.count = 0; /* unknown */
@ -1798,8 +1758,6 @@ vbo_validated_multidrawarraysindirectcount(struct gl_context *ctx,
if (maxdrawcount == 0)
return;
vbo_bind_arrays(ctx);
ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, offset,
maxdrawcount, stride,
@ -1824,8 +1782,6 @@ vbo_validated_multidrawelementsindirectcount(struct gl_context *ctx,
if (maxdrawcount == 0)
return;
vbo_bind_arrays(ctx);
/* NOTE: IndexBufferObj is guaranteed to be a VBO. */
ib.count = 0; /* unknown */

View File

@ -238,7 +238,6 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
/* The exec VAO is not immutable, so we need to set manually */
ctx->NewDriverState |= ctx->DriverFlags.NewArray;
_mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
/* Finally update the inputs array */
_vbo_update_inputs(ctx, &vbo->draw_arrays);
}

View File

@ -208,7 +208,6 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
/* Finally update the inputs array */
_vbo_update_inputs(ctx, &vbo->draw_arrays);
_mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
assert(ctx->NewState == 0);