aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-03-22 01:07:54 -0400
committerMarge Bot <[email protected]>2020-04-30 22:01:55 +0000
commit2e3a9d78289ace1928e2dc093fc743cad81c911c (patch)
treea723c2ece5b61ea7744bccecc3176c7180842cec
parent256d5ca80af0b742d4b2bf156180a22b1976fb80 (diff)
mesa: don't update shaders on fixed-func state changes if user shaders are bound
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/state.c27
2 files changed, 28 insertions, 3 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8bfeeaf7cd4..c99d6b97f00 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2290,6 +2290,8 @@ struct gl_vertex_program_state
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
/** Should fixed-function T&L be implemented with a vertex prog? */
GLboolean _MaintainTnlProgram;
+ /** Whether the fixed-func program is being used right now. */
+ GLboolean _UsesTnlProgram;
struct gl_program *Current; /**< User-bound vertex program */
@@ -2363,6 +2365,8 @@ struct gl_fragment_program_state
GLboolean Enabled; /**< User-set fragment program enable flag */
/** Should fixed-function texturing be implemented with a fragment prog? */
GLboolean _MaintainTexEnvProgram;
+ /** Whether the fixed-func program is being used right now. */
+ GLboolean _UsesTexEnvProgram;
struct gl_program *Current; /**< User-bound fragment program */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 88feb16b6ea..2f89cecd8ab 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -363,6 +363,23 @@ update_program_constants(struct gl_context *ctx)
}
+static void
+update_fixed_func_program_usage(struct gl_context *ctx)
+{
+ ctx->FragmentProgram._UsesTexEnvProgram =
+ ctx->FragmentProgram._MaintainTexEnvProgram &&
+ !ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] && /* GLSL*/
+ !_mesa_arb_fragment_program_enabled(ctx) &&
+ !(_mesa_ati_fragment_shader_enabled(ctx) &&
+ ctx->ATIFragmentShader.Current->Program);
+
+ ctx->VertexProgram._UsesTnlProgram =
+ ctx->VertexProgram._MaintainTnlProgram &&
+ !ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] && /* GLSL */
+ !_mesa_arb_vertex_program_enabled(ctx);
+}
+
+
/**
* Compute derived GL state.
* If __struct gl_contextRec::NewState is non-zero then this function \b must
@@ -399,13 +416,17 @@ _mesa_update_state_locked( struct gl_context *ctx )
ctx->API == API_OPENGLES) {
GLbitfield prog_flags = _NEW_PROGRAM;
- /* Determine which state flags effect vertex/fragment program state */
- if (ctx->FragmentProgram._MaintainTexEnvProgram) {
+ if (new_state & _NEW_PROGRAM)
+ update_fixed_func_program_usage(ctx);
+
+ /* Determine which states affect fixed-func vertex/fragment program. */
+ if (ctx->FragmentProgram._UsesTexEnvProgram) {
prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE_OBJECT | _NEW_FOG |
_NEW_VARYING_VP_INPUTS | _NEW_LIGHT | _NEW_POINT |
_NEW_RENDERMODE | _NEW_COLOR | _NEW_TEXTURE_STATE);
}
- if (ctx->VertexProgram._MaintainTnlProgram) {
+
+ if (ctx->VertexProgram._UsesTnlProgram) {
prog_flags |= (_NEW_VARYING_VP_INPUTS | _NEW_TEXTURE_OBJECT |
_NEW_TEXTURE_MATRIX | _NEW_TRANSFORM | _NEW_POINT |
_NEW_FOG | _NEW_LIGHT | _NEW_TEXTURE_STATE |