From f8294202ce8d5658f6308eeaed634058db9bbb4b Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Wed, 6 Nov 2024 13:14:35 +0200 Subject: Make various parameters and return types require specialization when targeting WGSL (#5483) Structured buffer types translate to array types in the WGSL emitter. WGSL doesn't allow passing runtime-sized arrays to functions. Similarly for pointers to texture handles. Also, structured buffers (runtime-sized arrays) cannot be returned in WGSL. This closes issue #5228, issue #5278 and issue #5288 by enabling specialized functions to be generated in these cases, in order to work around these constraints. --- source/slang/slang-ir-specialize-resources.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ir-specialize-resources.cpp') diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp index 6aca4bbc7..56f468ac7 100644 --- a/source/slang/slang-ir-specialize-resources.cpp +++ b/source/slang/slang-ir-specialize-resources.cpp @@ -67,7 +67,10 @@ struct ResourceParameterSpecializationCondition : FunctionCallSpecializeConditio else return isIllegalGLSLParameterType(type); } - + else if (isWGPUTarget(targetRequest)) + { + return isIllegalWGSLParameterType(type); + } // For now, we will not treat any other parameters as // needing specialization, even if they use resource @@ -1220,7 +1223,7 @@ bool specializeResourceOutputs( HashSet& unspecializableFuncs) { auto targetRequest = codeGenContext->getTargetReq(); - if (isD3DTarget(targetRequest) || isKhronosTarget(targetRequest)) + if (isD3DTarget(targetRequest) || isKhronosTarget(targetRequest) || isWGPUTarget(targetRequest)) { } else @@ -1354,4 +1357,10 @@ bool isIllegalSPIRVParameterType(IRType* type, bool isArray) } return false; } + +bool isIllegalWGSLParameterType(IRType* type) +{ + return isIllegalGLSLParameterType(type); +} + } // namespace Slang -- cgit v1.2.3