mesa: don't flag _NEW_PROGRAM_CONSTANTS for GLSL programs for st/mesa
authorMarek Olšák <marek.olsak@amd.com>
Sat, 10 Jun 2017 15:22:09 +0000 (17:22 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
v2: also update _mesa_uniform_handle for bindless textures

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (v1)
Reviewed-by: Brian Paul <brianp@vmware.com> (v1)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (v1)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/mesa/main/shaderapi.c
src/mesa/main/uniform_query.cpp
src/mesa/main/uniforms.h
src/mesa/state_tracker/st_context.c

index 9f0122ad704ba5ae8678128b3909f81195fd5849..5a7124043bb656bd19bd8244fc950b0e8e6a9c83 100644 (file)
@@ -2586,6 +2586,7 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
    }
 
    i = 0;
+   bool flushed = false;
    do {
       struct gl_uniform_storage *uni = p->sh.SubroutineUniformRemapTable[i];
       if (uni == NULL) {
@@ -2593,6 +2594,11 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
          continue;
       }
 
+      if (!flushed) {
+         _mesa_flush_vertices_for_uniforms(ctx, uni);
+         flushed = true;
+      }
+
       int uni_count = uni->array_elements ? uni->array_elements : 1;
       int j, k, f;
 
@@ -2625,8 +2631,6 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
       }
       i += uni_count;
    } while(i < count);
-
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 }
 
 
index 37c130ac310ff3870527c49f75183798be6d225f..5eb0efc3268ca504642271ed60059e5dee865f89 100644 (file)
@@ -1002,6 +1002,23 @@ validate_uniform(GLint location, GLsizei count, const GLvoid *values,
    return uni;
 }
 
+void
+_mesa_flush_vertices_for_uniforms(struct gl_context *ctx,
+                                  const struct gl_uniform_storage *uni)
+{
+   uint64_t new_driver_state = 0;
+   unsigned mask = uni->active_shader_mask;
+
+   while (mask) {
+      unsigned index = u_bit_scan(&mask);
+
+      assert(index < MESA_SHADER_STAGES);
+      new_driver_state |= ctx->DriverFlags.NewShaderConstants[index];
+   }
+
+   FLUSH_VERTICES(ctx, new_driver_state ? 0 : _NEW_PROGRAM_CONSTANTS);
+   ctx->NewDriverState |= new_driver_state;
+}
 
 /**
  * Called via glUniform*() functions.
@@ -1056,7 +1073,7 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
       count = MIN2(count, (int) (uni->array_elements - offset));
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
+   _mesa_flush_vertices_for_uniforms(ctx, uni);
 
    /* Store the data in the "actual type" backing storage for the uniform.
     */
@@ -1272,7 +1289,7 @@ _mesa_uniform_matrix(GLint location, GLsizei count,
       count = MIN2(count, (int) (uni->array_elements - offset));
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
+   _mesa_flush_vertices_for_uniforms(ctx, uni);
 
    /* Store the data in the "actual type" backing storage for the uniform.
     */
@@ -1426,7 +1443,7 @@ _mesa_uniform_handle(GLint location, GLsizei count, const GLvoid *values,
       count = MIN2(count, (int) (uni->array_elements - offset));
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
+   _mesa_flush_vertices_for_uniforms(ctx, uni);
 
    /* Store the data in the "actual type" backing storage for the uniform.
     */
index bd42b4f03605cc4976db9778681d96234984e67a..ebeaf9deb1db04859bcd029f367447b2da805ecf 100644 (file)
@@ -486,6 +486,10 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
 extern bool
 _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *);
 
+extern void
+_mesa_flush_vertices_for_uniforms(struct gl_context *ctx,
+                                  const struct gl_uniform_storage *uni);
+
 struct gl_builtin_uniform_element {
    const char *field;
    int tokens[STATE_LENGTH];
index f74f391234309061656bded30c94d01ed8e0bb5a..18f202632a8912d9a1be96bd29991505f71fd157 100644 (file)
@@ -243,9 +243,6 @@ st_invalidate_state(struct gl_context * ctx)
          st->dirty |= ST_NEW_FS_STATE;
       }
    }
-
-   if (new_state & _NEW_PROGRAM_CONSTANTS)
-      st->dirty |= st->active_states & ST_NEW_CONSTANTS;
 }