glsl: make component_slots() returns 1 for sampler types
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 20 Apr 2017 17:02:27 +0000 (19:02 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Apr 2017 08:08:04 +0000 (10:08 +0200)
It looks inconsistent to return 1 for image types and 0 for
sampler types. Especially because component_slots() is mostly
used by values_for_type() which always returns 1 for samplers.

For bindless, this value will be bumped to 2 because the
ARB_bindless_texture states that bindless samplers/images
should consume two components.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/compiler/glsl_types.cpp

index db65bb0e00d4a2a101e55ce817ce3eadce96cf23..0480bef80ecafc786777ab0f7d166eb8d7322de3 100644 (file)
@@ -1296,13 +1296,12 @@ glsl_type::component_slots() const
    case GLSL_TYPE_ARRAY:
       return this->length * this->fields.array->component_slots();
 
+   case GLSL_TYPE_SAMPLER:
    case GLSL_TYPE_IMAGE:
-      return 1;
    case GLSL_TYPE_SUBROUTINE:
-     return 1;
+      return 1;
 
    case GLSL_TYPE_FUNCTION:
-   case GLSL_TYPE_SAMPLER:
    case GLSL_TYPE_ATOMIC_UINT:
    case GLSL_TYPE_VOID:
    case GLSL_TYPE_ERROR: