mesa: Avoid setting _NEW_VARYING_VP_INPUTS in non fixed function mode.
authorMathias Fröhlich <mathias.froehlich@web.de>
Sun, 12 May 2019 08:35:52 +0000 (10:35 +0200)
committerMathias Fröhlich <Mathias.Froehlich@gmx.net>
Tue, 14 May 2019 16:09:49 +0000 (18:09 +0200)
Instead of checking the API variant on entry of set_varying_vp_inputs
to check if we can ever be interrested in fixed function processing
or not, we can check if we are actually fixed function processing.
To check this we can use the immediately updated
gl_context::VertexProgram._VPMode value that tells us if we have a
user provided shader program or if we are in fixed function processing
either through an internal TNL shader of directly through hardware.
When doing so, we also need to recheck the varying_vp_inputs variable
at the time gl_context::VertexProgram._VPMode is set to VP_MODE_FF.
Put asserts at the consumers of gl_context::varying_vp_inputs to make
sure gl_context::VertexProgram._VPMode is set to VP_MODE_FF. By that
gl_context::varying_vp_inputs should be up to date then.

By not looking at the opengl api for this decision we should actually
catch more cases where we can avoid setting a state change flag, including
the ones where we cannot get into VP_MODE_FF by the choice of the api.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/main/ff_fragment_shader.cpp
src/mesa/main/ffvertex_prog.c
src/mesa/main/state.c

index 935a21624af7ed93521b98da9f6b518f32cf5204..8f2b4e9de4818e35225bf2ac19229daf083297d2 100644 (file)
@@ -181,6 +181,8 @@ static GLbitfield filter_fp_input_mask( GLbitfield fp_inputs,
 
       /* _NEW_VARYING_VP_INPUTS */
       GLbitfield varying_inputs = ctx->varying_vp_inputs;
 
       /* _NEW_VARYING_VP_INPUTS */
       GLbitfield varying_inputs = ctx->varying_vp_inputs;
+      /* We only update ctx->varying_vp_inputs when in VP_MODE_FF _VPMode */
+      assert(VP_MODE_FF == ctx->VertexProgram._VPMode);
 
       /* These get generated in the setup routine regardless of the
        * vertex program:
 
       /* These get generated in the setup routine regardless of the
        * vertex program:
index dfb494bd8c186a4fdcbc82ff8c58d19cafd7918f..04126fe9b9034bb5f1e133e98efd4353ab93c736 100644 (file)
@@ -1650,6 +1650,9 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
    struct gl_program *prog;
    struct state_key key;
 
    struct gl_program *prog;
    struct state_key key;
 
+   /* We only update ctx->varying_vp_inputs when in VP_MODE_FF _VPMode */
+   assert(VP_MODE_FF == ctx->VertexProgram._VPMode);
+
    /* Grab all the relevant state and put it in a single structure:
     */
    make_state_key(ctx, &key);
    /* Grab all the relevant state and put it in a single structure:
     */
    make_state_key(ctx, &key);
index 3ca6f58c6a645faf2096f991b4679264969ce928..9d8964952cd39a31333fa4aabd750f6ad1b03b79 100644 (file)
@@ -423,8 +423,11 @@ _mesa_update_state( struct gl_context *ctx )
 static void
 set_varying_vp_inputs(struct gl_context *ctx, GLbitfield varying_inputs)
 {
 static void
 set_varying_vp_inputs(struct gl_context *ctx, GLbitfield varying_inputs)
 {
-   if (ctx->API != API_OPENGL_COMPAT &&
-       ctx->API != API_OPENGLES)
+   /*
+    * The gl_context::varying_vp_inputs value is only used when in
+    * VP_MODE_FF mode.
+    */
+   if (VP_MODE_FF != ctx->VertexProgram._VPMode)
       return;
 
    if (ctx->varying_vp_inputs != varying_inputs) {
       return;
 
    if (ctx->varying_vp_inputs != varying_inputs) {
@@ -471,6 +474,12 @@ set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
 
    /* Finally memorize the value */
    ctx->VertexProgram._VPMode = m;
 
    /* Finally memorize the value */
    ctx->VertexProgram._VPMode = m;
+
+   /* Since we only track the varying inputs while being in fixed function
+    * vertex processing mode, we may need to recheck for the
+    * _NEW_VARYING_VP_INPUTS bit.
+    */
+   set_varying_vp_inputs(ctx, ctx->Array._DrawVAOEnabledAttribs);
 }
 
 
 }