diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h index 624f872cd1d..1e317f0ed00 100644 --- a/src/mesa/main/arrayobj.h +++ b/src/mesa/main/arrayobj.h @@ -171,33 +171,25 @@ _mesa_draw_array_bits(const struct gl_context *ctx) /** - * Return enabled user space vertex attribute bits for draw. + * Return the enabled user (= non-VBO) attrib mask and the non-zero divisor + * attrib mask for the draw. * - * Needs the a fully updated VAO ready for draw. + * Needs a fully updated VAO ready for draw. */ -static inline GLbitfield -_mesa_draw_user_array_bits(const struct gl_context *ctx) +static inline void +_mesa_get_derived_vao_masks(const struct gl_context *ctx, + GLbitfield *enabled_user_attribs, + GLbitfield *nonzero_divisor_attribs) { const struct gl_vertex_array_object *const vao = ctx->Array._DrawVAO; + assert(!vao->NewVertexBuffers && !vao->NewVertexElements); - return ~vao->_EffEnabledVBO & ctx->Array._DrawVAOEnabledAttribs; + *enabled_user_attribs = ~vao->_EffEnabledVBO & + ctx->Array._DrawVAOEnabledAttribs; + *nonzero_divisor_attribs = vao->_EffEnabledNonZeroDivisor & + ctx->Array._DrawVAOEnabledAttribs; } - -/** - * 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->NewVertexBuffers && !vao->NewVertexElements); - return vao->_EffEnabledNonZeroDivisor & ctx->Array._DrawVAOEnabledAttribs; -} - - /** * Return enabled current values attribute bits for draw. */ diff --git a/src/mesa/state_tracker/st_atom_array.cpp b/src/mesa/state_tracker/st_atom_array.cpp index 8cf91b7927f..035fcabacb2 100644 --- a/src/mesa/state_tracker/st_atom_array.cpp +++ b/src/mesa/state_tracker/st_atom_array.cpp @@ -296,7 +296,9 @@ st_setup_current_user(struct st_context *st, } template void ALWAYS_INLINE -st_update_array_templ(struct st_context *st) +st_update_array_templ(struct st_context *st, + const GLbitfield enabled_user_attribs, + const GLbitfield nonzero_divisor_attribs) { struct gl_context *ctx = st->ctx; @@ -307,11 +309,11 @@ st_update_array_templ(struct st_context *st) const struct st_common_variant *vp_variant = st->vp_variant; const GLbitfield inputs_read = vp_variant->vert_attrib_mask; const GLbitfield dual_slot_inputs = vp->Base.DualSlotInputs; - const GLbitfield userbuf_attribs = inputs_read & _mesa_draw_user_array_bits(ctx); + const GLbitfield userbuf_attribs = inputs_read & enabled_user_attribs; bool uses_user_vertex_buffers = userbuf_attribs != 0; st->draw_needs_minmax_index = - (userbuf_attribs & ~_mesa_draw_nonzero_divisor_bits(ctx)) != 0; + (userbuf_attribs & ~nonzero_divisor_attribs) != 0; struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS]; unsigned num_vbuffers = 0; @@ -361,6 +363,11 @@ template void ALWAYS_INLINE st_update_array_impl(struct st_context *st) { struct gl_context *ctx = st->ctx; + GLbitfield enabled_user_attribs; + GLbitfield nonzero_divisor_attribs; + + _mesa_get_derived_vao_masks(ctx, &enabled_user_attribs, + &nonzero_divisor_attribs); /* Changing from user to non-user buffers and vice versa can switch between * cso and u_vbuf, which means that we need to update vertex elements even @@ -368,10 +375,12 @@ st_update_array_impl(struct st_context *st) */ if (ctx->Array.NewVertexElements || st->uses_user_vertex_buffers != - !!(st->vp_variant->vert_attrib_mask & _mesa_draw_user_array_bits(ctx))) { - st_update_array_templ(st); + !!(st->vp_variant->vert_attrib_mask & enabled_user_attribs)) { + st_update_array_templ + (st, enabled_user_attribs, nonzero_divisor_attribs); } else { - st_update_array_templ(st); + st_update_array_templ + (st, enabled_user_attribs, nonzero_divisor_attribs); } }