summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-18 23:01:45 -0700
committerGitHub <noreply@github.com>2024-04-18 23:01:45 -0700
commita3a5e7ea4e2ec15dd385c169578f5770f49b6e1c (patch)
tree3c7a75a3ca0f8c38f5f92871629947b812865234 /source/slang/slang-emit.cpp
parenta2b9e376b2d54283000a0fe0c48e6e1912d8a333 (diff)
Metal: rewrite global variables as explicit context. (#3981)
* Metal: rewrite global variables as explicit context. * Small tweaks.
Diffstat (limited to 'source/slang/slang-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index c00c7bfc3..b7227a4f0 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -69,6 +69,7 @@
#include "slang-ir-synthesize-active-mask.h"
#include "slang-ir-validate.h"
#include "slang-ir-wrap-structured-buffers.h"
+#include "slang-ir-wrap-global-context.h"
#include "slang-ir-liveness.h"
#include "slang-ir-glsl-liveness.h"
#include "slang-ir-translate-glsl-global-var.h"
@@ -1082,6 +1083,12 @@ Result linkAndOptimizeIR(
validateIRModuleIfEnabled(codeGenContext, irModule);
}
+ // Metal does not allow global variables and global parameters, so
+ // we need to convert them into an explicit global context parameter
+ // passed around through a function parameter.
+ if (target == CodeGenTarget::Metal)
+ wrapGlobalScopeInContextType(irModule);
+
auto metadata = new ArtifactPostEmitMetadata;
outLinkedIR.metadata = metadata;