summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-06-19 15:24:30 -0700
committerEric Anholt <[email protected]>2012-07-31 12:06:19 -0700
commit5a165d1f3ae8eddb96c2d2026ac4a8f981733ac5 (patch)
tree3dacd67e5363e6f7c90e7161d3303d4623d35234 /src/mesa/main
parent467304dfe56bb4e3a66f500db5754500cc18955a (diff)
mesa: Add support for getting active uniform block names.
Fixes piglit ARB_uniform_buffer_object/getactiveuniformblockname. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/uniforms.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 940cb07c247..3236d6eb064 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -668,6 +668,10 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
params[0] = block->Binding;
return;
+ case GL_UNIFORM_BLOCK_NAME_LENGTH:
+ params[0] = strlen(block->Name) + 1;
+ return;
+
default:
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetActiveUniformBlockiv(pname 0x%x (%s))",
@@ -676,6 +680,48 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
}
}
+static void GLAPIENTRY
+_mesa_GetActiveUniformBlockName(GLuint program,
+ GLuint uniformBlockIndex,
+ GLsizei bufSize,
+ GLsizei *length,
+ GLchar *uniformBlockName)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+ struct gl_uniform_block *block;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+ return;
+ }
+
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockName(bufSize %d < 0)",
+ bufSize);
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetActiveUniformBlockiv");
+ if (!shProg)
+ return;
+
+ if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockiv(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+ return;
+ }
+
+ block = &shProg->UniformBlocks[uniformBlockIndex];
+
+ if (uniformBlockName) {
+ _mesa_copy_string(uniformBlockName, bufSize, length, block->Name);
+ }
+}
+
/**
* Plug in shader uniform-related functions into API dispatch table.
*/
@@ -738,6 +784,7 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec)
SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
+ SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName);
SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
#endif /* FEATURE_GL */