summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shaderapi.c
diff options
context:
space:
mode:
authorAntia Puentes <[email protected]>2018-08-13 14:13:38 +0200
committerAlejandro PiƱeiro <[email protected]>2019-07-12 23:42:41 +0200
commit8818553f1809d25c08ad44826313352e54453717 (patch)
treed16acf9608b2d1d8a3de264fa4e1c3690e666341 /src/mesa/main/shaderapi.c
parent8792abff9de8a6767fdd97bd4b5d0c3a1ef1b1e2 (diff)
mesa/shaderapi: Fix TRANSFORM_FEEDBACK_VARYING program query
Fixes the program queries API (glGetProgramiv): TRANSFORM_FEEDBACK_VARYINGS and TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH in two cases: 1. ARB_enhaced_layouts: The queries were not working for GLSL shaders which specify the varyings using enhanced layouts. We were returning the info as if the varyings could only be specified using the API. 2. ARB_gl_spirv: TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH should return 1 if there is no name reflection information available. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index e84f5bdf8b7..c057178bfa9 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -771,19 +771,48 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
case GL_TRANSFORM_FEEDBACK_VARYINGS:
if (!has_xfb)
break;
- *params = shProg->TransformFeedback.NumVarying;
+
+ /* Check first if there are transform feedback varyings specified in the
+ * shader (ARB_enhanced_layouts). If there isn't any, return the number of
+ * varyings specified using the API.
+ */
+ if (shProg->last_vert_prog &&
+ shProg->last_vert_prog->sh.LinkedTransformFeedback->NumVarying > 0)
+ *params =
+ shProg->last_vert_prog->sh.LinkedTransformFeedback->NumVarying;
+ else
+ *params = shProg->TransformFeedback.NumVarying;
return;
case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: {
unsigned i;
GLint max_len = 0;
+ bool in_shader_varyings;
+ int num_varying;
+
if (!has_xfb)
break;
- for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
- /* Add one for the terminating NUL character.
+ /* Check first if there are transform feedback varyings specified in the
+ * shader (ARB_enhanced_layouts). If there isn't any, use the ones
+ * specified using the API.
+ */
+ in_shader_varyings = shProg->last_vert_prog &&
+ shProg->last_vert_prog->sh.LinkedTransformFeedback->NumVarying > 0;
+
+ num_varying = in_shader_varyings ?
+ shProg->last_vert_prog->sh.LinkedTransformFeedback->NumVarying :
+ shProg->TransformFeedback.NumVarying;
+
+ for (i = 0; i < num_varying; i++) {
+ const char *name = in_shader_varyings ?
+ shProg->last_vert_prog->sh.LinkedTransformFeedback->Varyings[i].Name
+ : shProg->TransformFeedback.VaryingNames[i];
+
+ /* Add one for the terminating NUL character. We have to use
+ * strlen_or_zero, as for shaders constructed from SPIR-V binaries,
+ * it is possible that no name reflection information is available.
*/
- const GLint len =
- strlen(shProg->TransformFeedback.VaryingNames[i]) + 1;
+ const GLint len = strlen_or_zero(name) + 1;
if (len > max_len)
max_len = len;