Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / mesa / shader / shader_api.c
index b3d66c5babd882c4bed4e17a8a445f6a7afb8900..122688826cd437fb397c32be4f21a1c06232bb65 100644 (file)
@@ -381,7 +381,7 @@ _mesa_init_shader_state(GLcontext * ctx)
     * are generated by the GLSL compiler.
     */
    ctx->Shader.EmitHighLevelInstructions = GL_TRUE;
-   ctx->Shader.EmitCondCodes = GL_TRUE; /* XXX probably want GL_FALSE... */
+   ctx->Shader.EmitCondCodes = GL_FALSE;/*GL_TRUE;*/ /* XXX probably want GL_FALSE... */
    ctx->Shader.EmitComments = GL_FALSE;
 }
 
@@ -1117,7 +1117,8 @@ get_matrix_dims(GLenum type, GLint *rows, GLint *cols)
 
 /**
  * Determine the number of rows and columns occupied by a uniform
- * according to its datatype.
+ * according to its datatype.  For non-matrix types (such as GL_FLOAT_VEC4),
+ * the number of rows = 1 and cols = number of elements in the vector.
  */
 static void
 get_uniform_rows_cols(const struct gl_program_parameter *p,
@@ -1126,11 +1127,17 @@ get_uniform_rows_cols(const struct gl_program_parameter *p,
    get_matrix_dims(p->DataType, rows, cols);
    if (*rows == 0 && *cols == 0) {
       /* not a matrix type, probably a float or vector */
-      *rows = p->Size / 4 + 1;
-      if (p->Size % 4 == 0)
-         *cols = 4;
-      else
-         *cols = p->Size % 4;
+      if (p->Size <= 4) {
+         *rows = 1;
+         *cols = p->Size;
+      }
+      else {
+         *rows = p->Size / 4 + 1;
+         if (p->Size % 4 == 0)
+            *cols = 4;
+         else
+            *cols = p->Size % 4;
+      }
    }
 }
 
@@ -1527,7 +1534,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
       return;
    }
 
-   if (index + offset > program->Parameters->Size) {
+   if (index + offset > (GLint) program->Parameters->Size) {
       /* out of bounds! */
       return;
    }
@@ -1592,7 +1599,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
          /* if the uniform is bool-valued, convert to 1.0 or 0.0 */
          if (is_boolean_type(param->DataType)) {
             for (i = 0; i < elems; i++) {
-               uniformVal[i] = uniformVal[i] ? 1.0 : 0.0;
+               uniformVal[i] = uniformVal[i] ? 1.0f : 0.0f;
             }
          }
       }