On 17/12/17 05:46, Jason Ekstrand wrote:
---
  src/compiler/spirv/spirv_to_nir.c | 17 ++++++++++-------
  1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 83c75c7..ffea442 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1075,10 +1075,12 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
     case SpvOpTypeImage: {
        val->type->base_type = vtn_base_type_image;
- const struct glsl_type *sampled_type =
-         vtn_value(b, w[2], vtn_value_type_type)->type->type;
+      const struct vtn_type *sampled_type =
+         vtn_value(b, w[2], vtn_value_type_type)->type;
- vtn_assert(glsl_type_is_vector_or_scalar(sampled_type));
+      vtn_fail_if(sampled_type->base_type != vtn_base_type_scalar ||
+                  glsl_get_bit_size(sampled_type->type) != 32,
+                  "Sampled type of OpTypeImage must be a 32-bit scalar");

Maybe I'm missing something, but the 1.3 spec says :

"Sampled Type is the type of the components that result from sampling or reading from this image type. Must be a
scalar numerical type or OpTypeVoid."

"Numerical type: An integer type or a floating-point type."

"Floating-point type: Any width type from OpTypeFloat."

And OpTypeFloat can have variable width (like 16bits), so I'm not too sure about != 32 for the fail_if() above.

enum glsl_sampler_dim dim;
        switch ((SpvDim)w[3]) {
@@ -1090,7 +1092,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
        case SpvDimBuffer:   dim = GLSL_SAMPLER_DIM_BUF;   break;
        case SpvDimSubpassData: dim = GLSL_SAMPLER_DIM_SUBPASS; break;
        default:
-         vtn_fail("Invalid SPIR-V Sampler dimension");
+         vtn_fail("Invalid SPIR-V image dimensionality");
        }
bool is_shadow = w[4];
@@ -1115,15 +1117,16 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
val->type->image_format = translate_image_format(b, format); + enum glsl_base_type sampled_base_type =
+         glsl_get_base_type(sampled_type->type);
        if (sampled == 1) {
           val->type->sampled = true;
           val->type->type = glsl_sampler_type(dim, is_shadow, is_array,
-                                             glsl_get_base_type(sampled_type));
+                                             sampled_base_type);
        } else if (sampled == 2) {
           vtn_assert(!is_shadow);
           val->type->sampled = false;
-         val->type->type = glsl_image_type(dim, is_array,
-                                           glsl_get_base_type(sampled_type));
+         val->type->type = glsl_image_type(dim, is_array, sampled_base_type);
        } else {
           vtn_fail("We need to know if the image will be sampled");
        }


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to