mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-14 05:48:04 +02:00
st/mesa: simplify determination whether a draw needs min/max index
Reviewed-by: Mathias Fröhlich <mathias.froehlich@web.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3829>
This commit is contained in:
parent
1d93372802
commit
fd6636ebc0
6 changed files with 38 additions and 5 deletions
|
|
@ -611,9 +611,12 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
|
||||||
const GLbitfield enabled = vao->Enabled;
|
const GLbitfield enabled = vao->Enabled;
|
||||||
/* VBO array bits. */
|
/* VBO array bits. */
|
||||||
const GLbitfield vbos = vao->VertexAttribBufferMask;
|
const GLbitfield vbos = vao->VertexAttribBufferMask;
|
||||||
|
const GLbitfield divisor_is_nonzero = vao->NonZeroDivisorMask;
|
||||||
|
|
||||||
/* Compute and store effectively enabled and mapped vbo arrays */
|
/* Compute and store effectively enabled and mapped vbo arrays */
|
||||||
vao->_EffEnabledVBO = _mesa_vao_enable_to_vp_inputs(mode, enabled & vbos);
|
vao->_EffEnabledVBO = _mesa_vao_enable_to_vp_inputs(mode, enabled & vbos);
|
||||||
|
vao->_EffEnabledNonZeroDivisor =
|
||||||
|
_mesa_vao_enable_to_vp_inputs(mode, enabled & divisor_is_nonzero);
|
||||||
/* Walk those enabled arrays that have a real vbo attached */
|
/* Walk those enabled arrays that have a real vbo attached */
|
||||||
GLbitfield mask = enabled;
|
GLbitfield mask = enabled;
|
||||||
while (mask) {
|
while (mask) {
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,20 @@ _mesa_draw_user_array_bits(const struct gl_context *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return which enabled vertex attributes have a non-zero instance divisor.
|
||||||
|
*
|
||||||
|
* Needs the a fully updated VAO ready for draw.
|
||||||
|
*/
|
||||||
|
static inline GLbitfield
|
||||||
|
_mesa_draw_nonzero_divisor_bits(const struct gl_context *ctx)
|
||||||
|
{
|
||||||
|
const struct gl_vertex_array_object *const vao = ctx->Array._DrawVAO;
|
||||||
|
assert(vao->NewArrays == 0);
|
||||||
|
return ~vao->_EffEnabledNonZeroDivisor & ctx->Array._DrawVAOEnabledAttribs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return enabled current values attribute bits for draw.
|
* Return enabled current values attribute bits for draw.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1580,8 +1580,10 @@ copy_array_object(struct gl_context *ctx,
|
||||||
/* Enabled must be the same than on push */
|
/* Enabled must be the same than on push */
|
||||||
dest->Enabled = src->Enabled;
|
dest->Enabled = src->Enabled;
|
||||||
dest->_EffEnabledVBO = src->_EffEnabledVBO;
|
dest->_EffEnabledVBO = src->_EffEnabledVBO;
|
||||||
|
dest->_EffEnabledNonZeroDivisor = src->_EffEnabledNonZeroDivisor;
|
||||||
/* The bitmask of bound VBOs needs to match the VertexBinding array */
|
/* The bitmask of bound VBOs needs to match the VertexBinding array */
|
||||||
dest->VertexAttribBufferMask = src->VertexAttribBufferMask;
|
dest->VertexAttribBufferMask = src->VertexAttribBufferMask;
|
||||||
|
dest->NonZeroDivisorMask = src->NonZeroDivisorMask;
|
||||||
dest->_AttributeMapMode = src->_AttributeMapMode;
|
dest->_AttributeMapMode = src->_AttributeMapMode;
|
||||||
dest->NewArrays = src->NewArrays;
|
dest->NewArrays = src->NewArrays;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1547,6 +1547,9 @@ struct gl_vertex_array_object
|
||||||
/** Mask indicating which vertex arrays have vertex buffer associated. */
|
/** Mask indicating which vertex arrays have vertex buffer associated. */
|
||||||
GLbitfield VertexAttribBufferMask;
|
GLbitfield VertexAttribBufferMask;
|
||||||
|
|
||||||
|
/** Mask indicating which vertex arrays have a non-zero instance divisor. */
|
||||||
|
GLbitfield NonZeroDivisorMask;
|
||||||
|
|
||||||
/** Mask of VERT_BIT_* values indicating which arrays are enabled */
|
/** Mask of VERT_BIT_* values indicating which arrays are enabled */
|
||||||
GLbitfield Enabled;
|
GLbitfield Enabled;
|
||||||
|
|
||||||
|
|
@ -1559,6 +1562,9 @@ struct gl_vertex_array_object
|
||||||
*/
|
*/
|
||||||
GLbitfield _EffEnabledVBO;
|
GLbitfield _EffEnabledVBO;
|
||||||
|
|
||||||
|
/** Same as _EffEnabledVBO, but for instance divisors. */
|
||||||
|
GLbitfield _EffEnabledNonZeroDivisor;
|
||||||
|
|
||||||
/** Denotes the way the position/generic0 attribute is mapped */
|
/** Denotes the way the position/generic0 attribute is mapped */
|
||||||
gl_attribute_map_mode _AttributeMapMode;
|
gl_attribute_map_mode _AttributeMapMode;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,11 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx,
|
||||||
else
|
else
|
||||||
vao->VertexAttribBufferMask &= ~array_bit;
|
vao->VertexAttribBufferMask &= ~array_bit;
|
||||||
|
|
||||||
|
if (vao->BufferBinding[bindingIndex].InstanceDivisor)
|
||||||
|
vao->NonZeroDivisorMask |= array_bit;
|
||||||
|
else
|
||||||
|
vao->NonZeroDivisorMask &= ~array_bit;
|
||||||
|
|
||||||
vao->BufferBinding[array->BufferBindingIndex]._BoundArrays &= ~array_bit;
|
vao->BufferBinding[array->BufferBindingIndex]._BoundArrays &= ~array_bit;
|
||||||
vao->BufferBinding[bindingIndex]._BoundArrays |= array_bit;
|
vao->BufferBinding[bindingIndex]._BoundArrays |= array_bit;
|
||||||
|
|
||||||
|
|
@ -250,6 +255,12 @@ vertex_binding_divisor(struct gl_context *ctx,
|
||||||
|
|
||||||
if (binding->InstanceDivisor != divisor) {
|
if (binding->InstanceDivisor != divisor) {
|
||||||
binding->InstanceDivisor = divisor;
|
binding->InstanceDivisor = divisor;
|
||||||
|
|
||||||
|
if (divisor)
|
||||||
|
vao->NonZeroDivisorMask |= binding->_BoundArrays;
|
||||||
|
else
|
||||||
|
vao->NonZeroDivisorMask &= ~binding->_BoundArrays;
|
||||||
|
|
||||||
vao->NewArrays |= vao->Enabled & binding->_BoundArrays;
|
vao->NewArrays |= vao->Enabled & binding->_BoundArrays;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,8 @@ st_setup_arrays(struct st_context *st,
|
||||||
GLbitfield userbuf_attribs = inputs_read & _mesa_draw_user_array_bits(ctx);
|
GLbitfield userbuf_attribs = inputs_read & _mesa_draw_user_array_bits(ctx);
|
||||||
|
|
||||||
*has_user_vertex_buffers = userbuf_attribs != 0;
|
*has_user_vertex_buffers = userbuf_attribs != 0;
|
||||||
|
st->draw_needs_minmax_index =
|
||||||
|
(userbuf_attribs & ~_mesa_draw_nonzero_divisor_bits(ctx)) != 0;
|
||||||
|
|
||||||
while (mask) {
|
while (mask) {
|
||||||
/* The attribute index to start pulling a binding */
|
/* The attribute index to start pulling a binding */
|
||||||
|
|
@ -164,9 +166,6 @@ st_setup_arrays(struct st_context *st,
|
||||||
vbuffer[bufidx].buffer.user = ptr;
|
vbuffer[bufidx].buffer.user = ptr;
|
||||||
vbuffer[bufidx].is_user_buffer = true;
|
vbuffer[bufidx].is_user_buffer = true;
|
||||||
vbuffer[bufidx].buffer_offset = 0;
|
vbuffer[bufidx].buffer_offset = 0;
|
||||||
|
|
||||||
if (!binding->InstanceDivisor)
|
|
||||||
st->draw_needs_minmax_index = true;
|
|
||||||
}
|
}
|
||||||
vbuffer[bufidx].stride = binding->Stride; /* in bytes */
|
vbuffer[bufidx].stride = binding->Stride; /* in bytes */
|
||||||
|
|
||||||
|
|
@ -296,8 +295,6 @@ st_update_array(struct st_context *st)
|
||||||
unsigned num_velements;
|
unsigned num_velements;
|
||||||
bool uses_user_vertex_buffers;
|
bool uses_user_vertex_buffers;
|
||||||
|
|
||||||
st->draw_needs_minmax_index = false;
|
|
||||||
|
|
||||||
/* ST_NEW_VERTEX_ARRAYS alias ctx->DriverFlags.NewArray */
|
/* ST_NEW_VERTEX_ARRAYS alias ctx->DriverFlags.NewArray */
|
||||||
/* Setup arrays */
|
/* Setup arrays */
|
||||||
st_setup_arrays(st, vp, vp_variant, velements, vbuffer, &num_vbuffers,
|
st_setup_arrays(st, vp, vp_variant, velements, vbuffer, &num_vbuffers,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue