spirv: Calculate properly 16-bit vector sizes
authorJose Maria Casanova Crespo <jmcasanova@igalia.com>
Thu, 22 Feb 2018 16:36:37 +0000 (17:36 +0100)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 1 Mar 2018 05:37:40 +0000 (21:37 -0800)
Range in 16-bit push constants load was being calculated
wrongly using 4-bytes per element instead of 2-bytes as it
should be.

v2: Use glsl_get_bit_size instead of if statement
    (Jason Ekstrand)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/spirv/vtn_variables.c

index 9eb85c24e9571e928f4258a53b9f7e458645e2b5..105b33a5671433146fed06c8025a0c98587c0344 100644 (file)
@@ -683,12 +683,9 @@ vtn_type_block_size(struct vtn_builder *b, struct vtn_type *type)
       if (cols > 1) {
          vtn_assert(type->stride > 0);
          return type->stride * cols;
-      } else if (base_type == GLSL_TYPE_DOUBLE ||
-                base_type == GLSL_TYPE_UINT64 ||
-                base_type == GLSL_TYPE_INT64) {
-         return glsl_get_vector_elements(type->type) * 8;
       } else {
-         return glsl_get_vector_elements(type->type) * 4;
+         unsigned type_size = glsl_get_bit_size(type->type) / 8;
+         return glsl_get_vector_elements(type->type) * type_size;
       }
    }