[Mesa-dev] [PATCH v2 1/3] mesa: add a new flag to track program usage in a pipeline

Tapani Pälli tapani.palli at intel.com
Tue Dec 8 01:16:44 PST 2015


Patch adds ValidProgramUse flag to gl_shader_program that can be used
to track if a program is fully utilized by program pipeline. Flag is
set by glUseProgramStages and will be used for pipeline validation by
the next patch.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Suggested-by: Timothy Arceri <timothy.arceri at collabora.com>
---
 src/glsl/linker.cpp         |  1 +
 src/mesa/main/mtypes.h      |  1 +
 src/mesa/main/pipelineobj.c | 27 +++++++++++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ae628cd..7e0af44 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -4062,6 +4062,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    prog->LinkStatus = true; /* All error paths will set this to false */
    prog->Validated = false;
    prog->_Used = false;
+   prog->ValidProgramUse = false;
 
    prog->ARB_fragment_coord_conventions_enable = false;
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1eb1e21..770055f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2746,6 +2746,7 @@ struct gl_shader_program
    GLboolean Validated;
    GLboolean _Used;        /**< Ever used for drawing? */
    GLboolean SamplersValidated; /**< Samplers validated against texture units? */
+   GLboolean ValidProgramUse; /**< SSO, is every stage used by the pipeline? */
    GLchar *InfoLog;
 
    unsigned Version;       /**< GLSL version used for linking */
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 5eda4e5..f4ce3ed 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -219,6 +219,31 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx,
 }
 
 /**
+ * Raise a flag if shader programs in pipeline contain
+ * stages that are not used. This is used by validation later.
+ */
+static void
+update_program_usage(struct gl_pipeline_object *pipe)
+{
+   unsigned i, j;
+   for (i = 0; i < MESA_SHADER_STAGES; i++) {
+      struct gl_shader_program *shProg = pipe->CurrentProgram[i];
+      if (!shProg)
+         continue;
+      shProg->ValidProgramUse = true;
+      for (j = 0; j < MESA_SHADER_STAGES; j++) {
+         if (!shProg->_LinkedShaders[j])
+            continue;
+         /* Make sure that any shader stage is also used in the pipeline. */
+         if (shProg != pipe->CurrentProgram[j]) {
+            shProg->ValidProgramUse = false;
+            return;
+         }
+      }
+   }
+}
+
+/**
  * Bound program to severals stages of the pipeline
  */
 void GLAPIENTRY
@@ -341,6 +366,8 @@ _mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
 
    if ((stages & GL_COMPUTE_SHADER_BIT) != 0)
       _mesa_use_shader_program(ctx, GL_COMPUTE_SHADER, shProg, pipe);
+
+   update_program_usage(pipe);
 }
 
 /**
-- 
2.5.0



More information about the mesa-dev mailing list