Skip to content

Commit 09be489

Browse files
committed
address Damyan
1 parent 15fceac commit 09be489

File tree

8 files changed

+21
-28
lines changed

8 files changed

+21
-28
lines changed

include/dxc/Support/HLSLOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ int ReadDxcOpts(const llvm::opt::OptTable *optionTable, unsigned flagsToInclude,
306306
llvm::raw_ostream &errors);
307307

308308
/// Sets up the specified DllLoader instance as per the given options.
309-
int SetupDllLoader(const DxcOpts &opts, dxc::DllLoader &dxcSupport,
309+
int SetupDllLoader(const DxcOpts &opts, dxc::SpecificDllLoader &dxcSupport,
310310
llvm::raw_ostream &errors);
311311

312312
void CopyArgsToWStrings(const llvm::opt::InputArgList &inArgs,

include/dxc/Support/dxcapi.extval.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,19 @@ class DxcDllExtValidationLoader : public DllLoader {
3030
to satisfy the IDllLoader interface. The parameter is ignored
3131
because the relevant dlls are specific and known: dxcompiler.dll
3232
and dxil.dll. This class is not designed to handle any other dlls */
33-
HRESULT OverrideDll(LPCSTR dll, LPCSTR entryPoint) override {
33+
HRESULT OverrideDll(LPCSTR dll, LPCSTR entryPoint) {
3434
return InitializeInternal(entryPoint);
3535
}
3636

37-
bool HasCreateWithMalloc() const override {
37+
bool HasCreateWithMalloc() const {
3838
assert(DxCompilerSupport.HasCreateWithMalloc() &&
3939
DxilExtValSupport.HasCreateWithMalloc());
4040
return true;
4141
}
4242

4343
bool IsEnabled() const override { return DxCompilerSupport.IsEnabled(); }
4444

45-
void Cleanup() {
46-
DxilExtValSupport.Cleanup();
47-
DxCompilerSupport.Cleanup();
48-
}
49-
50-
HMODULE Detach() override {
45+
HMODULE Detach() {
5146
// Can't Detach and return a handle for DxilSupport. Cleanup() instead.
5247
DxilExtValSupport.Cleanup();
5348
return DxCompilerSupport.Detach();

include/dxc/Support/dxcapi.use.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ extern const char *kDxilLib;
2121

2222
// Interface for common dll operations
2323
class DllLoader {
24-
public:
25-
virtual HRESULT OverrideDll(LPCSTR dll, LPCSTR entryPoint) = 0;
26-
DllLoader() = default;
27-
DllLoader(const DllLoader &) = delete;
28-
DllLoader(DllLoader &&) = delete;
2924

3025
protected:
3126
virtual HRESULT CreateInstanceImpl(REFCLSID clsid, REFIID riid,
3227
IUnknown **pResult) = 0;
3328
virtual HRESULT CreateInstance2Impl(IMalloc *pMalloc, REFCLSID clsid,
3429
REFIID riid, IUnknown **pResult) = 0;
30+
virtual ~DllLoader() {}
3531

3632
public:
33+
DllLoader() = default;
34+
DllLoader(const DllLoader &) = delete;
35+
DllLoader(DllLoader &&) = delete;
36+
3737
template <typename TInterface>
3838
HRESULT CreateInstance(REFCLSID clsid, TInterface **pResult) {
3939
return CreateInstanceImpl(clsid, __uuidof(TInterface),
@@ -54,11 +54,7 @@ class DllLoader {
5454
return CreateInstance2Impl(pMalloc, clsid, riid, (IUnknown **)pResult);
5555
}
5656

57-
virtual bool HasCreateWithMalloc() const = 0;
58-
5957
virtual bool IsEnabled() const = 0;
60-
61-
virtual HMODULE Detach() = 0;
6258
};
6359

6460
// Helper class to dynamically load the dxcompiler or a compatible libraries.
@@ -128,13 +124,13 @@ class SpecificDllLoader : public DllLoader {
128124
other.m_createFn2 = nullptr;
129125
}
130126

131-
virtual ~SpecificDllLoader() { Cleanup(); }
127+
~SpecificDllLoader() override { Cleanup(); }
132128

133129
HRESULT Initialize() {
134130
return InitializeInternal(kDxCompilerLib, "DxcCreateInstance");
135131
}
136132

137-
HRESULT OverrideDll(LPCSTR dll, LPCSTR entryPoint) override {
133+
HRESULT OverrideDll(LPCSTR dll, LPCSTR entryPoint) {
138134
return InitializeInternal(dll, entryPoint);
139135
}
140136

@@ -166,7 +162,7 @@ class SpecificDllLoader : public DllLoader {
166162
return hr;
167163
}
168164

169-
bool HasCreateWithMalloc() const override { return m_createFn2 != nullptr; }
165+
bool HasCreateWithMalloc() const { return m_createFn2 != nullptr; }
170166

171167
bool IsEnabled() const override { return m_dll != nullptr; }
172168

@@ -192,7 +188,7 @@ class SpecificDllLoader : public DllLoader {
192188
}
193189
}
194190

195-
HMODULE Detach() override {
191+
HMODULE Detach() {
196192
HMODULE hModule = m_dll;
197193
m_dll = nullptr;
198194
return hModule;
@@ -209,7 +205,7 @@ inline DxcDefine GetDefine(LPCWSTR name, LPCWSTR value) {
209205
// Checks an HRESULT and formats an error message with the appended data.
210206
void IFT_Data(HRESULT hr, LPCWSTR data);
211207

212-
void EnsureEnabled(DllLoader &dxcSupport);
208+
void EnsureEnabled(SpecificDllLoader &dxcSupport);
213209
void ReadFileIntoBlob(DllLoader &dxcSupport, LPCWSTR pFileName,
214210
IDxcBlobEncoding **ppBlobEncoding);
215211
void WriteBlobToConsole(IDxcBlob *pBlob, DWORD streamType = STD_OUTPUT_HANDLE);

include/dxc/Test/DxcTestUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ bool CheckNotMsgs(const LPCSTR pText, size_t TextCount,
197197
const LPCSTR *pErrorMsgs, size_t errorMsgCount, bool bRegex);
198198
void GetDxilPart(dxc::DllLoader &dllSupport, IDxcBlob *pProgram,
199199
IDxcBlob **pDxilPart);
200-
std::string DisassembleProgram(dxc::DllLoader &dllSupport, IDxcBlob *pProgram);
200+
std::string DisassembleProgram(dxc::SpecificDllLoader &dllSupport,
201+
IDxcBlob *pProgram);
201202
void SplitPassList(LPWSTR pPassesBuffer, std::vector<LPCWSTR> &passes);
202203
void MultiByteStringToBlob(dxc::DllLoader &dllSupport, const std::string &val,
203204
UINT32 codePoint, IDxcBlob **ppBlob);

lib/DxcSupport/HLSLOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
13841384
}
13851385

13861386
/// Sets up the specified DllLoader instance as per the given options.
1387-
int SetupDllLoader(const DxcOpts &opts, dxc::DllLoader &dxcSupport,
1387+
int SetupDllLoader(const DxcOpts &opts, dxc::SpecificDllLoader &dxcSupport,
13881388
llvm::raw_ostream &errors) {
13891389
if (!opts.ExternalLib.empty()) {
13901390
DXASSERT(!opts.ExternalFn.empty(), "else ReadDxcOpts should have failed");

lib/DxcSupport/dxcapi.use.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void IFT_Data(HRESULT hr, LPCWSTR data) {
7373
throw ::hlsl::Exception(hr, errMsg);
7474
}
7575

76-
void EnsureEnabled(DllLoader &dxcSupport) {
76+
void EnsureEnabled(SpecificDllLoader &dxcSupport) {
7777
if (!dxcSupport.IsEnabled()) {
7878
IFT(dxcSupport.OverrideDll(kDxCompilerLib, "DxcCreateInstance"));
7979
}

tools/clang/unittests/HLSLExec/HlslExecTestUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static bool createDevice(ID3D12Device **D3DDevice,
228228
}
229229

230230
inline void readHlslDataIntoNewStream(LPCWSTR RelativePath, IStream **Stream,
231-
dxc::DllLoader &Support) {
231+
dxc::SpecificDllLoader &Support) {
232232
VERIFY_SUCCEEDED(
233233
Support.OverrideDll(dxc::kDxCompilerLib, "DxcCreateInstance"));
234234
CComPtr<IDxcLibrary> Library;

tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ bool CheckOperationResultMsgs(IDxcOperationResult *pResult,
181181
maySucceedAnyway, bRegex);
182182
}
183183

184-
std::string DisassembleProgram(dxc::DllLoader &dllSupport, IDxcBlob *pProgram) {
184+
std::string DisassembleProgram(dxc::SpecificDllLoader &dllSupport,
185+
IDxcBlob *pProgram) {
185186
CComPtr<IDxcCompiler> pCompiler;
186187
CComPtr<IDxcBlobEncoding> pDisassembly;
187188

0 commit comments

Comments
 (0)