Skip to content

Commit c274e5b

Browse files
committed
remove wstring for simplicity
1 parent 98b25af commit c274e5b

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

include/dxc/Support/dxcapi.extval.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ class DxcDllExtValidationSupport : public dxc::DxcDllSupport {
88
protected:
99
dxc::DxcDllSupport DxilSupport;
1010

11-
std::wstring DxilDllPath;
11+
std::string DxilDllPath;
1212

1313
// override DxcDllSupport's implementation of InitializeInternal,
1414
// adding the environment variable value check for a path to a dxil.dll
1515
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName) override;
1616

1717
public:
18-
std::wstring GetDxilDllPath() { return DxilDllPath; }
18+
std::string GetDxilDllPath() { return DxilDllPath; }
1919
bool DxilDllFailedToLoad() {
2020
return !DxilDllPath.empty() && !DxilSupport.IsEnabled();
2121
}

lib/DxcSupport/dxcapi.extval.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
#include <dxc/Support/Global.h> // for hresult handling with DXC_FAILED
33
#include <filesystem> // C++17 and later
44
// WinIncludes must come before dxcapi.extval.h
5-
#include "dxc/Support/Unicode.h" // for wstring conversions like WideToUtf8String
65
#include "dxc/Support/dxcapi.extval.h"
7-
#include <wchar.h> // for _wgetenv
86

97
HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR dllName,
108
LPCSTR fnName) {
@@ -16,17 +14,14 @@ HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR dllName,
1614
}
1715

1816
// now handle external dxil.dll
19-
const wchar_t *EnvVarValue = _wgetenv(L"DXC_DXIL_DLL_PATH");
20-
if (!EnvVarValue || std::wstring(EnvVarValue).empty()) {
17+
const char *EnvVarVal = std::getenv("DXC_DXIL_DLL_PATH");
18+
if (!EnvVarVal || std::string(EnvVarVal).empty()) {
2119
return S_OK;
2220
}
2321

24-
std::wstring DllPathWStr(EnvVarValue);
25-
std::string DllPathStr;
26-
Unicode::WideToUTF8String(DllPathWStr.data(), &DllPathStr);
27-
28-
DxilDllPath = DllPathWStr;
29-
std::filesystem::path DllPath(DllPathWStr);
22+
std::string DllPathStr(EnvVarVal);
23+
DxilDllPath = DllPathStr;
24+
std::filesystem::path DllPath(DllPathStr);
3025

3126
// Check if path is absolute and exists
3227
if (!DllPath.is_absolute() || !std::filesystem::exists(DllPath)) {
@@ -36,7 +31,6 @@ HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR dllName,
3631
// to see if dxil.dll is successfully loaded.
3732
// the CheckDxilDLLLoaded function can determine whether there were any
3833
// problems loading dxil.dll or not
39-
4034
DxilSupport.InitializeForDll(DllPathStr.data(), fnName);
4135

4236
return S_OK;

tools/clang/unittests/HLSL/ValidationTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,7 +4268,7 @@ TEST_F(ValidationTest, UnitTestExtValidationSupport) {
42684268
VERIFY_SUCCEEDED(ExtSupportEmpty.Initialize());
42694269

42704270
VERIFY_IS_FALSE(ExtSupportEmpty.DxilDllFailedToLoad());
4271-
VERIFY_ARE_EQUAL_WSTR(ExtSupportEmpty.GetDxilDllPath().c_str(), L"");
4271+
VERIFY_ARE_EQUAL_STR(ExtSupportEmpty.GetDxilDllPath().c_str(), "");
42724272

42734273
// 2. Test with a bogus path in the environment variable
42744274
SetEnvVarW(L"DXC_DXIL_DLL_PATH", L"bogus");
@@ -4279,7 +4279,7 @@ TEST_F(ValidationTest, UnitTestExtValidationSupport) {
42794279

42804280
// validate that m_dllExtSupport2 was able to capture the environment
42814281
// variable's value, and that loading the bogus path was unsuccessful
4282-
VERIFY_ARE_EQUAL_WSTR(ExtSupportBogus.GetDxilDllPath().c_str(), L"bogus");
4282+
VERIFY_ARE_EQUAL_STR(ExtSupportBogus.GetDxilDllPath().c_str(), "bogus");
42834283
VERIFY_IS_TRUE(ExtSupportBogus.DxilDllFailedToLoad());
42844284

42854285
// 3. Test production of class IDs CLSID_DxcCompiler, CLSID_DxcLinker,

0 commit comments

Comments
 (0)