mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 10:50:10 +01:00
vbo: don't call update_color_material in copy_to_current if it's a no-op
Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8850>
This commit is contained in:
parent
c0a893543d
commit
1e18754200
2 changed files with 14 additions and 10 deletions
|
|
@ -178,6 +178,7 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
|
|||
struct gl_context *ctx = gl_context_from_vbo_exec(exec);
|
||||
struct vbo_context *vbo = vbo_context(ctx);
|
||||
GLbitfield64 enabled = exec->vtx.enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
|
||||
bool color0_changed = false;
|
||||
|
||||
while (enabled) {
|
||||
const int i = u_bit_scan64(&enabled);
|
||||
|
|
@ -206,6 +207,9 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
|
|||
if (memcmp(current, tmp, 4 * sizeof(GLfloat) << dmul_shift) != 0) {
|
||||
memcpy(current, tmp, 4 * sizeof(GLfloat) << dmul_shift);
|
||||
|
||||
if (i == VBO_ATTRIB_COLOR0)
|
||||
color0_changed = true;
|
||||
|
||||
if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT) {
|
||||
ctx->NewState |= _NEW_MATERIAL;
|
||||
ctx->PopAttribState |= GL_LIGHTING_BIT;
|
||||
|
|
@ -234,10 +238,7 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
|
|||
}
|
||||
}
|
||||
|
||||
/* Colormaterial -- this kindof sucks.
|
||||
*/
|
||||
if (ctx->Light.ColorMaterialEnabled &&
|
||||
exec->vtx.attr[VBO_ATTRIB_COLOR0].size) {
|
||||
if (color0_changed && ctx->Light.ColorMaterialEnabled) {
|
||||
_mesa_update_color_material(ctx,
|
||||
ctx->Current.Attrib[VBO_ATTRIB_COLOR0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
static void
|
||||
copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
|
||||
GLbitfield mask, GLbitfield state, GLbitfield pop_state,
|
||||
int shift, fi_type **data)
|
||||
int shift, fi_type **data, bool *color0_changed)
|
||||
{
|
||||
struct vbo_context *vbo = vbo_context(ctx);
|
||||
|
||||
|
|
@ -71,6 +71,9 @@ copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
|
|||
if (memcmp(currval->Ptr, tmp, 4 * sizeof(GLfloat) << dmul_shift) != 0) {
|
||||
memcpy((fi_type*)currval->Ptr, tmp, 4 * sizeof(GLfloat) << dmul_shift);
|
||||
|
||||
if (current_index == VBO_ATTRIB_COLOR0)
|
||||
*color0_changed = true;
|
||||
|
||||
/* The fixed-func vertex program uses this. */
|
||||
if (current_index == VBO_ATTRIB_MAT_FRONT_SHININESS ||
|
||||
current_index == VBO_ATTRIB_MAT_BACK_SHININESS)
|
||||
|
|
@ -100,18 +103,18 @@ playback_copy_to_current(struct gl_context *ctx,
|
|||
return;
|
||||
|
||||
fi_type *data = node->current_data;
|
||||
bool color0_changed = false;
|
||||
|
||||
/* Copy conventional attribs and generics except pos */
|
||||
copy_vao(ctx, node->VAO[VP_MODE_SHADER], ~VERT_BIT_POS & VERT_BIT_ALL,
|
||||
_NEW_CURRENT_ATTRIB, GL_CURRENT_BIT, 0, &data);
|
||||
_NEW_CURRENT_ATTRIB, GL_CURRENT_BIT, 0, &data, &color0_changed);
|
||||
/* Copy materials */
|
||||
copy_vao(ctx, node->VAO[VP_MODE_FF], VERT_BIT_MAT_ALL,
|
||||
_NEW_CURRENT_ATTRIB | _NEW_MATERIAL,
|
||||
GL_CURRENT_BIT | GL_LIGHTING_BIT,
|
||||
VBO_MATERIAL_SHIFT, &data);
|
||||
VBO_MATERIAL_SHIFT, &data, &color0_changed);
|
||||
|
||||
/* Colormaterial -- this kindof sucks.
|
||||
*/
|
||||
if (ctx->Light.ColorMaterialEnabled) {
|
||||
if (color0_changed && ctx->Light.ColorMaterialEnabled) {
|
||||
_mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue