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 <jason@jlekstrand.net>
This commit is contained in:
parent
d75f84cb65
commit
c5236fc6e2
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue