Mesa (gallium-mesa-7.4): glsl: fix incorrect size returned by glGetActiveUniform() for array elements.
Alan Hourihane
alanh at kemper.freedesktop.org
Wed Feb 18 12:59:25 UTC 2009
Module: Mesa
Branch: gallium-mesa-7.4
Commit: 29981c14da9d04866c13f8041b458b04aae2fbe8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=29981c14da9d04866c13f8041b458b04aae2fbe8
Author: Brian Paul <brianp at vmware.com>
Date: Mon Feb 16 20:28:14 2009 -0700
glsl: fix incorrect size returned by glGetActiveUniform() for array elements.
Fixes one of the issues in bug 20056.
(cherry picked from master, commit 369d1859d7bc4a6213f128718f8affc8e4f06006)
---
src/mesa/shader/shader_api.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index b3d66c5..e768c39 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -866,6 +866,7 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
{
const struct gl_shader_program *shProg;
const struct gl_program *prog;
+ const struct gl_program_parameter *param;
GLint progPos;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform");
@@ -891,14 +892,30 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
if (!prog || progPos < 0)
return; /* should never happen */
- if (nameOut)
- copy_string(nameOut, maxLength, length,
- prog->Parameters->Parameters[progPos].Name);
- if (size)
- *size = prog->Parameters->Parameters[progPos].Size
- / sizeof_glsl_type(prog->Parameters->Parameters[progPos].DataType);
- if (type)
- *type = prog->Parameters->Parameters[progPos].DataType;
+ ASSERT(progPos < prog->Parameters->NumParameters);
+ param = &prog->Parameters->Parameters[progPos];
+
+ if (nameOut) {
+ copy_string(nameOut, maxLength, length, param->Name);
+ }
+
+ if (size) {
+ GLint typeSize = sizeof_glsl_type(param->DataType);
+ if (param->Size > typeSize) {
+ /* This is an array.
+ * Array elements are placed on vector[4] boundaries so they're
+ * a multiple of four floats. We round typeSize up to next multiple
+ * of four to get the right size below.
+ */
+ typeSize = (typeSize + 3) & ~3;
+ }
+ /* Note that the returned size is in units of the <type>, not bytes */
+ *size = param->Size / typeSize;
+ }
+
+ if (type) {
+ *type = param->DataType;
+ }
}
More information about the mesa-commit
mailing list