From 2a5a0d19d67b2ccd7eee33a6f3bead66cc2d78ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Tue, 10 Mar 2015 10:33:20 +0200 Subject: mesa: glGetProgramResourceName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch adds required helper functions to shaderapi.h and the actual implementation. Name generation copied from '_mesa_get_uniform_name' which can be removed later by refactoring functions to use resource list. The added functionality can be tested by tests for following functions that are refactored by later patches: GetActiveUniformName GetActiveUniformBlockName v2: no index for geometry shader inputs (Ilia Mirkin) add bufSize < 0 check and error out validate enum corresponding Piglit test: arb_program_interface_query-getprogramresourcename Signed-off-by: Tapani Pälli Reviewed-by: Martin Peres --- src/mesa/main/program_resource.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/mesa/main/program_resource.c') diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c index 7a27325..a60b2e4 100644 --- a/src/mesa/main/program_resource.c +++ b/src/mesa/main/program_resource.c @@ -245,6 +245,29 @@ _mesa_GetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) { + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = + _mesa_lookup_shader_program_err(ctx, program, + "glGetProgramResourceName"); + + /* Set user friendly return values in case of errors. */ + if (name) + *name = '\0'; + if (length) + *length = 0; + + if (!shProg || !name) + return; + + if (programInterface == GL_ATOMIC_COUNTER_BUFFER || + !supported_interface_enum(programInterface)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceName(%s)", + _mesa_lookup_enum_by_nr(programInterface)); + return; + } + + _mesa_get_program_resource_name(shProg, programInterface, index, bufSize, + length, name, "glGetProgramResourceName"); } void GLAPIENTRY -- cgit v1.1