mesa: fix glUniform* when a struct contains a bindless sampler
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 14 Sep 2020 19:08:29 +0000 (21:08 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 18 Sep 2020 07:52:06 +0000 (07:52 +0000)
Small example from #3271:

layout (bindless_sampler) uniform;
struct SamplerSparse {
  sampler2D tex;
  vec4 size;
  [...]
};
uniform SamplerSparse foo;

'foo' will be marked as bindless but we should only take the assign-as-GLuint64 path for 'tex'.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3271
Fixes: 990c8d15ac3 ("mesa: fix setting uniform variables for bindless samplers/images")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6730>

src/mesa/main/uniform_query.cpp

index db2f173..2b1fc86 100644 (file)
@@ -1043,10 +1043,12 @@ copy_uniforms_to_storage(gl_constant_value *storage,
                          const unsigned offset, const unsigned components,
                          enum glsl_base_type basicType)
 {
-   if (!uni->type->is_boolean() && !uni->is_bindless) {
+   bool copy_as_uint64 = uni->is_bindless &&
+                         (uni->type->is_sampler() || uni->type->is_image());
+   if (!uni->type->is_boolean() && !copy_as_uint64) {
       memcpy(storage, values,
              sizeof(storage[0]) * components * count * size_mul);
-   } else if (uni->is_bindless) {
+   } else if (copy_as_uint64) {
       const union gl_constant_value *src =
          (const union gl_constant_value *) values;
       GLuint64 *dst = (GLuint64 *)&storage->i;