summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/program_resource.c
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2015-03-10 13:11:14 +0200
committerTapani Pälli <[email protected]>2015-04-16 07:55:57 +0300
commit2ab8de2181988870a95de23aeb906df5678e1e90 (patch)
tree277c48bd24233d7fc96123ded05d6d4b21b0a65a /src/mesa/main/program_resource.c
parent9367ade331e5d0a7724c595e7afb0322caaaddf7 (diff)
mesa: implementation of glGetProgramResourceiv
Patch adds required helper functions to shaderapi.h and the actual implementation. The property query functionality can be tested with tests for following functions that are refactored by later patches: GetActiveAtomicCounterBufferiv GetActiveUniformBlockiv GetActiveUniformsiv v2: code cleanup (Ilia Mirkin) add bufSize < 0 check and error out fix is_resource_referenced to return bool check for propCount and bufSize, fixes in buffer_prop Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]>
Diffstat (limited to 'src/mesa/main/program_resource.c')
-rw-r--r--src/mesa/main/program_resource.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
index 9eb4e2ffd0c..b15a13210c0 100644
--- a/src/mesa/main/program_resource.c
+++ b/src/mesa/main/program_resource.c
@@ -276,6 +276,28 @@ _mesa_GetProgramResourceiv(GLuint program, GLenum programInterface,
const GLenum *props, GLsizei bufSize,
GLsizei *length, GLint *params)
{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg =
+ _mesa_lookup_shader_program_err(ctx, program, "glGetProgramResourceiv");
+
+ if (!shProg || !params)
+ return;
+
+ /* The error INVALID_VALUE is generated if <propCount> is zero.
+ * Note that we check < 0 here because it makes sense to bail early.
+ */
+ if (propCount <= 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramResourceiv(propCount <= 0)");
+ return;
+ }
+
+ /* No need to write any properties, user requested none. */
+ if (bufSize == 0)
+ return;
+
+ _mesa_get_program_resourceiv(shProg, programInterface, index,
+ propCount, props, bufSize, length, params);
}
/**