summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-api.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-04-16 10:34:26 -0700
committerGitHub <noreply@github.com>2021-04-16 10:34:26 -0700
commit79e92395f8ce3d92c446e3bb3250d19ce33decd5 (patch)
tree2ac277fa299200da72cf03a2b5b96338f66aee5d /source/slang/slang-api.cpp
parentbad484d838590d0a2aaf1b5b8ac820634af2decb (diff)
Update `model-viewer` example and fixing compiler bugs. (#1795)
Diffstat (limited to 'source/slang/slang-api.cpp')
-rw-r--r--source/slang/slang-api.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp
index bb0e2e174..8347b8c30 100644
--- a/source/slang/slang-api.cpp
+++ b/source/slang/slang-api.cpp
@@ -83,6 +83,12 @@ SLANG_API SlangResult slang_createGlobalSession(
slang::IGlobalSession** outGlobalSession)
{
Slang::ComPtr<slang::IGlobalSession> globalSession;
+
+#ifdef SLANG_ENABLE_IR_BREAK_ALLOC
+ // Set inst debug alloc counter to 0 so IRInsts for stdlib always starts from a large value.
+ Slang::_debugGetIRAllocCounter() = 0x80000000;
+#endif
+
SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(apiVersion, globalSession.writeRef()));
// If we have the embedded stdlib, load from that, else compile it
@@ -106,6 +112,12 @@ SLANG_API SlangResult slang_createGlobalSession(
}
*outGlobalSession = globalSession.detach();
+
+#ifdef SLANG_ENABLE_IR_BREAK_ALLOC
+ // Reset inst debug alloc counter to 0 so IRInsts for user code always starts from 0.
+ Slang::_debugGetIRAllocCounter() = 0;
+#endif
+
return SLANG_OK;
}