glsl: make component_slots() returns 2 for samplers/images
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 20 Apr 2017 12:42:49 +0000 (14:42 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sat, 6 May 2017 14:40:19 +0000 (16:40 +0200)
Bindless samplers/images are 64-bit unsigned integers, which
means they consume two components as specified by
ARB_bindless_texture.

It looks like we are not wasting uniform storage by changing
this because default-block uniforms are not packed. So, if
we use N uint uniforms, they occupy N * 16 bytes in the
constant buffer. This is something that could be improved.

Though, count_uniform_size needs to be adjusted to not count
a sampler (or image) twice.

As a side effect, this will probably break the cache if you
have one because it will consider sampler/image types as
two components.

v3: - update the comments

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl_types.cpp

index c195e767e259c991f23a70c88727e1505664c723..f6335b0f9eb50f6cb8798108698c59d23cb0d58c 100644 (file)
@@ -340,9 +340,13 @@ private:
       if (type->contains_subroutine()) {
          this->num_shader_subroutines += values;
       } else if (type->contains_sampler()) {
-         this->num_shader_samplers += values;
+         /* Samplers (bound or bindless) are counted as two components as
+          * specified by ARB_bindless_texture. */
+         this->num_shader_samplers += values / 2;
       } else if (type->contains_image()) {
-         this->num_shader_images += values;
+         /* Images (bound or bindless) are counted as two components as
+          * specified by ARB_bindless_texture. */
+         this->num_shader_images += values / 2;
 
          /* As drivers are likely to represent image uniforms as
           * scalar indices, count them against the limit of uniform
index 22a54d06eff8051f109e4dafaa6bda8d1773789d..8fa626bba96a677f28b5698dc599360611383233 100644 (file)
@@ -1293,6 +1293,8 @@ glsl_type::component_slots() const
 
    case GLSL_TYPE_SAMPLER:
    case GLSL_TYPE_IMAGE:
+      return 2;
+
    case GLSL_TYPE_SUBROUTINE:
       return 1;