mesa: add KHR_no_error support for gl*UniformHandleui64*ARB
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 14 Jun 2017 09:27:44 +0000 (11:27 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 18 Jun 2017 12:21:05 +0000 (14:21 +0200)
Similar to _mesa_uniform() except that we have to call
validate_uniform_parameters() instead of validate_uniform().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/uniform_query.cpp

index fed33df6fb047934bdc3e06e35dc387db45eb1df..37c130ac310ff3870527c49f75183798be6d225f 100644 (file)
@@ -1359,28 +1359,48 @@ _mesa_uniform_handle(GLint location, GLsizei count, const GLvoid *values,
                      struct gl_context *ctx, struct gl_shader_program *shProg)
 {
    unsigned offset;
-   struct gl_uniform_storage *const uni =
-      validate_uniform_parameters(location, count, &offset,
-                                  ctx, shProg, "glUniformHandleui64*ARB");
-   if (uni == NULL)
-      return;
+   struct gl_uniform_storage *uni;
 
-   if (!uni->is_bindless) {
-      /* From section "Errors" of the ARB_bindless_texture spec:
-       *
-       * "The error INVALID_OPERATION is generated by
-       *  UniformHandleui64{v}ARB if the sampler or image uniform being
-       *  updated has the "bound_sampler" or "bound_image" layout qualifier."
-       *
-       * From section 4.4.6 of the ARB_bindless_texture spec:
+   if (_mesa_is_no_error_enabled(ctx)) {
+      /* From Section 7.6 (UNIFORM VARIABLES) of the OpenGL 4.5 spec:
        *
-       * "In the absence of these qualifiers, sampler and image uniforms are
-       *  considered "bound". Additionally, if GL_ARB_bindless_texture is not
-       *  enabled, these uniforms are considered "bound"."
+       *   "If the value of location is -1, the Uniform* commands will
+       *   silently ignore the data passed in, and the current uniform values
+       *   will not be changed.
        */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glUniformHandleui64*ARB(non-bindless sampler/image uniform)");
-      return;
+      if (location == -1)
+         return;
+
+      uni = shProg->UniformRemapTable[location];
+
+      /* The array index specified by the uniform location is just the
+       * uniform location minus the base location of of the uniform.
+       */
+      assert(uni->array_elements > 0 || location == (int)uni->remap_location);
+      offset = location - uni->remap_location;
+   } else {
+      uni = validate_uniform_parameters(location, count, &offset,
+                                        ctx, shProg, "glUniformHandleui64*ARB");
+      if (!uni)
+         return;
+
+      if (!uni->is_bindless) {
+         /* From section "Errors" of the ARB_bindless_texture spec:
+          *
+          * "The error INVALID_OPERATION is generated by
+          *  UniformHandleui64{v}ARB if the sampler or image uniform being
+          *  updated has the "bound_sampler" or "bound_image" layout qualifier."
+          *
+          * From section 4.4.6 of the ARB_bindless_texture spec:
+          *
+          * "In the absence of these qualifiers, sampler and image uniforms are
+          *  considered "bound". Additionally, if GL_ARB_bindless_texture is
+          *  not enabled, these uniforms are considered "bound"."
+          */
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glUniformHandleui64*ARB(non-bindless sampler/image uniform)");
+         return;
+      }
    }
 
    const unsigned components = uni->type->vector_elements;