diff options
author | Eric Anholt <[email protected]> | 2012-04-27 15:56:44 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-07-20 10:43:40 -0700 |
commit | 9f1a4a6340824786142be9bc14f0c3418f14a69f (patch) | |
tree | 8fe11dbc309bafd5299540cc14df27dce368e888 /src/mesa | |
parent | acfbdfcbc8263cc0ace3468457a209dd80da017e (diff) |
mesa: Add support for glGetActiveUniformsiv on non-UBO pnames.
We'll need to propagate the UBO fields to the uniform storage records
before we can handle the other pnames.
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/uniform_query.cpp | 62 | ||||
-rw-r--r-- | src/mesa/main/uniforms.c | 1 | ||||
-rw-r--r-- | src/mesa/main/uniforms.h | 7 |
3 files changed, 70 insertions, 0 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 25d887dbcdc..b5499ea3445 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -74,6 +74,68 @@ _mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, } } +extern "C" void GLAPIENTRY +_mesa_GetActiveUniformsiv(GLuint program, + GLsizei uniformCount, + const GLuint *uniformIndices, + GLenum pname, + GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg; + GLsizei i; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); + if (!shProg) + return; + + if (uniformCount < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetUniformIndices(uniformCount < 0)"); + return; + } + + for (i = 0; i < uniformCount; i++) { + GLuint index = uniformIndices[i]; + const struct gl_uniform_storage *uni = &shProg->UniformStorage[index]; + + if (index >= shProg->NumUserUniformStorage) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniformsiv(index)"); + return; + } + + switch (pname) { + case GL_UNIFORM_TYPE: + params[i] = uni->type->gl_type; + break; + + case GL_UNIFORM_SIZE: + /* array_elements is zero for non-arrays, but the API requires that 1 be + * returned. + */ + params[i] = MAX2(1, uni->array_elements); + break; + + case GL_UNIFORM_NAME_LENGTH: + params[i] = strlen(uni->name) + 1; + break; + + case GL_UNIFORM_BLOCK_INDEX: + case GL_UNIFORM_OFFSET: + case GL_UNIFORM_ARRAY_STRIDE: + case GL_UNIFORM_MATRIX_STRIDE: + case GL_UNIFORM_IS_ROW_MAJOR: + _mesa_problem(ctx, "FINISHME: glGetActiveUniformsiv(pname)"); + params[i] = -1; + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetActiveUniformsiv(pname)"); + return; + } + } +} + static bool validate_uniform_parameters(struct gl_context *ctx, struct gl_shader_program *shProg, diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 9ed5d7e03a8..1cec5922db5 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -616,6 +616,7 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) /* GL_ARB_uniform_buffer_object / GL 3.1 */ SET_GetUniformIndices(exec, _mesa_GetUniformIndices); + SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv); #endif /* FEATURE_GL */ } diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h index a94dbd63bcb..bb05524765f 100644 --- a/src/mesa/main/uniforms.h +++ b/src/mesa/main/uniforms.h @@ -150,6 +150,13 @@ _mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); extern void GLAPIENTRY +_mesa_GetActiveUniformsiv(GLuint program, + GLsizei uniformCount, + const GLuint *uniformIndices, + GLenum pname, + GLint *params); + +extern void GLAPIENTRY _mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); extern void GLAPIENTRY |