From dc2b47ab06fb42c85a8dfa206eac0353e340478b Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:33:15 -0400 Subject: [PATCH] fix metal by including it in more compile passes --- source/slang/slang-emit.cpp | 2 +- source/slang/slang-ir-specialize-resources.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 66135b2d83..9def0349fe 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -1221,7 +1221,7 @@ Result linkAndOptimizeIR( // concrete value. // These sort of GlobalVar's should be removed in-favor of directly // using the known value since this may be an indirect use of a resource - // variable (which is illegal for most targets). + // variable (which is illegal for almost targets). simplifyGlobalVars(irModule); switch( target ) diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp index 5e15098d42..b844b215dd 100644 --- a/source/slang/slang-ir-specialize-resources.cpp +++ b/source/slang/slang-ir-specialize-resources.cpp @@ -1202,7 +1202,9 @@ bool specializeResourceOutputs( HashSet& unspecializableFuncs) { auto targetRequest = codeGenContext->getTargetReq(); - if(isD3DTarget(targetRequest) || isKhronosTarget(targetRequest)) + // D3D & SPIRV/GLSL cannot easily use resources as parameters + // Metal cannot assign globals to resource-outputting functions (in global scope) + if(isD3DTarget(targetRequest) || isKhronosTarget(targetRequest) || isMetalTarget(targetRequest)) {} else {