[Mesa-dev] [PATCH v2] shaderapi: Fix AttachShader error
Tapani Pälli
tapani.palli at intel.com
Mon Feb 11 22:42:36 PST 2013
From: bma <Bo.Ma at windriver.com>
Detect a duplicate Shader type as and error instead of silently allowing
it, restrict to ES2 API.
v2: Tapani Pälli <tapani.palli at intel.com>
- make the check run time instead of compile time
Signed-off-by: bma <Bo.Ma at windriver.com>
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
src/mesa/main/shaderapi.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2590abe..64f7ed3 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,16 @@ 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."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader");
+ return;
}
}
--
1.8.1
More information about the mesa-dev
mailing list