diff options
author | Dave Airlie <[email protected]> | 2016-05-24 06:41:21 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2016-06-07 06:10:19 +1000 |
commit | 07403014c3a29bfdecc89def187389ac9f208529 (patch) | |
tree | 7886817d884483ae38d2f18ec346ee42a201d704 /src/mesa/main/shader_query.cpp | |
parent | ec2b52e2d9d7114df6e6023eec5949c4c6a76d52 (diff) |
mesa/program_resource: return -1 for index if no location.
The GL4.5 spec quote seems clear on this:
"The value -1 will be returned by either command if an error occurs,
if name does not identify an active variable on programInterface,
or if name identifies an active variable that does not have a valid
location assigned, as described above."
This fixes:
GL45-CTS.program_interface_query.output-built-in
[airlied: use _mesa_program_resource_location_index as
suggested by Eduardo]
Reviewed-by: Eduardo Lima Mitev <[email protected]>
Cc: "12.0" <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main/shader_query.cpp')
-rw-r--r-- | src/mesa/main/shader_query.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index eec933c2176..5956ce4976d 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -881,6 +881,13 @@ _mesa_program_resource_location_index(struct gl_shader_program *shProg, if (!res || !(res->StageReferences & (1 << MESA_SHADER_FRAGMENT))) return -1; + /* From OpenGL 4.5 spec, 7.3 Program Objects + * "The value -1 will be returned by either command... + * ... or if name identifies an active variable that does not have a + * valid location assigned. + */ + if (RESOURCE_VAR(res)->location == -1) + return -1; return RESOURCE_VAR(res)->index; } @@ -1233,12 +1240,18 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg, default: goto invalid_operation; } - case GL_LOCATION_INDEX: + case GL_LOCATION_INDEX: { + int tmp; if (res->Type != GL_PROGRAM_OUTPUT) goto invalid_operation; - *val = RESOURCE_VAR(res)->index; + tmp = program_resource_location(res, 0); + if (tmp == -1) + *val = -1; + else + *val = _mesa_program_resource_location_index(shProg, res->Type, + RESOURCE_VAR(res)->name); return 1; - + } case GL_NUM_COMPATIBLE_SUBROUTINES: if (res->Type != GL_VERTEX_SUBROUTINE_UNIFORM && res->Type != GL_FRAGMENT_SUBROUTINE_UNIFORM && |