summaryrefslogtreecommitdiff
path: root/spirv_msl.hpp
diff options
context:
space:
mode:
authorBill Hollings <bill.hollings@brenwill.com>2023-10-13 21:57:01 -0400
committerBill Hollings <bill.hollings@brenwill.com>2023-10-14 14:46:47 -0400
commit16fbf8872ad4ea3cfe63db8fd8fd3edff18663cd (patch)
treeb3cbe0bf626a4eebf9758a9bb13af08e5834cc88 /spirv_msl.hpp
parent724433d72925f54682ae637c8bc4f4b7e83c4409 (diff)
downloadSPIRV-Cross-16fbf8872ad4ea3cfe63db8fd8fd3edff18663cd.tar.gz
SPIRV-Cross-16fbf8872ad4ea3cfe63db8fd8fd3edff18663cd.tar.bz2
SPIRV-Cross-16fbf8872ad4ea3cfe63db8fd8fd3edff18663cd.zip
MSL: Workaround Metal 3.1 regression bug on recursive input structs.
Metal 3.1 introduced a Metal regression bug which causes an infinite recursion crash during Metal's analysis of an entry point input structure that itself contains internal recursion. This patch works around this by replacing the recursive input declaration with a alternate variable of type void*, and then casting to the correct type at the top of the entry point function. - Add CompilerMSL::Options::replace_recursive_inputs to enable replacing recursive input. - Add Compiler::type_contains_recursion() to determine if a struct contains internal recursion, and add custom Decorations to mark such structs, to short-cut future similar checks. - Replace recursive input struct declarations with void*, and emit a recast to correct type at top of entry function. - Add unit test. - Compiler::type_is_top_level_block() remove hardcode reference to spirv_cross namespace, as it interferes with configurable namespaces (unrelated).
Diffstat (limited to 'spirv_msl.hpp')
-rw-r--r--spirv_msl.hpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/spirv_msl.hpp b/spirv_msl.hpp
index 26167f67..dc149530 100644
--- a/spirv_msl.hpp
+++ b/spirv_msl.hpp
@@ -505,6 +505,13 @@ public:
// Note: Only Apple's GPU compiler takes advantage of the lack of coherency, so make sure to test on Apple GPUs if you disable this.
bool readwrite_texture_fences = true;
+ // Metal 3.1 introduced a Metal regression bug which causes infinite recursion during
+ // Metal's analysis of an entry point input structure that is itself recursive. Enabling
+ // this option will replace the recursive input declaration with a alternate variable of
+ // type void*, and then cast to the correct type at the top of the entry point function.
+ // The bug has been reported to Apple, and will hopefully be fixed in future releases.
+ bool replace_recursive_inputs = false;
+
bool is_ios() const
{
return platform == iOS;
@@ -1194,6 +1201,7 @@ protected:
SmallVector<uint32_t> buffer_aliases_discrete;
std::unordered_set<uint32_t> atomic_image_vars; // Emulate texture2D atomic operations
std::unordered_set<uint32_t> pull_model_inputs;
+ std::unordered_set<uint32_t> recursive_inputs;
SmallVector<SPIRVariable *> entry_point_bindings;