@@ -24,6 +24,9 @@ extern const char *kDxCompilerLib;
2424// Helper class to dynamically load the dxcompiler or a compatible libraries.
2525class DxcDllSupport {
2626protected:
27+ // Mach change start: static dxcompiler
28+ BOOL m_initialized;
29+ // Mach change end
2730 HMODULE m_dll;
2831 DxcCreateInstanceProc m_createFn;
2932 DxcCreateInstance2Proc m_createFn2;
@@ -77,6 +80,7 @@ class DxcDllSupport {
7780// }
7881 HRESULT InitializeInternal (LPCSTR dllName, LPCSTR fnName) {
7982 if (strcmp (fnName, " DxcCreateInstance" ) == 0 ) {
83+ m_initialized = true ;
8084 m_createFn = &DxcCreateInstance;
8185 m_createFn2 = &DxcCreateInstance2;
8286 return S_OK;
@@ -87,9 +91,16 @@ class DxcDllSupport {
8791// Mach change end
8892
8993public:
90- DxcDllSupport () : m_dll(nullptr ), m_createFn(nullptr ), m_createFn2(nullptr ) {}
94+ // Mach change start: static dxcompiler
95+ // DxcDllSupport() : m_dll(nullptr), m_createFn(nullptr), m_createFn2(nullptr) {}
96+ DxcDllSupport () : m_initialized(false ), m_dll(nullptr ), m_createFn(nullptr ), m_createFn2(nullptr ) {}
97+ // Mach change end
9198
9299 DxcDllSupport (DxcDllSupport &&other) {
100+ // Mach change start: static dxcompiler
101+ m_initialized = other.m_initialized ;
102+ other.m_initialized = false ;
103+ // Mach change end
93104 m_dll = other.m_dll ;
94105 other.m_dll = nullptr ;
95106 m_createFn = other.m_createFn ;
@@ -116,8 +127,11 @@ class DxcDllSupport {
116127 HRESULT CreateInstance (REFCLSID clsid, REFIID riid, IUnknown **pResult) {
117128 if (pResult == nullptr )
118129 return E_POINTER;
130+ // Mach change start: static dxcompiler
119131 // if (m_dll == nullptr)
120- // return E_FAIL;
132+ if (!m_initialized)
133+ // Mach change end
134+ return E_FAIL;
121135 HRESULT hr = m_createFn (clsid, riid, (LPVOID *)pResult);
122136 return hr;
123137 }
@@ -133,17 +147,23 @@ class DxcDllSupport {
133147 IUnknown **pResult) {
134148 if (pResult == nullptr )
135149 return E_POINTER;
150+ // Mach change start: static dxcompiler
136151 // if (m_dll == nullptr)
137- // return E_FAIL;
138- // if (m_createFn2 == nullptr)
139- // return E_FAIL;
152+ if (!m_initialized)
153+ // Mach change end
154+ return E_FAIL;
155+ if (m_createFn2 == nullptr )
156+ return E_FAIL;
140157 HRESULT hr = m_createFn2 (pMalloc, clsid, riid, (LPVOID *)pResult);
141158 return hr;
142159 }
143160
144161 bool HasCreateWithMalloc () const { return m_createFn2 != nullptr ; }
145162
146- bool IsEnabled () const { return m_dll != nullptr ; }
163+ // Mach change start: static dxcompiler
164+ // bool IsEnabled() const { return m_dll != nullptr; }
165+ bool IsEnabled () const { return m_initialized; }
166+ // Mach change start
147167
148168 void Cleanup () {
149169 if (m_dll != nullptr ) {
@@ -158,11 +178,13 @@ class DxcDllSupport {
158178 }
159179 }
160180
161- HMODULE Detach () {
162- HMODULE hModule = m_dll;
163- m_dll = nullptr ;
164- return hModule;
165- }
181+ // Mach change start: static dxcompiler
182+ // HMODULE Detach() {
183+ // HMODULE hModule = m_dll;
184+ // m_dll = nullptr;
185+ // return hModule;
186+ // }
187+ // Mach change end
166188};
167189
168190inline DxcDefine GetDefine (LPCWSTR name, LPCWSTR value) {
0 commit comments