From 3a294ff01fb9d1d8b4f984a364ed7ef469624c49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 23 Nov 2022 05:08:07 -0500 Subject: [PATCH] mesa: move the _mesa_set_varying_vp_inputs call to where the state changes This removes the _mesa_update_vao_state() call from all glDraw* functions where it was executed unconditionally. Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/context.c | 2 +- src/mesa/main/draw.c | 57 +++----------------------------- src/mesa/main/draw.h | 3 -- src/mesa/main/state.c | 3 ++ src/mesa/main/varray.c | 6 ++++ src/mesa/state_tracker/st_cb_rasterpos.c | 1 - src/mesa/vbo/vbo_exec_draw.c | 1 - src/mesa/vbo/vbo_save_draw.c | 1 - 8 files changed, 15 insertions(+), 59 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b418b3c9..b61c237 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -688,6 +688,7 @@ init_attrib_groups(struct gl_context *ctx) _mesa_init_pixelstore( ctx ); _mesa_init_point( ctx ); _mesa_init_polygon( ctx ); + _mesa_init_varray( ctx ); /* should be before _mesa_init_program */ _mesa_init_program( ctx ); _mesa_init_queryobj( ctx ); _mesa_init_sync( ctx ); @@ -697,7 +698,6 @@ init_attrib_groups(struct gl_context *ctx) _mesa_init_stencil( ctx ); _mesa_init_transform( ctx ); _mesa_init_transform_feedback( ctx ); - _mesa_init_varray( ctx ); _mesa_init_viewport( ctx ); _mesa_init_resident_handles( ctx ); diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c index 9f264b7..29db6ea 100644 --- a/src/mesa/main/draw.c +++ b/src/mesa/main/draw.c @@ -146,6 +146,7 @@ _mesa_save_and_set_draw_vao(struct gl_context *ctx, ctx->Array._DrawVAO = NULL; ctx->VertexProgram._VPModeInputFilter = vp_input_filter; _mesa_set_draw_vao(ctx, vao); + _mesa_set_varying_vp_inputs(ctx, vp_input_filter & vao->_EnabledWithMapMode); } void @@ -162,21 +163,13 @@ _mesa_restore_draw_vao(struct gl_context *ctx, _mesa_update_edgeflag_state_vao(ctx); ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS; ctx->Array.NewVertexElements = true; -} -/** - * Update derived VAO state. This determines whether to update gallium vertex - * buffers and vertex elements, and it sets which vertex attribs are enabled - * according to the filter. - */ -void -_mesa_update_vao_state(struct gl_context *ctx, GLbitfield filter) -{ - struct gl_vertex_array_object *vao = ctx->Array._DrawVAO; - _mesa_set_varying_vp_inputs(ctx, filter & vao->_EnabledWithMapMode); + /* Restore original states. */ + _mesa_update_edgeflag_state_vao(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + saved->_EnabledWithMapMode); } - /** * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), * etc? Also, do additional checking related to transformation feedback. @@ -1401,8 +1394,6 @@ _mesa_DrawArrays(GLenum mode, GLint start, GLsizei count) GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1431,8 +1422,6 @@ _mesa_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1462,8 +1451,6 @@ _mesa_DrawArraysInstancedBaseInstance(GLenum mode, GLint first, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1492,8 +1479,6 @@ _mesa_MultiDrawArrays(GLenum mode, const GLint *first, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1724,8 +1709,6 @@ _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1819,8 +1802,6 @@ _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1843,8 +1824,6 @@ _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1867,8 +1846,6 @@ _mesa_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1894,8 +1871,6 @@ _mesa_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1923,8 +1898,6 @@ _mesa_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -1954,8 +1927,6 @@ _mesa_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2104,8 +2075,6 @@ _mesa_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2129,8 +2098,6 @@ _mesa_MultiDrawElementsBaseVertex(GLenum mode, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2159,8 +2126,6 @@ _mesa_draw_transform_feedback(struct gl_context *ctx, GLenum mode, { FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2264,8 +2229,6 @@ _mesa_DrawArraysIndirect(GLenum mode, const GLvoid *indirect) FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2321,8 +2284,6 @@ _mesa_DrawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect) FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2346,8 +2307,6 @@ _mesa_MultiDrawArraysIndirect(GLenum mode, const GLvoid *indirect, FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2417,8 +2376,6 @@ _mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type, FLUSH_FOR_DRAW(ctx); - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2513,8 +2470,6 @@ _mesa_MultiDrawArraysIndirectCountARB(GLenum mode, GLintptr indirect, if (stride == 0) stride = 4 * sizeof(GLuint); /* sizeof(DrawArraysIndirectCommand) */ - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); @@ -2542,8 +2497,6 @@ _mesa_MultiDrawElementsIndirectCountARB(GLenum mode, GLenum type, if (stride == 0) stride = 5 * sizeof(GLuint); /* sizeof(DrawElementsIndirectCommand) */ - _mesa_update_vao_state(ctx, ctx->VertexProgram._VPModeInputFilter); - if (ctx->NewState) _mesa_update_state(ctx); diff --git a/src/mesa/main/draw.h b/src/mesa/main/draw.h index e55ed8a..a0a1a0d 100644 --- a/src/mesa/main/draw.h +++ b/src/mesa/main/draw.h @@ -96,9 +96,6 @@ _mesa_restore_draw_vao(struct gl_context *ctx, GLbitfield saved_vp_input_filter); void -_mesa_update_vao_state(struct gl_context *ctx, GLbitfield filter); - -void _mesa_bitmap(struct gl_context *ctx, GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap, struct pipe_resource *tex); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 8e06fae..04ae1d1 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -684,6 +684,9 @@ set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m) default: assert(0); } + + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); } diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 1b1eb93..5990b9a 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -2080,6 +2080,9 @@ _mesa_enable_vertex_array_attribs(struct gl_context *ctx, vao->_EnabledWithMapMode = _mesa_vao_enable_to_vp_inputs(vao->_AttributeMapMode, vao->Enabled); + + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + vao->_EnabledWithMapMode); } } @@ -2183,6 +2186,9 @@ _mesa_disable_vertex_array_attribs(struct gl_context *ctx, vao->_EnabledWithMapMode = _mesa_vao_enable_to_vp_inputs(vao->_AttributeMapMode, vao->Enabled); + + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + vao->_EnabledWithMapMode); } } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 90e6d0f..7a6d221 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -274,7 +274,6 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4]) _mesa_save_and_set_draw_vao(ctx, rs->VAO, VERT_BIT_POS, &old_vao, &old_vp_input_filter); - _mesa_update_vao_state(ctx, VERT_BIT_POS); st_feedback_draw_vbo(ctx, &rs->info, 0, &rs->draw, 1); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 81a26df..4b2e767 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -151,7 +151,6 @@ vbo_exec_bind_arrays(struct gl_context *ctx, _mesa_save_and_set_draw_vao(ctx, vao, vao_filter, old_vao, old_vp_input_filter); - _mesa_update_vao_state(ctx, vao_filter); } diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 1d95737..284da5e 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -328,7 +328,6 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data, bool copy_to_c _mesa_save_and_set_draw_vao(ctx, node->cold->VAO[mode], vao_filter, &old_vao, &old_vp_input_filter); - _mesa_update_vao_state(ctx, vao_filter); /* Need that at least one time. */ if (ctx->NewState) -- 2.7.4