mesa: add additional checks for uniform location query
authorTapani Pälli <tapani.palli@intel.com>
Mon, 26 Oct 2015 09:13:14 +0000 (11:13 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 26 Oct 2015 10:52:17 +0000 (12:52 +0200)
Patch adds additional check to make sure we don't return locations for
structures or arrays of structures.

From page 79 of the OpenGL 4.2 spec:
    "A valid name cannot be a structure, an array of structures, or any
    portion of a single vector or a matrix."

v2: use without-array() to simplify code (Timothy)

No Piglit or CTS regressions observed.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/mesa/main/shader_query.cpp

index 8182d3dcc048549c4e9d03a5178b7f61b3034d68..84cbfbcd4af867bf8be05237bb112c380cff0a8c 100644 (file)
@@ -808,6 +808,14 @@ program_resource_location(struct gl_shader_program *shProg,
       if (RESOURCE_UNI(res)->builtin)
          return -1;
 
+     /* From page 79 of the OpenGL 4.2 spec:
+      *
+      *     "A valid name cannot be a structure, an array of structures, or any
+      *     portion of a single vector or a matrix."
+      */
+      if (RESOURCE_UNI(res)->type->without_array()->is_record())
+         return -1;
+
       /* From the GL_ARB_uniform_buffer_object spec:
        *
        *     "The value -1 will be returned if <name> does not correspond to an