summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c22
-rw-r--r--src/mesa/main/mtypes.h9
-rw-r--r--src/mesa/main/shaderobj.c8
3 files changed, 20 insertions, 19 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 10166ae5a2b..1625e4c5019 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1702,10 +1702,10 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
_mesa_update_state(ctx);
if (ctx->Shader.CurrentProgram) {
- unsigned i;
+ struct gl_shader_program *const prog = ctx->Shader.CurrentProgram;
/* using shaders */
- if (!ctx->Shader.CurrentProgram->LinkStatus) {
+ if (!prog->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(shader not linked)", where);
return GL_FALSE;
@@ -1713,10 +1713,9 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#if 0 /* not normally enabled */
{
char errMsg[100];
- if (!_mesa_validate_shader_program(ctx, ctx->Shader.CurrentProgram,
- errMsg)) {
+ if (!_mesa_validate_shader_program(ctx, prog, errMsg)) {
_mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentProgram->Name, errMsg);
+ prog->Name, errMsg);
}
}
#endif
@@ -1725,13 +1724,12 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
* any stages that are not provided, the corresponding assembly shader
* target will be validated below.
*/
- for (i = 0; i < ctx->Shader.CurrentProgram->_NumLinkedShaders; i++) {
- switch (ctx->Shader.CurrentProgram->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER: vert_from_glsl_shader = true; break;
- case GL_GEOMETRY_SHADER_ARB: geom_from_glsl_shader = true; break;
- case GL_FRAGMENT_SHADER: frag_from_glsl_shader = true; break;
- }
- }
+ vert_from_glsl_shader =
+ prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL;
+ geom_from_glsl_shader =
+ prog->_LinkedShaders[MESA_SHADER_GEOMETRY] != NULL;
+ frag_from_glsl_shader =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6702032679b..13aa66fc1e8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2117,11 +2117,12 @@ struct gl_shader_program
/**
* Per-stage shaders resulting from the first stage of linking.
+ *
+ * Set of linked shaders for this program. The array is accessed using the
+ * \c MESA_SHADER_* defines. Entries for non-existent stages will be
+ * \c NULL.
*/
- /*@{*/
- GLuint _NumLinkedShaders;
- struct gl_shader *_LinkedShaders[2];
- /*@}*/
+ struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES];
};
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index e0ffa2f289d..b6594cbe6f0 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -326,10 +326,12 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
shProg->TransformFeedback.NumVarying = 0;
- for (i = 0; i < shProg->_NumLinkedShaders; i++) {
- ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[i]);
+ for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (shProg->_LinkedShaders[i] != NULL) {
+ ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[i]);
+ shProg->_LinkedShaders[i] = NULL;
+ }
}
- shProg->_NumLinkedShaders = 0;
}