summaryrefslogtreecommitdiff
path: root/src/mesa/vbo/vbo_exec_api.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-04-11 10:14:17 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-04-11 10:14:17 -0600
commitd758479b9fbff803bdac15f3f39d32ef9064db71 (patch)
treeefe60ae9b5c8ad3002d6e860315215def70b35f3 /src/mesa/vbo/vbo_exec_api.c
parent6d0f9d5a01b1104716d9562e0775e6a144dc9f89 (diff)
mesa: Fix glBegin-time test for invalid programs/shaders.
Cherry-picked from master.
Diffstat (limited to 'src/mesa/vbo/vbo_exec_api.c')
-rw-r--r--src/mesa/vbo/vbo_exec_api.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index b7f4d8a307..98580170e3 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -477,6 +477,23 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j )
}
+/**
+ * Check if programs/shaders are enabled and valid at glBegin time.
+ */
+GLboolean
+vbo_validate_shaders(GLcontext *ctx)
+{
+ if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
+ (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
+ return GL_FALSE;
+ }
+ if (ctx->Shader.CurrentProgram && !ctx->Shader.CurrentProgram->LinkStatus) {
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+}
+
+
/* Build a list of primitives on the fly. Keep
* ctx->Driver.CurrentExecPrimitive uptodate as well.
*/
@@ -491,18 +508,16 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
if (ctx->NewState) {
_mesa_update_state( ctx );
- /* XXX also need to check if shader enabled, but invalid */
- if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
- (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBegin (invalid vertex/fragment program)");
- return;
- }
-
CALL_Begin(ctx->Exec, (mode));
return;
}
+ if (!vbo_validate_shaders(ctx)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBegin (invalid vertex/fragment program)");
+ return;
+ }
+
/* Heuristic: attempt to isolate attributes occuring outside
* begin/end pairs.
*/