From c97961a855ad1ae5c58d47634862b459e682e158 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 14 Jul 2023 15:35:05 -0400 Subject: [PATCH] mesa: fix 38% decrease in display list performance of Viewperf2020/NX8_StudioAA It happened because glCallList was restoring varying_vp_inputs, which caused every glCallList to process the state change again. This loosely reverts commit 3a294ff01fb9d1d8b4f984a364ed7ef469624c49 "mesa: move the _mesa_set_varying_vp_inputs call to where the state changes". Fixes: 3a294ff01fb9d1d8b - "mesa: move the _mesa_set_varying_vp_inputs call to where the state changes" Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/draw.c | 47 ++++++++++++++++++++++++++++++-- src/mesa/main/state.c | 3 -- src/mesa/main/varray.c | 6 ---- src/mesa/state_tracker/st_cb_rasterpos.c | 2 ++ src/mesa/vbo/vbo_exec_draw.c | 2 ++ src/mesa/vbo/vbo_save_draw.c | 4 +-- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c index af9e282..8519bd5 100644 --- a/src/mesa/main/draw.c +++ b/src/mesa/main/draw.c @@ -147,7 +147,6 @@ _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 @@ -166,8 +165,6 @@ _mesa_restore_draw_vao(struct gl_context *ctx, /* Restore original states. */ _mesa_update_edgeflag_state_vao(ctx); - _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & - saved->_EnabledWithMapMode); } /** @@ -1395,6 +1392,8 @@ _mesa_DrawArrays(GLenum mode, GLint start, GLsizei count) GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1423,6 +1422,8 @@ _mesa_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1452,6 +1453,8 @@ _mesa_DrawArraysInstancedBaseInstance(GLenum mode, GLint first, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1480,6 +1483,8 @@ _mesa_MultiDrawArrays(GLenum mode, const GLint *first, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1720,6 +1725,8 @@ _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1814,6 +1821,8 @@ _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1837,6 +1846,8 @@ _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1860,6 +1871,8 @@ _mesa_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1886,6 +1899,8 @@ _mesa_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1914,6 +1929,8 @@ _mesa_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1944,6 +1961,8 @@ _mesa_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -1972,6 +1991,8 @@ _mesa_DrawElementsUserBuf(GLintptr indexBuf, GLenum mode, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2139,6 +2160,8 @@ _mesa_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2164,6 +2187,8 @@ _mesa_MultiDrawElementsBaseVertex(GLenum mode, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2193,6 +2218,8 @@ _mesa_MultiDrawElementsUserBuf(GLintptr indexBuf, GLenum mode, GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2225,6 +2252,8 @@ _mesa_draw_transform_feedback(struct gl_context *ctx, GLenum mode, { FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2328,6 +2357,8 @@ _mesa_DrawArraysIndirect(GLenum mode, const GLvoid *indirect) FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2383,6 +2414,8 @@ _mesa_DrawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect) FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2406,6 +2439,8 @@ _mesa_MultiDrawArraysIndirect(GLenum mode, const GLvoid *indirect, FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2475,6 +2510,8 @@ _mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type, FLUSH_FOR_DRAW(ctx); + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2587,6 +2624,8 @@ _mesa_MultiDrawArraysIndirectCountARB(GLenum mode, GLintptr indirect, if (stride == 0) stride = 4 * sizeof(GLuint); /* sizeof(DrawArraysIndirectCommand) */ + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); @@ -2614,6 +2653,8 @@ _mesa_MultiDrawElementsIndirectCountARB(GLenum mode, GLenum type, if (stride == 0) stride = 5 * sizeof(GLuint); /* sizeof(DrawElementsIndirectCommand) */ + _mesa_set_varying_vp_inputs(ctx, ctx->VertexProgram._VPModeInputFilter & + ctx->Array._DrawVAO->_EnabledWithMapMode); if (ctx->NewState) _mesa_update_state(ctx); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 784dafd..736b2ae 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -687,9 +687,6 @@ 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 d09eb08..c3150df 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -2159,9 +2159,6 @@ _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); } } @@ -2265,9 +2262,6 @@ _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 d6ff88f..eff9bd1 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -274,6 +274,8 @@ 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_set_varying_vp_inputs(ctx, VERT_BIT_POS & + ctx->Array._DrawVAO->_EnabledWithMapMode); 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 49dd10b..e1e8ca2 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -151,6 +151,8 @@ 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_set_varying_vp_inputs(ctx, vao_filter & + ctx->Array._DrawVAO->_EnabledWithMapMode); } diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 9663ff1..54591e9 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -207,7 +207,6 @@ vbo_save_playback_vertex_list_gallium(struct gl_context *ctx, * which attribs have stride = 0 and whether edge flags are enabled. */ const GLbitfield enabled = node->enabled_attribs[mode]; - const GLbitfield saved_varying_vp_inputs = ctx->VertexProgram._VaryingInputs; _mesa_set_varying_vp_inputs(ctx, enabled); if (ctx->NewState) @@ -294,7 +293,6 @@ vbo_save_playback_vertex_list_gallium(struct gl_context *ctx, /* Restore edge flag state and ctx->VertexProgram._VaryingInputs. */ _mesa_update_edgeflag_state_vao(ctx); - _mesa_set_varying_vp_inputs(ctx, saved_varying_vp_inputs); if (copy_to_current) playback_copy_to_current(ctx, node); @@ -334,6 +332,8 @@ 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_set_varying_vp_inputs(ctx, vao_filter & + ctx->Array._DrawVAO->_EnabledWithMapMode); /* Need that at least one time. */ if (ctx->NewState) -- 2.7.4