[Mesa-dev] [PATCH 2/3] mesa: build up a mask of active shader stages in a pipeline

Tapani Pälli tapani.palli at intel.com
Mon Dec 7 01:29:50 PST 2015


This will be used for validating SSO pipeline where all active stages
in linked programs should be in use when rendering.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/mesa/main/mtypes.h      |  2 ++
 src/mesa/main/pipelineobj.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fa7ead0..d5a22c9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2824,6 +2824,8 @@ struct gl_pipeline_object
    GLboolean Validated;                 /**< Pipeline Validation status */
 
    GLchar *InfoLog;
+
+   uint8_t ActiveStages;                /**< Stages used, (glUseProgramStages) */
 };
 
 /**
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 6710d0d..c510ee8 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -218,6 +218,43 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx,
    }
 }
 
+static GLenum
+shader_bit_from_shader_stage(gl_shader_stage stage)
+{
+   switch (stage) {
+   case MESA_SHADER_VERTEX:
+      return GL_VERTEX_SHADER_BIT;
+   case MESA_SHADER_FRAGMENT:
+      return GL_FRAGMENT_SHADER_BIT;
+   case MESA_SHADER_GEOMETRY:
+      return GL_GEOMETRY_SHADER_BIT;
+   case MESA_SHADER_TESS_CTRL:
+      return GL_TESS_CONTROL_SHADER_BIT;
+   case MESA_SHADER_TESS_EVAL:
+      return GL_TESS_EVALUATION_SHADER_BIT;
+   case MESA_SHADER_COMPUTE:
+      return GL_COMPUTE_SHADER_BIT;
+   default:
+      unreachable("bad value in _mesa_shader_bit_from_shader_stage()");
+   }
+}
+
+static void
+update_active_pipeline_stages(struct gl_pipeline_object *pipe,
+                              struct gl_shader_program *shProg,
+                              GLbitfield stages)
+{
+   unsigned i;
+   for (i = 0; i < MESA_SHADER_STAGES; i++) {
+      if ((stages & shader_bit_from_shader_stage(i)) != 0) {
+         if (shProg && shProg->ActiveStages & (1 << i))
+            pipe->ActiveStages |= (1 << i);
+         else
+            pipe->ActiveStages &= ~(1 << i);
+      }
+   }
+}
+
 /**
  * Bound program to severals stages of the pipeline
  */
@@ -311,6 +348,8 @@ _mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
       }
    }
 
+   update_active_pipeline_stages(pipe, shProg, stages);
+
    /* Enable individual stages from the program as requested by the
     * application.  If there is no shader for a requested stage in the
     * program, _mesa_use_shader_program will enable fixed-function processing
-- 
2.5.0



More information about the mesa-dev mailing list