Patch adds required helper functions to shaderapi.h and the actual implementation.
The added functionality can be tested by tests for following functions that are refactored by later patches: GetFragDataIndex Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> --- src/mesa/main/program_resource.c | 25 ++++++++++++++++++++++++- src/mesa/main/shader_query.cpp | 18 ++++++++++++++++++ src/mesa/main/shaderapi.h | 4 ++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c index 87a0144..ae987de 100644 --- a/src/mesa/main/program_resource.c +++ b/src/mesa/main/program_resource.c @@ -329,9 +329,32 @@ _mesa_GetProgramResourceLocation(GLuint program, GLenum programInterface, return _mesa_program_resource_location(shProg, programInterface, name); } +/** + * Returns output index for dual source blending. + */ GLint GLAPIENTRY _mesa_GetProgramResourceLocationIndex(GLuint program, GLenum programInterface, const GLchar *name) { - return -1; + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = + lookup_linked_program(program, "glGetProgramResourceLocationIndex"); + + if (!shProg || invalid_array_element_syntax(name)) + return -1; + + /* From the GL_ARB_program_interface_query spec: + * + * "For GetProgramResourceLocationIndex, <programInterface> must be + * PROGRAM_OUTPUT." + */ + if (programInterface != GL_PROGRAM_OUTPUT) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetProgramResourceLocationIndex (%s)", + _mesa_lookup_enum_by_nr(programInterface)); + return -1; + } + + return _mesa_program_resource_location_index(shProg, programInterface, + name); } diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index 4ae00a6..d3264db 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -807,3 +807,21 @@ _mesa_program_resource_location(struct gl_shader_program *shProg, return program_resource_location(shProg, res, name); } + +/** + * Function implements following index queries: + * glGetFragDataIndex + */ +GLint +_mesa_program_resource_location_index(struct gl_shader_program *shProg, + GLenum interface, const char *name) +{ + struct gl_program_resource *res = + _mesa_program_resource_find_name(shProg, interface, name); + + /* Non-existent (inactive) variable. */ + if (!res) + return -1; + + return RESOURCE_VAR(res)->data.index; +} diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h index 73ebf60..5046018 100644 --- a/src/mesa/main/shaderapi.h +++ b/src/mesa/main/shaderapi.h @@ -248,6 +248,10 @@ extern GLint _mesa_program_resource_location(struct gl_shader_program *shProg, GLenum interface, const char *name); +extern GLint +_mesa_program_resource_location_index(struct gl_shader_program *shProg, + GLenum interface, const char *name); + #ifdef __cplusplus } #endif -- 2.1.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev