From 79e92395f8ce3d92c446e3bb3250d19ce33decd5 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 16 Apr 2021 10:34:26 -0700 Subject: Update `model-viewer` example and fixing compiler bugs. (#1795) --- source/slang/slang-api.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/slang/slang-api.cpp') 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 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; } -- cgit v1.2.3