@@ -194,25 +194,28 @@ void WriteOperationResultToConsole(IDxcOperationResult *pRewriteResult,
194
194
bool outputWarnings);
195
195
196
196
class DxcDllExtValidationSupport : public DxcDllSupport {
197
- // this instance of DxcDllSupport manages the lifetime of
198
- // dxil.dll
197
+ // DxcDllExtValidationSupport manages the
198
+ // lifetime of dxcompiler.dll, while the member, m_DxilSupport,
199
+ // manages the lifetime of dxil.dll
199
200
DxcDllSupport *m_DxilSupport = nullptr ;
200
201
201
202
std::string DxilDLLPathExt = " " ;
202
- bool InitializationSuccess = false ;
203
+ bool ExternalDxilDLLInitializationSuccess = false ;
203
204
// override DxcDllSupport's implementation of InitializeInternal,
204
205
// adding the environment variable value check for a path to a dxil.dll
205
206
// for external validation
206
207
HRESULT InitializeInternal (LPCSTR dllName, LPCSTR fnName){
207
208
208
209
// Load dxcompiler.dll
209
- HRESULT result = m_DxilSupport->InitializeForDll (dllName, fnName);
210
- InitializationSuccess = DXC_FAILED (result) ? false : true ;
211
- if (!InitializationSuccess){
210
+ HRESULT result = InitializeForDll (dllName, fnName);
211
+ // if dxcompiler.dll fails to load, then we won't try loading dxil.dll,
212
+ // so set this boolean to false.
213
+ ExternalDxilDLLInitializationSuccess = DXC_FAILED (result) ? false : true ;
214
+ if (!ExternalDxilDLLInitializationSuccess) {
212
215
return result;
213
216
}
214
217
215
- // now handle internal or external dxil.dll
218
+ // now handle external dxil.dll
216
219
const char *envVal = std::getenv (" DXC_DXIL_DLL_PATH" );
217
220
bool ValidateInternally = false ;
218
221
if (!envVal || std::string (envVal).empty ()) {
@@ -226,18 +229,23 @@ class DxcDllExtValidationSupport : public DxcDllSupport {
226
229
227
230
// Check if path is absolute and exists
228
231
if (!DllPath.is_absolute () || !std::filesystem::exists (DllPath)) {
229
- InitializationSuccess = false ;
232
+ ExternalDxilDLLInitializationSuccess = false ;
230
233
// TODO: Ideally emit some diagnostic that the given absolute path doesn't exist
231
234
return HRESULT_FROM_WIN32 (GetLastError ());
232
235
}
233
236
result = m_DxilSupport->InitializeForDll (DllPathStr.data (), fnName);
234
237
if (DXC_FAILED (result)) {
235
- InitializationSuccess = false ;
238
+ ExternalDxilDLLInitializationSuccess = false ;
239
+ return result;
236
240
}
241
+ ExternalDxilDLLInitializationSuccess = true ;
242
+ } else {
243
+ // nothing to do if we are validating internally, dxcompiler.dll
244
+ // is loaded and it'll take care of validation.
245
+ // No external dxil.dll will be loaded in this case
246
+ ExternalDxilDLLInitializationSuccess = false ;
237
247
}
238
- // nothing to do if we are validating internally, dxcompiler.dll
239
- // is loaded and it'll take care of validation.
240
- return InitializationSuccess;
248
+ return S_OK;
241
249
}
242
250
243
251
std::string GetDxilDLLPathExt () { return DxilDLLPathExt; }
0 commit comments