[Mesa-dev] [PATCH 1/7] mesa: create use_program_stages() helper
Timothy Arceri
tarceri at itsqueeze.com
Thu May 4 01:19:48 UTC 2017
This will be used to create a KHR_no_error version of
glUseProgramStages().
---
src/mesa/main/pipelineobj.c | 71 +++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index dbca3c3..047c0a3 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -211,20 +211,58 @@ use_program_stage(struct gl_context *ctx, GLenum type,
struct gl_shader_program *shProg,
struct gl_pipeline_object *pipe) {
gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type);
struct gl_program *prog = NULL;
if (shProg && shProg->_LinkedShaders[stage])
prog = shProg->_LinkedShaders[stage]->Program;
_mesa_use_program(ctx, stage, shProg, prog, pipe);
}
+static void
+use_program_stages(struct gl_context *ctx, struct gl_shader_program *shProg,
+ GLbitfield stages, struct gl_pipeline_object *pipe) {
+
+ /* 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
+ * as dictated by the spec.
+ *
+ * Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
+ * says:
+ *
+ * "If UseProgramStages is called with program set to zero or with a
+ * program object that contains no executable code for the given
+ * stages, it is as if the pipeline object has no programmable stage
+ * configured for the indicated shader stages."
+ */
+ if ((stages & GL_VERTEX_SHADER_BIT) != 0)
+ use_program_stage(ctx, GL_VERTEX_SHADER, shProg, pipe);
+
+ if ((stages & GL_FRAGMENT_SHADER_BIT) != 0)
+ use_program_stage(ctx, GL_FRAGMENT_SHADER, shProg, pipe);
+
+ if ((stages & GL_GEOMETRY_SHADER_BIT) != 0)
+ use_program_stage(ctx, GL_GEOMETRY_SHADER, shProg, pipe);
+
+ if ((stages & GL_TESS_CONTROL_SHADER_BIT) != 0)
+ use_program_stage(ctx, GL_TESS_CONTROL_SHADER, shProg, pipe);
+
+ if ((stages & GL_TESS_EVALUATION_SHADER_BIT) != 0)
+ use_program_stage(ctx, GL_TESS_EVALUATION_SHADER, shProg, pipe);
+
+ if ((stages & GL_COMPUTE_SHADER_BIT) != 0)
+ use_program_stage(ctx, GL_COMPUTE_SHADER, shProg, pipe);
+
+ pipe->Validated = false;
+}
+
/**
* Bound program to severals stages of the pipeline
*/
void GLAPIENTRY
_mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_pipeline_object *pipe = _mesa_lookup_pipeline_object(ctx, pipeline);
struct gl_shader_program *shProg = NULL;
@@ -304,52 +342,21 @@ _mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
}
if (!shProg->SeparateShader) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glUseProgramStages(program wasn't linked with the "
"PROGRAM_SEPARABLE flag)");
return;
}
}
- /* 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
- * as dictated by the spec.
- *
- * Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
- * says:
- *
- * "If UseProgramStages is called with program set to zero or with a
- * program object that contains no executable code for the given
- * stages, it is as if the pipeline object has no programmable stage
- * configured for the indicated shader stages."
- */
- if ((stages & GL_VERTEX_SHADER_BIT) != 0)
- use_program_stage(ctx, GL_VERTEX_SHADER, shProg, pipe);
-
- if ((stages & GL_FRAGMENT_SHADER_BIT) != 0)
- use_program_stage(ctx, GL_FRAGMENT_SHADER, shProg, pipe);
-
- if ((stages & GL_GEOMETRY_SHADER_BIT) != 0)
- use_program_stage(ctx, GL_GEOMETRY_SHADER, shProg, pipe);
-
- if ((stages & GL_TESS_CONTROL_SHADER_BIT) != 0)
- use_program_stage(ctx, GL_TESS_CONTROL_SHADER, shProg, pipe);
-
- if ((stages & GL_TESS_EVALUATION_SHADER_BIT) != 0)
- use_program_stage(ctx, GL_TESS_EVALUATION_SHADER, shProg, pipe);
-
- if ((stages & GL_COMPUTE_SHADER_BIT) != 0)
- use_program_stage(ctx, GL_COMPUTE_SHADER, shProg, pipe);
-
- pipe->Validated = false;
+ use_program_stages(ctx, shProg, stages, pipe);
}
/**
* Use the named shader program for subsequent glUniform calls (if pipeline
* bound)
*/
void GLAPIENTRY
_mesa_ActiveShaderProgram(GLuint pipeline, GLuint program)
{
GET_CURRENT_CONTEXT(ctx);
--
2.9.3
More information about the mesa-dev
mailing list