Skip to content

Commit a144ca1

Browse files
committed
address Damyan final concerns
1 parent bfc508f commit a144ca1

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

include/dxc/Support/dxcapi.extval.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DxcDllExtValidationSupport {
1010
dxc::DxcDllSupport DxilExtValSupport;
1111

1212
std::string DxilDllPath;
13-
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName);
13+
HRESULT InitializeInternal(LPCSTR fnName);
1414

1515
public:
1616
std::string GetDxilDllPath() { return DxilDllPath; }
@@ -33,9 +33,7 @@ class DxcDllExtValidationSupport {
3333
HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, REFIID riid,
3434
IUnknown **pResult);
3535

36-
HRESULT Initialize() {
37-
return InitializeInternal(kDxCompilerLib, "DxcCreateInstance");
38-
}
36+
HRESULT Initialize() { return InitializeInternal("DxcCreateInstance"); }
3937

4038
bool IsEnabled() const { return DxcompilerSupport.IsEnabled(); }
4139
};

lib/DxcSupport/dxcapi.extval.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ HRESULT DxcDllExtValidationSupport::CreateInstance2(IMalloc *pMalloc,
2323
return DxcompilerSupport.CreateInstance2(pMalloc, clsid, riid, pResult);
2424
}
2525

26-
HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR dllName,
27-
LPCSTR fnName) {
26+
HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR fnName) {
2827
// Load dxcompiler.dll
29-
HRESULT Result = DxcompilerSupport.InitializeForDll(dllName, fnName);
28+
HRESULT Result = DxcompilerSupport.InitializeForDll(kDxCompilerLib, fnName);
3029
// if dxcompiler.dll fails to load, return the failed HRESULT
3130
if (DXC_FAILED(Result)) {
3231
return Result;
@@ -38,21 +37,19 @@ HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR dllName,
3837
return S_OK;
3938
}
4039

41-
std::string DllPathStr(EnvVarVal);
42-
DxilDllPath = DllPathStr;
43-
std::filesystem::path DllPath(DllPathStr);
40+
DxilDllPath = std::string(EnvVarVal);
41+
std::filesystem::path DllPath(DxilDllPath);
4442

4543
// Check if path is absolute and exists
4644
if (!DllPath.is_absolute() || !std::filesystem::exists(DllPath)) {
47-
return S_OK;
45+
return ERROR_DLL_INIT_FAILED;
4846
}
4947
// code that calls this function is responsible for checking
5048
// to see if dxil.dll is successfully loaded.
51-
// the CheckDxilDLLLoaded function can determine whether there were any
49+
// the DxilDllFailedToLoad function can determine whether there were any
5250
// problems loading dxil.dll or not
53-
DxilExtValSupport.InitializeForDll(DllPathStr.data(), fnName);
5451

55-
return S_OK;
52+
return DxilExtValSupport.InitializeForDll(DxilDllPath.c_str(), fnName);
5653
}
5754

5855
} // namespace dxc

tools/clang/unittests/HLSL/ValidationTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "llvm/ADT/ArrayRef.h"
2626
#include "llvm/ADT/StringRef.h"
2727
#include "llvm/Support/Regex.h"
28-
#include <cstdlib> // for setenv(), getenv(), unsetenv()
2928
#include <wchar.h> // for _wgetenv
3029

3130
#ifdef _WIN32
@@ -4281,11 +4280,12 @@ TEST_F(ValidationTest, UnitTestExtValidationSupport) {
42814280
VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance(
42824281
CLSID_DxcValidator, __uuidof(IDxcValidator), (IUnknown **)&Validator));
42834282

4284-
CComPtr<IMalloc> Malloc;
4285-
CComPtr<IDxcCompiler2> Compiler2;
42864283
Linker.Release();
42874284
Validator.Release();
42884285
Compiler.Release();
4286+
4287+
CComPtr<IMalloc> Malloc;
4288+
CComPtr<IDxcCompiler2> Compiler2;
42894289
VERIFY_SUCCEEDED(DxcCoGetMalloc(1, &Malloc));
42904290
VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance2(Malloc, CLSID_DxcCompiler,
42914291
__uuidof(IDxcCompiler),

0 commit comments

Comments
 (0)