diff options
author | bma <[email protected]> | 2013-02-12 08:42:36 +0200 |
---|---|---|
committer | Chad Versace <[email protected]> | 2013-02-13 14:09:47 -0800 |
commit | ce3dfa19ab27871d7eecd5664c1674e467b736bc (patch) | |
tree | 2a66d88fdf8ba81d0cd41a1c76a22c0caa394b33 /src/mesa/main/shaderapi.c | |
parent | 0898047e7b6f81dfe95ecd3b0a6d836c26fef9b3 (diff) |
shaderapi: Fix AttachShader error
Detect a duplicate Shader type as and error instead of silently allowing
it, restrict to ES2 API.
v2: Tapani Pälli <[email protected]>
- make the check run time instead of compile time
v3: chadv
- Quote spec on which error to generate.
Signed-off-by: bma <[email protected]>
Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-and-tested-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r-- | src/mesa/main/shaderapi.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 2590abe7ed4..be69467986d 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -207,6 +207,8 @@ attach_shader(struct gl_context *ctx, GLuint program, GLuint shader) struct gl_shader *sh; GLuint i, n; + const bool same_type_disallowed = _mesa_is_gles(ctx); + shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader"); if (!shProg) return; @@ -227,6 +229,18 @@ attach_shader(struct gl_context *ctx, GLuint program, GLuint shader) */ _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); return; + } else if (same_type_disallowed && + shProg->Shaders[i]->Type == sh->Type) { + /* Shader with the same type is already attached to this program, + * OpenGL ES 2.0 and 3.0 specs say: + * + * "Multiple shader objects of the same type may not be attached + * to a single program object. [...] The error INVALID_OPERATION + * is generated if [...] another shader object of the same type + * as shader is already attached to program." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); + return; } } |