[Mesa-dev] [PATCH 04/11] mesa: Add missing error checks to GetProgramInfoLog, GetShaderInfoLog and GetProgramiv
Eduardo Lima Mitev
elima at igalia.com
Tue Feb 10 07:40:41 PST 2015
Fixes 3 dEQP tests:
* dEQP-GLES3.functional.negative_api.state.get_program_info_log
* dEQP-GLES3.functional.negative_api.state.get_shader_info_log
* dEQP-GLES3.functional.negative_api.state.get_programiv
---
src/mesa/main/shaderapi.c | 84 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 79 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 52eab46..9dc03c0 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -546,7 +546,22 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
|| _mesa_is_gles3(ctx);
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)");
+ /* Section 6.1.12 Shader and Program Queries, page 234 of the
+ * OpenGL ES 3.0.4 spec states:
+ *
+ * "These commands will generate the error INVALID_VALUE if the
+ * provided name is not the name of either a shader or program object,
+ * and INVALID_OPERATION if the provided name identifies an object of
+ * the other type."
+ *
+ * Also, Section 7.13. SHADER, PROGRAM, AND PROGRAM PIPELINE QUERIES,
+ * page 161 of the OpenGL 4.5 spec states:
+ *
+ * "An INVALID_OPERATION error is generated if prgoram is the name of a
+ * shader object."
+ */
+ struct gl_shader *sh = _mesa_lookup_shader(ctx, program);
+ _mesa_error(ctx, sh ? GL_INVALID_OPERATION : GL_INVALID_VALUE, "glGetProgramiv(program)");
return;
}
@@ -764,11 +779,40 @@ static void
get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize,
GLsizei *length, GLchar *infoLog)
{
- struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program);
+ struct gl_shader_program *shProg;
+
+ /* Section 2.5 GL Errors (page 18) of the OpenGL ES 3.0.4 spec and
+ * section 2.3.1 (Errors) of the OpenGL 4.5 spec say:
+ *
+ * "If a negative number is provided where an argument of type sizei or
+ * sizeiptr is specified, an INVALID_VALUE error is generated."
+ */
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(bufSize < 0)");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program(ctx, program);
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)");
+ /* Section 6.1.12 Shader and Program Queries, page 234 of the
+ * OpenGL ES 3.0.4 spec states:
+ *
+ * "These commands will generate the error INVALID_VALUE if the
+ * provided name is not the name of either a shader or program object,
+ * and INVALID_OPERATION if the provided name identifies an object of
+ * the other type."
+ *
+ * Also, Section 7.13. SHADER, PROGRAM, AND PROGRAM PIPELINE QUERIES,
+ * page 161 of the OpenGL 4.5 spec states:
+ *
+ * "An INVALID_OPERATION error is generated if prgoram is the name of a
+ * shader object."
+ */
+ struct gl_shader *sh = _mesa_lookup_shader(ctx, program);
+ _mesa_error(ctx, sh ? GL_INVALID_OPERATION : GL_INVALID_VALUE, "glGetProgramInfoLog(program)");
return;
}
+
_mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog);
}
@@ -777,11 +821,41 @@ static void
get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize,
GLsizei *length, GLchar *infoLog)
{
- struct gl_shader *sh = _mesa_lookup_shader(ctx, shader);
+ struct gl_shader *sh;
+
+ /* Section 2.5 GL Errors (page 18) of the OpenGL ES 3.0.4 spec and
+ * section 2.3.1 (Errors) of the OpenGL 4.5 spec say:
+ *
+ * "If a negative number is provided where an argument of type sizei or
+ * sizeiptr is specified, an INVALID_VALUE error is generated."
+ */
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(bufSize < 0)");
+ return;
+ }
+
+ sh = _mesa_lookup_shader(ctx, shader);
if (!sh) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)");
+ struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, shader);
+ /* Section 6.1.12 Shader and Program Queries, page 234 of the
+ * OpenGL ES 3.0.4 spec states:
+ *
+ * "These commands will generate the error INVALID_VALUE if the
+ * provided name is not the name of either a shader or program object,
+ * and INVALID_OPERATION if the provided name identifies an object of
+ * the other type."
+ *
+ * Also, Section 7.13. SHADER, PROGRAM, AND PROGRAM PIPELINE QUERIES,
+ * page 161 of the OpenGL 4.5 spec states:
+ *
+ * "An INVALID_OPERATION error is generated if shader is the name of a
+ * program object."
+ */
+ _mesa_error(ctx, shProg ? GL_INVALID_OPERATION : GL_INVALID_VALUE,
+ "glGetShaderInfoLog(shader)");
return;
}
+
_mesa_copy_string(infoLog, bufSize, length, sh->InfoLog);
}
--
2.1.3
More information about the mesa-dev
mailing list