summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/shader_api.c56
1 files changed, 36 insertions, 20 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index c77d0c4397..eea44eb92a 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -360,6 +360,22 @@ copy_string(GLchar *dst, GLsizei maxLength, GLsizei *length, const GLchar *src)
}
+static GLboolean
+_mesa_is_program(GLcontext *ctx, GLuint name)
+{
+ struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name);
+ return shProg ? GL_TRUE : GL_FALSE;
+}
+
+
+static GLboolean
+_mesa_is_shader(GLcontext *ctx, GLuint name)
+{
+ struct gl_shader *shader = _mesa_lookup_shader(ctx, name);
+ return shader ? GL_TRUE : GL_FALSE;
+}
+
+
/**
* Called via ctx->Driver.AttachShader()
*/
@@ -372,12 +388,21 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader)
GLuint n;
GLuint i;
- if (!shProg || !sh) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glAttachShader(bad program or shader name)");
+ if (!shProg) {
+ GLenum err = _mesa_is_shader(ctx, program)
+ ? GL_INVALID_OPERATION : GL_INVALID_VALUE;
+ _mesa_error(ctx, err, "glAttachShader(bad program or shader name)");
+ return;
+ }
+
+ if (!sh) {
+ GLenum err = _mesa_is_program(ctx, shader)
+ ? GL_INVALID_OPERATION : GL_INVALID_VALUE;
+ _mesa_error(ctx, err, "glAttachShader(bad program or shader name)");
return;
}
+
n = shProg->NumShaders;
for (i = 0; i < n; i++) {
@@ -445,7 +470,9 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
GLint i, oldIndex;
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(program)");
+ GLenum err = _mesa_is_shader(ctx, program)
+ ? GL_INVALID_OPERATION : GL_INVALID_VALUE;
+ _mesa_error(ctx, err, "glBindAttribLocation(program)");
return;
}
@@ -458,6 +485,11 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
return;
}
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)");
+ return;
+ }
+
if (shProg->LinkStatus) {
/* get current index/location for the attribute */
oldIndex = _mesa_get_attrib_location(ctx, program, name);
@@ -946,22 +978,6 @@ _mesa_get_uniform_location(GLcontext *ctx, GLuint program, const GLchar *name)
}
-static GLboolean
-_mesa_is_program(GLcontext *ctx, GLuint name)
-{
- struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name);
- return shProg ? GL_TRUE : GL_FALSE;
-}
-
-
-static GLboolean
-_mesa_is_shader(GLcontext *ctx, GLuint name)
-{
- struct gl_shader *shader = _mesa_lookup_shader(ctx, name);
- return shader ? GL_TRUE : GL_FALSE;
-}
-
-
/**
* Called via ctx->Driver.ShaderSource()