summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-06-02 14:34:15 -0700
committerEmil Velikov <[email protected]>2016-06-14 15:48:36 +0100
commitbb4ff53a716071a3e01eb55b585a0f839f9f428a (patch)
tree9a5bea40ddc104dff625dfecbd55acf3fe39168d
parentd5dc87a1efdfc348f30b06dbafe1a8ae1649a650 (diff)
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 <[email protected]> Cc: "12.0" <[email protected]> (cherry picked from commit 62c6e94bd69a1287ebb4908f4ee67b8f730466cc)
-rw-r--r--src/compiler/spirv/spirv_to_nir.c38
-rw-r--r--src/compiler/spirv/vtn_variables.c16
2 files changed, 36 insertions, 18 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index e8aea73581b..f1fa6eedfae 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -517,7 +517,8 @@ struct_member_decoration_cb(struct vtn_builder *b,
break;
case SpvDecorationPatch:
- unreachable("Tessellation not yet supported");
+ vtn_warn("Tessellation not yet supported");
+ break;
case SpvDecorationSpecId:
case SpvDecorationBlock:
@@ -534,11 +535,14 @@ struct_member_decoration_cb(struct vtn_builder *b,
case SpvDecorationDescriptorSet:
case SpvDecorationNoContraction:
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 SpvDecorationXfbStride:
- unreachable("Vulkan does not have transform feedback");
+ vtn_warn("Vulkan does not have transform feedback");
+ break;
case SpvDecorationCPacked:
case SpvDecorationSaturatedConversion:
@@ -546,7 +550,9 @@ struct_member_decoration_cb(struct vtn_builder *b,
case SpvDecorationFPRoundingMode:
case SpvDecorationFPFastMathMode:
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:
unreachable("Unhandled member decoration");
@@ -598,7 +604,9 @@ type_decoration_cb(struct vtn_builder *b,
case SpvDecorationOffset:
case SpvDecorationXfbBuffer:
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 SpvDecorationSpecId:
@@ -612,7 +620,9 @@ type_decoration_cb(struct vtn_builder *b,
case SpvDecorationLinkageAttributes:
case SpvDecorationNoContraction:
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 SpvDecorationSaturatedConversion:
@@ -620,7 +630,9 @@ type_decoration_cb(struct vtn_builder *b,
case SpvDecorationFPRoundingMode:
case SpvDecorationFPFastMathMode:
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 SpvCapabilityMultiViewport:
break;
+
case SpvCapabilityClipDistance:
case SpvCapabilityCullDistance:
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 SpvCapabilityTessellationPointSize:
case SpvCapabilityLinkage:
@@ -2331,7 +2339,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvCapabilityTransformFeedback:
case SpvCapabilityStorageImageReadWithoutFormat:
case SpvCapabilityStorageImageWriteWithoutFormat:
- unreachable("Unsupported SPIR-V Capability");
+ vtn_warn("Unsupported SPIR-V capability: %s",
+ spirv_capability_to_string(cap));
break;
case SpvCapabilityAddresses:
@@ -2344,7 +2353,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvCapabilityDeviceEnqueue:
case SpvCapabilityLiteralSampler:
case SpvCapabilityGenericPointer:
- unreachable("Unsupported OpenCL-style Capability");
+ vtn_warn("Unsupported OpenCL-style SPIR-V capability: %s",
+ spirv_capability_to_string(cap));
break;
}
break;
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 812ac62b39a..61fc184a692 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -26,6 +26,7 @@
*/
#include "vtn_private.h"
+#include "spirv_info.h"
static struct vtn_access_chain *
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 */
case SpvDecorationPatch:
- unreachable("Tessellation not yet supported");
+ vtn_warn("Tessellation not yet supported");
+ break;
case SpvDecorationLocation:
unreachable("Handled above");
@@ -1056,11 +1058,15 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
case SpvDecorationDescriptorSet:
case SpvDecorationNoContraction:
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 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 SpvDecorationSaturatedConversion:
@@ -1068,7 +1074,9 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
case SpvDecorationFPRoundingMode:
case SpvDecorationFPFastMathMode:
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;
}
}