Skip to content

Commit 65f1df4

Browse files
committed
self review
1 parent 1b3ee58 commit 65f1df4

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

include/dxc/Support/HLSLOptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ class DxcOpts {
218218
bool ResMayAlias = false; // OPT_res_may_alias
219219
unsigned long ValVerMajor = UINT_MAX,
220220
ValVerMinor = UINT_MAX; // OPT_validator_version
221-
std::string DxilDLLPath = ""; // OPT_dxil_dll_path
222221
unsigned ScanLimit = 0; // OPT_memdep_block_scan_limit
223222
bool ForceZeroStoreLifetimes = false; // OPT_force_zero_store_lifetimes
224223
bool EnableLifetimeMarkers = false; // OPT_enable_lifetime_markers

include/dxc/Support/dxcapi.use.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,28 @@ void WriteOperationResultToConsole(IDxcOperationResult *pRewriteResult,
194194
bool outputWarnings);
195195

196196
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
199200
DxcDllSupport *m_DxilSupport = nullptr;
200201

201202
std::string DxilDLLPathExt = "";
202-
bool InitializationSuccess = false;
203+
bool ExternalDxilDLLInitializationSuccess = false;
203204
// override DxcDllSupport's implementation of InitializeInternal,
204205
// adding the environment variable value check for a path to a dxil.dll
205206
// for external validation
206207
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName){
207208

208209
// 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) {
212215
return result;
213216
}
214217

215-
// now handle internal or external dxil.dll
218+
// now handle external dxil.dll
216219
const char *envVal = std::getenv("DXC_DXIL_DLL_PATH");
217220
bool ValidateInternally = false;
218221
if (!envVal || std::string(envVal).empty()) {
@@ -226,18 +229,23 @@ class DxcDllExtValidationSupport : public DxcDllSupport {
226229

227230
// Check if path is absolute and exists
228231
if (!DllPath.is_absolute() || !std::filesystem::exists(DllPath)) {
229-
InitializationSuccess = false;
232+
ExternalDxilDLLInitializationSuccess = false;
230233
// TODO: Ideally emit some diagnostic that the given absolute path doesn't exist
231234
return HRESULT_FROM_WIN32(GetLastError());
232235
}
233236
result = m_DxilSupport->InitializeForDll(DllPathStr.data(), fnName);
234237
if (DXC_FAILED(result)) {
235-
InitializationSuccess = false;
238+
ExternalDxilDLLInitializationSuccess = false;
239+
return result;
236240
}
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;
237247
}
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;
241249
}
242250

243251
std::string GetDxilDLLPathExt() { return DxilDLLPathExt; }

tools/clang/tools/dxclib/dxc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ int dxc::main(int argc, const char **argv_) {
14481448
SetUnhandledExceptionFilter(ExceptionFilter);
14491449
#endif
14501450

1451+
// Setup a helper DLL.
14511452
{
14521453
std::string dllErrorString;
14531454
llvm::raw_string_ostream dllErrorStream(dllErrorString);

tools/clang/tools/dxcompiler/dxcapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ HRESULT CreateDxcContainerBuilder(REFIID riid, _Out_ LPVOID *ppv) {
6161
*ppv = nullptr;
6262
const char *warning;
6363
HRESULT hr = DxilLibCreateInstance(CLSID_DxcContainerBuilder,
64-
(IDxcContainerBuilder **)ppv);
64+
(IDxcContainerBuilder **)ppv);
6565
if (FAILED(hr)) {
6666
warning = "Unable to create container builder from dxil.dll. Resulting "
6767
"container will not be signed.\n";

tools/clang/tools/dxcompiler/dxcutil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ bool CreateValidator(CComPtr<IDxcValidator> &pValidator) {
6060
return true;
6161
}
6262

63-
// otherwise, use the external validator provided by the dxil_dll_path
64-
// argument
63+
// otherwise, use the external validator provided by
64+
// the environment variable
6565
else {
6666
// this code loads the dll path on an as-needed basis.
6767
// if a request to initialize the dxil lib arrives more than once

0 commit comments

Comments
 (0)