summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniforms.c
diff options
context:
space:
mode:
authorBryan Cain <[email protected]>2011-08-04 15:43:34 -0500
committerBryan Cain <[email protected]>2011-08-04 15:43:34 -0500
commit4683529048ee133481b2d8f1cae1685aa1736f9a (patch)
treee02d90f4164e4dc6259000c358d65e6af84a3a31 /src/mesa/main/uniforms.c
parent50073563b2bfe3716b3dc8b1ed2f91381ba24305 (diff)
parent9adcab9cd464d659288e31e6767efb5dee3894ff (diff)
Merge branch 'glsl-to-tgsi'
Conflicts: src/mesa/state_tracker/st_atom_pixeltransfer.c src/mesa/state_tracker/st_program.c
Diffstat (limited to 'src/mesa/main/uniforms.c')
-rw-r--r--src/mesa/main/uniforms.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index dd069a3a4d1..1329af4cd7e 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -429,7 +429,7 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
for (i = 0; i < rows; i++) {
const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) {
- params[k++] = prog->Parameters->ParameterValues[base][j];
+ params[k++] = prog->Parameters->ParameterValues[base][j].f;
}
}
}
@@ -442,7 +442,7 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) {
params[k++] = (GLdouble)
- prog->Parameters->ParameterValues[base][j];
+ prog->Parameters->ParameterValues[base][j].f;
}
}
}
@@ -454,8 +454,9 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
for (i = 0; i < rows; i++) {
const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) {
- params[k++] = (GLint)
- prog->Parameters->ParameterValues[base][j];
+ params[k++] = ctx->Const.GLSLVersion <= 120 ?
+ (GLint) prog->Parameters->ParameterValues[base][j].f :
+ prog->Parameters->ParameterValues[base][j].i;
}
}
}
@@ -467,8 +468,9 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
for (i = 0; i < rows; i++) {
const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) {
- params[k++] = (GLuint)
- prog->Parameters->ParameterValues[base][j];
+ params[k++] = ctx->Const.GLSLVersion <= 120 ?
+ (GLuint) prog->Parameters->ParameterValues[base][j].f :
+ prog->Parameters->ParameterValues[base][j].u;
}
}
}
@@ -670,7 +672,7 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
/* loop over number of samplers to change */
for (i = 0; i < count; i++) {
GLuint sampler = (GLuint)
- program->Parameters->ParameterValues[index + offset + i][0];
+ program->Parameters->ParameterValues[index+offset + i][0].f;
GLuint texUnit = ((GLuint *) values)[i];
/* check that the sampler (tex unit index) is legal */
@@ -735,42 +737,52 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
/* loop over number of array elements */
for (k = 0; k < count; k++) {
- GLfloat *uniformVal;
+ gl_constant_value *uniformVal;
if (offset + k >= slots) {
/* Extra array data is ignored */
break;
}
- /* uniformVal (the destination) is always float[4] */
+ /* uniformVal (the destination) is always gl_constant_value[4] */
uniformVal = program->Parameters->ParameterValues[index + offset + k];
if (basicType == GL_INT) {
- /* convert user's ints to floats */
const GLint *iValues = ((const GLint *) values) + k * elems;
for (i = 0; i < elems; i++) {
- uniformVal[i] = (GLfloat) iValues[i];
+ if (ctx->Const.GLSLVersion <= 120)
+ uniformVal[i].f = (GLfloat) iValues[i];
+ else
+ uniformVal[i].i = iValues[i];
}
}
else if (basicType == GL_UNSIGNED_INT) {
- /* convert user's uints to floats */
const GLuint *iValues = ((const GLuint *) values) + k * elems;
for (i = 0; i < elems; i++) {
- uniformVal[i] = (GLfloat) iValues[i];
+ if (ctx->Const.GLSLVersion <= 120)
+ uniformVal[i].f = (GLfloat)(GLuint) iValues[i];
+ else
+ uniformVal[i].u = iValues[i];
}
}
else {
const GLfloat *fValues = ((const GLfloat *) values) + k * elems;
assert(basicType == GL_FLOAT);
for (i = 0; i < elems; i++) {
- uniformVal[i] = fValues[i];
+ uniformVal[i].f = fValues[i];
}
}
- /* if the uniform is bool-valued, convert to 1.0 or 0.0 */
+ /* if the uniform is bool-valued, convert to 1 or 0 */
if (isUniformBool) {
for (i = 0; i < elems; i++) {
- uniformVal[i] = uniformVal[i] ? 1.0f : 0.0f;
+ if (basicType == GL_FLOAT)
+ uniformVal[i].b = uniformVal[i].f != 0.0f ? 1 : 0;
+ else
+ uniformVal[i].b = uniformVal[i].u ? 1 : 0;
+
+ if (ctx->Const.GLSLVersion <= 120)
+ uniformVal[i].f = uniformVal[i].b ? 1.0f : 0.0f;
}
}
}
@@ -936,7 +948,7 @@ set_program_uniform_matrix(struct gl_context *ctx, struct gl_program *program,
/* Ignore writes beyond the end of (the used part of) an array */
return;
}
- v = program->Parameters->ParameterValues[index + offset];
+ v = (GLfloat *) program->Parameters->ParameterValues[index + offset];
for (row = 0; row < rows; row++) {
if (transpose) {
v[row] = values[src + row * cols + col];