summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-12-20 09:05:37 -0700
committerBrian <[email protected]>2007-12-20 09:06:05 -0700
commit2761cfce462af4fee0d67068c09f7f188677e7cf (patch)
tree9c3ee3ceca31e69e35a2aeaf177cced04817b998 /src
parente54329233522591bbe8aad8a3fd6bcdc1e430f03 (diff)
return correct size from glGetActiveUniform (bug 13751)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/shader_api.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index a1e73ef125c..82c2b857fff 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -369,6 +369,54 @@ copy_string(GLchar *dst, GLsizei maxLength, GLsizei *length, const GLchar *src)
/**
+ * Return size (in floats) of the given GLSL type.
+ * See also _slang_sizeof_type_specifier().
+ */
+static GLint
+sizeof_glsl_type(GLenum type)
+{
+ switch (type) {
+ case GL_BOOL:
+ case GL_FLOAT:
+ case GL_INT:
+ return 1;
+ case GL_BOOL_VEC2:
+ case GL_FLOAT_VEC2:
+ case GL_INT_VEC2:
+ return 2;
+ case GL_BOOL_VEC3:
+ case GL_FLOAT_VEC3:
+ case GL_INT_VEC3:
+ return 3;
+ case GL_BOOL_VEC4:
+ case GL_FLOAT_VEC4:
+ case GL_INT_VEC4:
+ return 4;
+ case GL_FLOAT_MAT2:
+ return 8; /* 2 rows of 4, actually */
+ case GL_FLOAT_MAT3:
+ return 12; /* 3 rows of 4, actually */
+ case GL_FLOAT_MAT4:
+ return 16;
+ case GL_FLOAT_MAT2x3:
+ return 6;
+ case GL_FLOAT_MAT2x4:
+ return 8;
+ case GL_FLOAT_MAT3x2:
+ return 12; /* 3 rows of 4, actually */
+ case GL_FLOAT_MAT3x4:
+ return 12;
+ case GL_FLOAT_MAT4x2:
+ return 16; /* 4 rows of 4, actually */
+ case GL_FLOAT_MAT4x3:
+ return 12;
+ default:
+ return 0; /* error */
+ }
+}
+
+
+/**
* Called via ctx->Driver.AttachShader()
*/
void
@@ -665,13 +713,17 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
if (shProg->Uniforms->Parameters[j].Type == PROGRAM_UNIFORM ||
shProg->Uniforms->Parameters[j].Type == PROGRAM_SAMPLER) {
if (ind == index) {
+ GLuint uSize = shProg->Uniforms->Parameters[j].Size;
+ GLenum uType = shProg->Uniforms->Parameters[j].DataType;
/* found it */
copy_string(nameOut, maxLength, length,
shProg->Uniforms->Parameters[j].Name);
- if (size)
- *size = shProg->Uniforms->Parameters[j].Size;
+ if (size) {
+ /* convert from floats to 'type' (eg: sizeof(mat4x4)=1) */
+ *size = uSize / sizeof_glsl_type(uType);
+ }
if (type)
- *type = shProg->Uniforms->Parameters[j].DataType;
+ *type = uType;
return;
}
ind++;