Be more consistant with paths in #includes. Eventually, eliminate a bunch of -I...
[mesa.git] / src / mesa / shader / shader_api.c
index 74bdef061b583a142db8f1aeda310739f21b5c52..66509d56db12a7bd7347ccfa5d3b99db7075c210 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.0
  *
  * Copyright (C) 2004-2007  Brian Paul   All Rights Reserved.
  *
 #include "prog_parameter.h"
 #include "prog_print.h"
 #include "prog_statevars.h"
-#include "shader_api.h"
-
-#include "slang_compile.h"
-#include "slang_link.h"
+#include "shader/shader_api.h"
+#include "shader/slang/slang_compile.h"
+#include "shader/slang/slang_link.h"
 
 
 
@@ -119,6 +118,11 @@ _mesa_free_shader_program_data(GLcontext *ctx,
 
    _mesa_clear_shader_program_data(ctx, shProg);
 
+   if (shProg->Attributes) {
+      _mesa_free_parameter_list(shProg->Attributes);
+      shProg->Attributes = NULL;
+   }
+
    /* detach shaders */
    for (i = 0; i < shProg->NumShaders; i++) {
       _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
@@ -638,12 +642,8 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
                          GLsizei maxLength, GLsizei *length, GLint *size,
                          GLenum *type, GLchar *nameOut)
 {
-   static const GLenum vec_types[] = {
-      GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4
-   };
    struct gl_shader_program *shProg
       = _mesa_lookup_shader_program(ctx, program);
-   GLint sz;
    GLuint ind, j;
 
    if (!shProg) {
@@ -664,11 +664,10 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
             /* found it */
             copy_string(nameOut, maxLength, length,
                         shProg->Uniforms->Parameters[j].Name);
-            sz = shProg->Uniforms->Parameters[j].Size;
             if (size)
-               *size = sz;
+               *size = shProg->Uniforms->Parameters[j].Size;
             if (type)
-               *type = vec_types[sz-1]; /* XXX this is a temporary hack */
+               *type = shProg->Uniforms->Parameters[j].DataType;
             return;
          }
          ind++;
@@ -1072,12 +1071,20 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
     * If we're setting a sampler, we must use glUniformi1()!
     */
    if (shProg->Uniforms->Parameters[location].Type == PROGRAM_SAMPLER) {
+      GLint unit;
       if (type != GL_INT || count != 1) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glUniform(only glUniform1i can be used "
                      "to set sampler uniforms)");
          return;
       }
+      /* check that the sampler (tex unit index) is legal */
+      unit = ((GLint *) values)[0];
+      if (unit >= ctx->Const.MaxTextureImageUnits) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glUniform1(invalid sampler/tex unit index)");
+         return;
+      }
    }
 
    if (count < 0) {