From 161de77e0feeab365f1a53464cb60eb3608ebe2e Mon Sep 17 00:00:00 2001 From: Antia Puentes Date: Fri, 14 Sep 2018 08:55:24 +0200 Subject: [PATCH] mesa/shader_query: Fix LOCATION_INDEX query (ARB_gl_spirv) When querying GL_LOCATION_INDEX using glGetProgramResourceiv we already know the index of the resource, we do not need to find it using the name, which is convenient for shaders coming from SPIR-V binaries where names are optional. Reviewed-by: Caio Marcelo de Oliveira Filho --- src/mesa/main/shader_query.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index a3365107648..e9b39b7ff8f 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -938,17 +938,9 @@ _mesa_program_resource_location(struct gl_shader_program *shProg, return program_resource_location(res, array_index); } -/** - * Function implements following index queries: - * glGetFragDataIndex - */ -GLint -_mesa_program_resource_location_index(struct gl_shader_program *shProg, - GLenum programInterface, const char *name) +static GLint +_get_resource_location_index(struct gl_program_resource *res) { - struct gl_program_resource *res = - _mesa_program_resource_find_name(shProg, programInterface, name, NULL); - /* Non-existent variable or resource is not referenced by fragment stage. */ if (!res || !(res->StageReferences & (1 << MESA_SHADER_FRAGMENT))) return -1; @@ -963,6 +955,20 @@ _mesa_program_resource_location_index(struct gl_shader_program *shProg, return RESOURCE_VAR(res)->index; } +/** + * Function implements following index queries: + * glGetFragDataIndex + */ +GLint +_mesa_program_resource_location_index(struct gl_shader_program *shProg, + GLenum programInterface, const char *name) +{ + struct gl_program_resource *res = + _mesa_program_resource_find_name(shProg, programInterface, name, NULL); + + return _get_resource_location_index(res); +} + static uint8_t stage_from_enum(GLenum ref) { @@ -1320,8 +1326,7 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg, if (tmp == -1) *val = -1; else - *val = _mesa_program_resource_location_index(shProg, res->Type, - RESOURCE_VAR(res)->name); + *val = _get_resource_location_index(res); return 1; } case GL_NUM_COMPATIBLE_SUBROUTINES: -- 2.30.2