nir/spirv: Make unhandled decorations and capabilities non-fatal
glslang frequently throw bogus decorations into shaders. While we are free to assert-fail, it's a bit nicer to the application to just warn. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Cc: "12.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
@@ -517,7 +517,8 @@ struct_member_decoration_cb(struct vtn_builder *b,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvDecorationPatch:
|
case SpvDecorationPatch:
|
||||||
unreachable("Tessellation not yet supported");
|
vtn_warn("Tessellation not yet supported");
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationSpecId:
|
case SpvDecorationSpecId:
|
||||||
case SpvDecorationBlock:
|
case SpvDecorationBlock:
|
||||||
@@ -534,11 +535,14 @@ struct_member_decoration_cb(struct vtn_builder *b,
|
|||||||
case SpvDecorationDescriptorSet:
|
case SpvDecorationDescriptorSet:
|
||||||
case SpvDecorationNoContraction:
|
case SpvDecorationNoContraction:
|
||||||
case SpvDecorationInputAttachmentIndex:
|
case SpvDecorationInputAttachmentIndex:
|
||||||
unreachable("Decoration not allowed on struct members");
|
vtn_warn("Decoration not allowed on struct members: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationXfbBuffer:
|
case SpvDecorationXfbBuffer:
|
||||||
case SpvDecorationXfbStride:
|
case SpvDecorationXfbStride:
|
||||||
unreachable("Vulkan does not have transform feedback");
|
vtn_warn("Vulkan does not have transform feedback");
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationCPacked:
|
case SpvDecorationCPacked:
|
||||||
case SpvDecorationSaturatedConversion:
|
case SpvDecorationSaturatedConversion:
|
||||||
@@ -546,7 +550,9 @@ struct_member_decoration_cb(struct vtn_builder *b,
|
|||||||
case SpvDecorationFPRoundingMode:
|
case SpvDecorationFPRoundingMode:
|
||||||
case SpvDecorationFPFastMathMode:
|
case SpvDecorationFPFastMathMode:
|
||||||
case SpvDecorationAlignment:
|
case SpvDecorationAlignment:
|
||||||
unreachable("Decoraiton only allowed for CL-style kernels");
|
vtn_warn("Decoraiton only allowed for CL-style kernels: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
unreachable("Unhandled member decoration");
|
unreachable("Unhandled member decoration");
|
||||||
@@ -598,7 +604,9 @@ type_decoration_cb(struct vtn_builder *b,
|
|||||||
case SpvDecorationOffset:
|
case SpvDecorationOffset:
|
||||||
case SpvDecorationXfbBuffer:
|
case SpvDecorationXfbBuffer:
|
||||||
case SpvDecorationXfbStride:
|
case SpvDecorationXfbStride:
|
||||||
unreachable("Decoraiton only allowed for struct members");
|
vtn_warn("Decoraiton only allowed for struct members: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationRelaxedPrecision:
|
case SpvDecorationRelaxedPrecision:
|
||||||
case SpvDecorationSpecId:
|
case SpvDecorationSpecId:
|
||||||
@@ -612,7 +620,9 @@ type_decoration_cb(struct vtn_builder *b,
|
|||||||
case SpvDecorationLinkageAttributes:
|
case SpvDecorationLinkageAttributes:
|
||||||
case SpvDecorationNoContraction:
|
case SpvDecorationNoContraction:
|
||||||
case SpvDecorationInputAttachmentIndex:
|
case SpvDecorationInputAttachmentIndex:
|
||||||
unreachable("Decoraiton not allowed on types");
|
vtn_warn("Decoraiton not allowed on types: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationCPacked:
|
case SpvDecorationCPacked:
|
||||||
case SpvDecorationSaturatedConversion:
|
case SpvDecorationSaturatedConversion:
|
||||||
@@ -620,7 +630,9 @@ type_decoration_cb(struct vtn_builder *b,
|
|||||||
case SpvDecorationFPRoundingMode:
|
case SpvDecorationFPRoundingMode:
|
||||||
case SpvDecorationFPFastMathMode:
|
case SpvDecorationFPFastMathMode:
|
||||||
case SpvDecorationAlignment:
|
case SpvDecorationAlignment:
|
||||||
unreachable("Decoraiton only allowed for CL-style kernels");
|
vtn_warn("Decoraiton only allowed for CL-style kernels: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2299,14 +2311,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
case SpvCapabilityInterpolationFunction:
|
case SpvCapabilityInterpolationFunction:
|
||||||
case SpvCapabilityMultiViewport:
|
case SpvCapabilityMultiViewport:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvCapabilityClipDistance:
|
case SpvCapabilityClipDistance:
|
||||||
case SpvCapabilityCullDistance:
|
case SpvCapabilityCullDistance:
|
||||||
case SpvCapabilityGeometryStreams:
|
case SpvCapabilityGeometryStreams:
|
||||||
/* glslang sometimes throws these at us even though it doesn't
|
|
||||||
* actually use the associated variable.
|
|
||||||
*/
|
|
||||||
fprintf(stderr, "WARNING: Unsupported SPIR-V Capability\n");
|
|
||||||
break;
|
|
||||||
case SpvCapabilityTessellation:
|
case SpvCapabilityTessellation:
|
||||||
case SpvCapabilityTessellationPointSize:
|
case SpvCapabilityTessellationPointSize:
|
||||||
case SpvCapabilityLinkage:
|
case SpvCapabilityLinkage:
|
||||||
@@ -2331,7 +2339,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
case SpvCapabilityTransformFeedback:
|
case SpvCapabilityTransformFeedback:
|
||||||
case SpvCapabilityStorageImageReadWithoutFormat:
|
case SpvCapabilityStorageImageReadWithoutFormat:
|
||||||
case SpvCapabilityStorageImageWriteWithoutFormat:
|
case SpvCapabilityStorageImageWriteWithoutFormat:
|
||||||
unreachable("Unsupported SPIR-V Capability");
|
vtn_warn("Unsupported SPIR-V capability: %s",
|
||||||
|
spirv_capability_to_string(cap));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvCapabilityAddresses:
|
case SpvCapabilityAddresses:
|
||||||
@@ -2344,7 +2353,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
case SpvCapabilityDeviceEnqueue:
|
case SpvCapabilityDeviceEnqueue:
|
||||||
case SpvCapabilityLiteralSampler:
|
case SpvCapabilityLiteralSampler:
|
||||||
case SpvCapabilityGenericPointer:
|
case SpvCapabilityGenericPointer:
|
||||||
unreachable("Unsupported OpenCL-style Capability");
|
vtn_warn("Unsupported OpenCL-style SPIR-V capability: %s",
|
||||||
|
spirv_capability_to_string(cap));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vtn_private.h"
|
#include "vtn_private.h"
|
||||||
|
#include "spirv_info.h"
|
||||||
|
|
||||||
static struct vtn_access_chain *
|
static struct vtn_access_chain *
|
||||||
vtn_access_chain_extend(struct vtn_builder *b, struct vtn_access_chain *old,
|
vtn_access_chain_extend(struct vtn_builder *b, struct vtn_access_chain *old,
|
||||||
@@ -1040,7 +1041,8 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
|
|||||||
break; /* Do nothing with these here */
|
break; /* Do nothing with these here */
|
||||||
|
|
||||||
case SpvDecorationPatch:
|
case SpvDecorationPatch:
|
||||||
unreachable("Tessellation not yet supported");
|
vtn_warn("Tessellation not yet supported");
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationLocation:
|
case SpvDecorationLocation:
|
||||||
unreachable("Handled above");
|
unreachable("Handled above");
|
||||||
@@ -1056,11 +1058,15 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
|
|||||||
case SpvDecorationDescriptorSet:
|
case SpvDecorationDescriptorSet:
|
||||||
case SpvDecorationNoContraction:
|
case SpvDecorationNoContraction:
|
||||||
case SpvDecorationInputAttachmentIndex:
|
case SpvDecorationInputAttachmentIndex:
|
||||||
unreachable("Decoration not allowed for variable or structure member");
|
vtn_warn("Decoration not allowed for variable or structure member: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationXfbBuffer:
|
case SpvDecorationXfbBuffer:
|
||||||
case SpvDecorationXfbStride:
|
case SpvDecorationXfbStride:
|
||||||
unreachable("Vulkan does not have transform feedback");
|
vtn_warn("Vulkan does not have transform feedback: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
|
|
||||||
case SpvDecorationCPacked:
|
case SpvDecorationCPacked:
|
||||||
case SpvDecorationSaturatedConversion:
|
case SpvDecorationSaturatedConversion:
|
||||||
@@ -1068,7 +1074,9 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
|
|||||||
case SpvDecorationFPRoundingMode:
|
case SpvDecorationFPRoundingMode:
|
||||||
case SpvDecorationFPFastMathMode:
|
case SpvDecorationFPFastMathMode:
|
||||||
case SpvDecorationAlignment:
|
case SpvDecorationAlignment:
|
||||||
unreachable("Decoraiton only allowed for CL-style kernels");
|
vtn_warn("Decoraiton only allowed for CL-style kernels: %s",
|
||||||
|
spirv_decoration_to_string(dec->decoration));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user