From c5236fc6e299225a94234ea5e381679ffbd36227 Mon Sep 17 00:00:00 2001 From: Xavier Bouchoux Date: Mon, 15 Oct 2018 16:24:29 +0200 Subject: [PATCH] nir/spirv: Fix assert when unsampled OpTypeImage has unknown 'Depth' 'dxc' hlsl-to-spirv compiler appears to emit 2 (Unknown) in the depth field, when the image is not sampled and the value is not needed. Previously, shaders failed with: SPIR-V parsing FAILED: In file ../src/compiler/spirv/spirv_to_nir.c:1412 !is_shadow 632 bytes into the SPIR-V binary Reviewed-by: Jason Ekstrand --- src/compiler/spirv/spirv_to_nir.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 2136c9df705..da0f2dcd805 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1380,7 +1380,9 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, vtn_fail("Invalid SPIR-V image dimensionality"); } - bool is_shadow = w[4]; + /* w[4]: as per Vulkan spec "Validation Rules within a Module", + * The “Depth” operand of OpTypeImage is ignored. + */ bool is_array = w[5]; bool multisampled = w[6]; unsigned sampled = w[7]; @@ -1406,10 +1408,9 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, 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, + val->type->type = glsl_sampler_type(dim, false, is_array, sampled_base_type); } else if (sampled == 2) { - vtn_assert(!is_shadow); val->type->sampled = false; val->type->type = glsl_image_type(dim, is_array, sampled_base_type); } else { -- 2.30.2