Skip to content

Commit 3823a40

Browse files
committed
stage 1+2 done!
1 parent c14454c commit 3823a40

2 files changed

Lines changed: 45 additions & 34 deletions

File tree

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,20 @@
11
#include "dxc/Support/dxcapi.use.h"
22
#include "dxc/dxcapi.h"
33

4-
using dxc::DxcDllSupport;
5-
6-
class DxcDllExtValidationSupport : public DxcDllSupport {
4+
class DxcDllExtValidationSupport : public dxc::DxcDllSupport {
75
// DxcDllExtValidationSupport manages the
86
// lifetime of dxcompiler.dll, while the member, m_DxilSupport,
97
// manages the lifetime of dxil.dll
10-
DxcDllSupport m_DxilSupport;
8+
dxc::DxcDllSupport m_DxilSupport;
119

1210
std::string DxilDllPath;
1311
// override DxcDllSupport's implementation of InitializeInternal,
1412
// adding the environment variable value check for a path to a dxil.dll
15-
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName);
1613

1714
std::string GetDxilDLLPathExt() { return DxilDllPath; }
1815
bool DxilDllSuccessfullyLoaded() {
1916
return !DxilDllPath.empty() && !m_DxilSupport.IsEnabled();
2017
}
2118

22-
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName) {
23-
// Load dxcompiler.dll
24-
HRESULT result = InitializeForDll(dllName, fnName);
25-
// if dxcompiler.dll fails to load, then we won't try loading dxil.dll,
26-
// so set this boolean to false.
27-
28-
// now handle external dxil.dll
29-
const char *envVal = std::getenv("DXC_DXIL_DLL_PATH");
30-
bool ValidateInternally = false;
31-
if (!envVal || std::string(envVal).empty()) {
32-
return S_OK;
33-
}
34-
35-
std::string DllPathStr(envVal);
36-
DxilDllPath = DllPathStr;
37-
std::filesystem::path DllPath(DllPathStr);
38-
39-
// Check if path is absolute and exists
40-
if (!DllPath.is_absolute() || !std::filesystem::exists(DllPath)) {
41-
return S_OK;
42-
}
43-
// code that calls this function is responsible for checking
44-
// to see if dxil.dll is successfully loaded.
45-
// the CheckDxilDLLLoaded function can determine whether there were any
46-
// problems loading dxil.dll or not
47-
m_DxilSupport.InitializeForDll(DllPathStr.data(), fnName);
48-
49-
return S_OK;
50-
}
19+
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName);
5120
};

lib/DxcSupport/dxcapi.extval.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1+
#include "dxc/Support/WinIncludes.h"
12

3+
#include "dxc/Support/dxcapi.use.h"
4+
5+
#include "dxc/Support/FileIOHelper.h"
6+
#include "dxc/Support/Global.h"
7+
#include "dxc/Support/SharedLibAffix.h" // header generated during DXC build
8+
#include "dxc/Support/Unicode.h"
9+
#include "dxc/Support/WinFunctions.h"
10+
11+
#include "dxc/Support/dxcapi.extval.h"
12+
13+
HRESULT DxcDllExtValidationSupport::InitializeInternal(LPCSTR dllName,
14+
LPCSTR fnName) {
15+
// Load dxcompiler.dll
16+
HRESULT result = InitializeForDll(dllName, fnName);
17+
// if dxcompiler.dll fails to load, return the failed HRESULT
18+
if (DXC_FAILED(result)) {
19+
return result;
20+
}
21+
22+
// now handle external dxil.dll
23+
const char *envVal = std::getenv("DXC_DXIL_DLL_PATH");
24+
if (!envVal || std::string(envVal).empty()) {
25+
return S_OK;
26+
}
27+
28+
std::string DllPathStr(envVal);
29+
DxilDllPath = DllPathStr;
30+
std::filesystem::path DllPath(DllPathStr);
31+
32+
// Check if path is absolute and exists
33+
if (!DllPath.is_absolute() || !std::filesystem::exists(DllPath)) {
34+
return S_OK;
35+
}
36+
// code that calls this function is responsible for checking
37+
// to see if dxil.dll is successfully loaded.
38+
// the CheckDxilDLLLoaded function can determine whether there were any
39+
// problems loading dxil.dll or not
40+
m_DxilSupport.InitializeForDll(DllPathStr.data(), fnName);
41+
42+
return S_OK;
43+
}

0 commit comments

Comments
 (0)