summaryrefslogtreecommitdiff
path: root/src/mesa/main/uniforms.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/uniforms.c')
-rw-r--r--src/mesa/main/uniforms.c73
1 files changed, 59 insertions, 14 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index d61856d0eb..1d74efafdf 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -39,6 +39,8 @@
#include "main/glheader.h"
#include "main/context.h"
#include "main/dispatch.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "main/uniforms.h"
@@ -207,6 +209,18 @@ static struct gl_builtin_uniform_element gl_NormalScale_elements[] = {
{NULL, {STATE_NORMAL_SCALE}, SWIZZLE_XXXX},
};
+static struct gl_builtin_uniform_element gl_MESABumpRotMatrix0_elements[] = {
+ {NULL, {STATE_INTERNAL, STATE_ROT_MATRIX_0}, SWIZZLE_XYZW},
+};
+
+static struct gl_builtin_uniform_element gl_MESABumpRotMatrix1_elements[] = {
+ {NULL, {STATE_INTERNAL, STATE_ROT_MATRIX_1}, SWIZZLE_XYZW},
+};
+
+static struct gl_builtin_uniform_element gl_MESAFogParamsOptimized_elements[] = {
+ {NULL, {STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED}, SWIZZLE_XYZW},
+};
+
#define MATRIX(name, statevar, modifier) \
static struct gl_builtin_uniform_element name ## _elements[] = { \
{ NULL, { statevar, 0, 0, 0, modifier}, SWIZZLE_XYZW }, \
@@ -310,6 +324,10 @@ const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = {
STATEVAR(gl_NormalMatrix),
STATEVAR(gl_NormalScale),
+ STATEVAR(gl_MESABumpRotMatrix0),
+ STATEVAR(gl_MESABumpRotMatrix1),
+ STATEVAR(gl_MESAFogParamsOptimized),
+
{NULL, NULL, 0}
};
@@ -448,6 +466,36 @@ _mesa_get_active_uniform(struct gl_context *ctx, GLuint program, GLuint index,
}
+static unsigned
+get_vector_elements(GLenum type)
+{
+ switch (type) {
+ case GL_FLOAT:
+ case GL_INT:
+ case GL_BOOL:
+ case GL_UNSIGNED_INT:
+ default: /* Catch all the various sampler types. */
+ return 1;
+
+ case GL_FLOAT_VEC2:
+ case GL_INT_VEC2:
+ case GL_BOOL_VEC2:
+ case GL_UNSIGNED_INT_VEC2:
+ return 2;
+
+ case GL_FLOAT_VEC3:
+ case GL_INT_VEC3:
+ case GL_BOOL_VEC3:
+ case GL_UNSIGNED_INT_VEC3:
+ return 3;
+
+ case GL_FLOAT_VEC4:
+ case GL_INT_VEC4:
+ case GL_BOOL_VEC4:
+ case GL_UNSIGNED_INT_VEC4:
+ return 4;
+ }
+}
static void
get_matrix_dims(GLenum type, GLint *rows, GLint *cols)
@@ -506,17 +554,8 @@ 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 */
- 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;
- }
+ *rows = 1;
+ *cols = get_vector_elements(p->DataType);
}
}
@@ -640,8 +679,10 @@ _mesa_get_uniformfv(struct gl_context *ctx, GLuint program, GLint location,
k = 0;
for (i = 0; i < rows; i++) {
+ const int base = paramPos + offset + i;
+
for (j = 0; j < cols; j++ ) {
- params[k++] = prog->Parameters->ParameterValues[paramPos+i][j];
+ params[k++] = prog->Parameters->ParameterValues[base][j];
}
}
}
@@ -673,8 +714,10 @@ _mesa_get_uniformiv(struct gl_context *ctx, GLuint program, GLint location,
k = 0;
for (i = 0; i < rows; i++) {
+ const int base = paramPos + offset + i;
+
for (j = 0; j < cols; j++ ) {
- params[k++] = (GLint) prog->Parameters->ParameterValues[paramPos+i][j];
+ params[k++] = (GLint) prog->Parameters->ParameterValues[base][j];
}
}
}
@@ -707,8 +750,10 @@ _mesa_get_uniformuiv(struct gl_context *ctx, GLuint program, GLint location,
k = 0;
for (i = 0; i < rows; i++) {
+ const int base = paramPos + offset + i;
+
for (j = 0; j < cols; j++ ) {
- params[k++] = (GLuint) prog->Parameters->ParameterValues[paramPos+i][j];
+ params[k++] = (GLuint) prog->Parameters->ParameterValues[base][j];
}
}
}