mesa: precompute _mesa_get_vao_vp_inputs

It's called for every draw, so this is important.

All inputs of _mesa_get_vao_vp_inputs are changed when
update_attribute_map_mode is called, so we can just compute
the value there.

The assertion ensures correct behavior in debug builds.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8798>
This commit is contained in:
Marek Olšák 2021-01-25 19:02:39 -05:00 committed by Marge Bot
parent 40b8838a5a
commit 306f1ef417
5 changed files with 15 additions and 15 deletions

View file

@ -158,18 +158,6 @@ _mesa_vao_enable_to_vp_inputs(gl_attribute_map_mode mode, GLbitfield enabled)
}
/**
* Return the vp_inputs enabled bitmask after application of
* the position/generic0 aliasing map.
*/
static inline GLbitfield
_mesa_get_vao_vp_inputs(const struct gl_vertex_array_object *vao)
{
const gl_attribute_map_mode mode = vao->_AttributeMapMode;
return _mesa_vao_enable_to_vp_inputs(mode, vao->Enabled);
}
/**
* Helper functions for consuming backends to walk the
* ctx->Array._DrawVAO for driver side array setup.

View file

@ -1658,6 +1658,9 @@ struct gl_vertex_array_object
/** Denotes the way the position/generic0 attribute is mapped */
gl_attribute_map_mode _AttributeMapMode;
/** "Enabled" with the position/generic0 attribute aliasing resolved */
GLbitfield _EnabledWithMapMode;
/** Mask of VERT_BIT_* values indicating changed/dirty arrays */
GLbitfield NewArrays;

View file

@ -680,8 +680,11 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
new_array = true;
}
/* May shuffle the position and generic0 bits around, filter out unwanted */
const GLbitfield enabled = filter & _mesa_get_vao_vp_inputs(vao);
assert(vao->_EnabledWithMapMode ==
_mesa_vao_enable_to_vp_inputs(vao->_AttributeMapMode, vao->Enabled));
/* Filter out unwanted arrays. */
const GLbitfield enabled = filter & vao->_EnabledWithMapMode;
if (ctx->Array._DrawVAOEnabledAttribs != enabled) {
ctx->Array._DrawVAOEnabledAttribs = enabled;
new_array = true;

View file

@ -1882,6 +1882,9 @@ _mesa_enable_vertex_array_attribs(struct gl_context *ctx,
/* Update the map mode if needed */
if (attrib_bits & (VERT_BIT_POS|VERT_BIT_GENERIC0))
update_attribute_map_mode(ctx, vao);
vao->_EnabledWithMapMode =
_mesa_vao_enable_to_vp_inputs(vao->_AttributeMapMode, vao->Enabled);
}
}
@ -1979,6 +1982,9 @@ _mesa_disable_vertex_array_attribs(struct gl_context *ctx,
/* Update the map mode if needed */
if (attrib_bits & (VERT_BIT_POS|VERT_BIT_GENERIC0))
update_attribute_map_mode(ctx, vao);
vao->_EnabledWithMapMode =
_mesa_vao_enable_to_vp_inputs(vao->_AttributeMapMode, vao->Enabled);
}
}

View file

@ -557,7 +557,7 @@ update_vao_inputs(struct gl_context *ctx,
const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
/* Make sure we process only arrays enabled in the VAO */
assert((enable & ~_mesa_get_vao_vp_inputs(vao)) == 0);
assert((enable & ~vao->_EnabledWithMapMode) == 0);
/* Fill in the client arrays from the VAO */
const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0];