diff --git a/include/dxc/Support/HLSLOptions.h b/include/dxc/Support/HLSLOptions.h index 31ca3d1c14..4a6868956a 100644 --- a/include/dxc/Support/HLSLOptions.h +++ b/include/dxc/Support/HLSLOptions.h @@ -36,7 +36,7 @@ class raw_ostream; } // namespace llvm namespace dxc { -class DxcDllSupport; +class SpecificDllLoader; } namespace hlsl { @@ -304,9 +304,10 @@ int ReadDxcOpts(const llvm::opt::OptTable *optionTable, unsigned flagsToInclude, const MainArgs &argStrings, DxcOpts &opts, llvm::raw_ostream &errors); -/// Sets up the specified DxcDllSupport instance as per the given options. -int SetupDxcDllSupport(const DxcOpts &opts, dxc::DxcDllSupport &dxcSupport, - llvm::raw_ostream &errors); +/// Sets up a SpecificDllLoader instance as per the given options. +int SetupSpecificDllLoader(const DxcOpts &opts, + dxc::SpecificDllLoader &dxcSupport, + llvm::raw_ostream &errors); void CopyArgsToWStrings(const llvm::opt::InputArgList &inArgs, unsigned flagsToInclude, diff --git a/include/dxc/Support/dxcapi.extval.h b/include/dxc/Support/dxcapi.extval.h new file mode 100644 index 0000000000..e479c9cce1 --- /dev/null +++ b/include/dxc/Support/dxcapi.extval.h @@ -0,0 +1,29 @@ +#include "dxc/Support/dxcapi.use.h" +#include +#include + +namespace dxc { +class DxcDllExtValidationLoader : public DllLoader { + // DxCompilerSupport manages the + // lifetime of dxcompiler.dll, while DxilExtValSupport + // manages the lifetime of dxil.dll + dxc::SpecificDllLoader DxCompilerSupport; + dxc::SpecificDllLoader DxilExtValSupport; + std::string DxilDllPath; + +public: + std::string GetDxilDllPath() { return DxilDllPath; } + bool DxilDllFailedToLoad() { + return !DxilDllPath.empty() && !DxilExtValSupport.IsEnabled(); + } + + HRESULT CreateInstanceImpl(REFCLSID clsid, REFIID riid, + IUnknown **pResult) override; + HRESULT CreateInstance2Impl(IMalloc *pMalloc, REFCLSID clsid, REFIID riid, + IUnknown **pResult) override; + + HRESULT Initialize(); + + bool IsEnabled() const override { return DxCompilerSupport.IsEnabled(); } +}; +} // namespace dxc diff --git a/include/dxc/Support/dxcapi.use.h b/include/dxc/Support/dxcapi.use.h index 44fe23bad6..2a3c350dd8 100644 --- a/include/dxc/Support/dxcapi.use.h +++ b/include/dxc/Support/dxcapi.use.h @@ -19,9 +19,47 @@ namespace dxc { extern const char *kDxCompilerLib; extern const char *kDxilLib; -// Helper class to dynamically load the dxcompiler or a compatible libraries. -class DxcDllSupport { +// Interface for common dll operations +class DllLoader { + protected: + virtual HRESULT CreateInstanceImpl(REFCLSID clsid, REFIID riid, + IUnknown **pResult) = 0; + virtual HRESULT CreateInstance2Impl(IMalloc *pMalloc, REFCLSID clsid, + REFIID riid, IUnknown **pResult) = 0; + virtual ~DllLoader() {} + +public: + DllLoader() = default; + DllLoader(const DllLoader &) = delete; + DllLoader(DllLoader &&) = delete; + + template + HRESULT CreateInstance(REFCLSID clsid, TInterface **pResult) { + return CreateInstanceImpl(clsid, __uuidof(TInterface), + (IUnknown **)pResult); + } + HRESULT CreateInstance(REFCLSID clsid, REFIID riid, IUnknown **pResult) { + return CreateInstanceImpl(clsid, riid, (IUnknown **)pResult); + } + + template + HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, + TInterface **pResult) { + return CreateInstance2Impl(pMalloc, clsid, __uuidof(TInterface), + (IUnknown **)pResult); + } + HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, REFIID riid, + IUnknown **pResult) { + return CreateInstance2Impl(pMalloc, clsid, riid, (IUnknown **)pResult); + } + + virtual bool IsEnabled() const = 0; +}; + +// Helper class to dynamically load the dxcompiler or a compatible libraries. +class SpecificDllLoader : public DllLoader { + HMODULE m_dll; DxcCreateInstanceProc m_createFn; DxcCreateInstance2Proc m_createFn2; @@ -74,33 +112,19 @@ class DxcDllSupport { } public: - DxcDllSupport() : m_dll(nullptr), m_createFn(nullptr), m_createFn2(nullptr) {} - - DxcDllSupport(DxcDllSupport &&other) { - m_dll = other.m_dll; - other.m_dll = nullptr; - m_createFn = other.m_createFn; - other.m_createFn = nullptr; - m_createFn2 = other.m_createFn2; - other.m_createFn2 = nullptr; - } + SpecificDllLoader() + : m_dll(nullptr), m_createFn(nullptr), m_createFn2(nullptr) {} - ~DxcDllSupport() { Cleanup(); } - - HRESULT Initialize() { - return InitializeInternal(kDxCompilerLib, "DxcCreateInstance"); - } + ~SpecificDllLoader() override { Cleanup(); } HRESULT InitializeForDll(LPCSTR dll, LPCSTR entryPoint) { return InitializeInternal(dll, entryPoint); } - template - HRESULT CreateInstance(REFCLSID clsid, TInterface **pResult) { - return CreateInstance(clsid, __uuidof(TInterface), (IUnknown **)pResult); - } - - HRESULT CreateInstance(REFCLSID clsid, REFIID riid, IUnknown **pResult) { + // Also bring visibility into the interface definition of this function + // which takes 2 args + HRESULT CreateInstanceImpl(REFCLSID clsid, REFIID riid, + IUnknown **pResult) override { if (pResult == nullptr) return E_POINTER; if (m_dll == nullptr) @@ -109,15 +133,10 @@ class DxcDllSupport { return hr; } - template - HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, - TInterface **pResult) { - return CreateInstance2(pMalloc, clsid, __uuidof(TInterface), - (IUnknown **)pResult); - } - - HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, REFIID riid, - IUnknown **pResult) { + // Also bring visibility into the interface definition of this function + // which takes 3 args + HRESULT CreateInstance2Impl(IMalloc *pMalloc, REFCLSID clsid, REFIID riid, + IUnknown **pResult) override { if (pResult == nullptr) return E_POINTER; if (m_dll == nullptr) @@ -130,7 +149,16 @@ class DxcDllSupport { bool HasCreateWithMalloc() const { return m_createFn2 != nullptr; } - bool IsEnabled() const { return m_dll != nullptr; } + bool IsEnabled() const override { return m_dll != nullptr; } + + bool GetCreateInstanceProcs(DxcCreateInstanceProc *pCreateFn, + DxcCreateInstance2Proc *pCreateFn2) const { + if (pCreateFn == nullptr || pCreateFn2 == nullptr || m_createFn == nullptr) + return false; + *pCreateFn = m_createFn; + *pCreateFn2 = m_createFn2; + return true; + } void Cleanup() { if (m_dll != nullptr) { @@ -152,6 +180,26 @@ class DxcDllSupport { } }; +// This class is for instances where we *only* expect +// to load dxcompiler.dll, and nothing else +class DxCompilerDllLoader : public SpecificDllLoader { +public: + HRESULT Initialize() { + return InitializeForDll(kDxCompilerLib, "DxcCreateInstance"); + } +}; + +// This class is for instances where we want to load a +// subset of any dlls that would give DxcLibrary functionality. +// e.g, load a IDxcLibrary object. +// Includes but isn't limited to dxcompiler.dll and dxil.dll +class LibraryDllLoader : public SpecificDllLoader { +public: + HRESULT Initialize() { + return InitializeForDll(kDxCompilerLib, "DxcCreateInstance"); + } +}; + inline DxcDefine GetDefine(LPCWSTR name, LPCWSTR value) { DxcDefine result; result.Name = name; @@ -162,8 +210,8 @@ inline DxcDefine GetDefine(LPCWSTR name, LPCWSTR value) { // Checks an HRESULT and formats an error message with the appended data. void IFT_Data(HRESULT hr, LPCWSTR data); -void EnsureEnabled(DxcDllSupport &dxcSupport); -void ReadFileIntoBlob(DxcDllSupport &dxcSupport, LPCWSTR pFileName, +void EnsureEnabled(LibraryDllLoader &dxcSupport); +void ReadFileIntoBlob(DllLoader &dxcSupport, LPCWSTR pFileName, IDxcBlobEncoding **ppBlobEncoding); void WriteBlobToConsole(IDxcBlob *pBlob, DWORD streamType = STD_OUTPUT_HANDLE); void WriteBlobToFile(IDxcBlob *pBlob, LPCWSTR pFileName, UINT32 textCodePage); diff --git a/include/dxc/Test/CompilationResult.h b/include/dxc/Test/CompilationResult.h index 1d1272b379..03a2a14bc4 100644 --- a/include/dxc/Test/CompilationResult.h +++ b/include/dxc/Test/CompilationResult.h @@ -101,11 +101,9 @@ class TrivialDxcUnsavedFile : public IDxcUnsavedFile { } }; -class HlslIntellisenseSupport : public dxc::DxcDllSupport { +class HlslIntellisenseSupport : public dxc::DxCompilerDllLoader { public: HlslIntellisenseSupport() {} - HlslIntellisenseSupport(HlslIntellisenseSupport &&other) - : dxc::DxcDllSupport(std::move(other)) {} HRESULT CreateIntellisense(IDxcIntelliSense **pResult) { return CreateInstance(CLSID_DxcIntelliSense, pResult); diff --git a/include/dxc/Test/DxcTestUtils.h b/include/dxc/Test/DxcTestUtils.h index 79ab49ee9a..f1face7194 100644 --- a/include/dxc/Test/DxcTestUtils.h +++ b/include/dxc/Test/DxcTestUtils.h @@ -109,11 +109,11 @@ class FileRunCommandPart { FileRunCommandPart(const FileRunCommandPart &) = default; FileRunCommandPart(FileRunCommandPart &&) = default; - FileRunCommandResult Run(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult Run(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior, PluginToolsPaths *pPluginToolsPaths = nullptr, LPCWSTR dumpName = nullptr); - FileRunCommandResult RunHashTests(dxc::DxcDllSupport &DllSupport); + FileRunCommandResult RunHashTests(dxc::DllLoader &DllSupport); FileRunCommandResult ReadOptsForDxc(hlsl::options::MainArgs &argStrings, hlsl::options::DxcOpts &Opts, @@ -127,30 +127,30 @@ class FileRunCommandPart { private: FileRunCommandResult RunFileChecker(const FileRunCommandResult *Prior, LPCWSTR dumpName = nullptr); - FileRunCommandResult RunDxc(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunDxc(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunDxv(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunDxv(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunOpt(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunOpt(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunListParts(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunListParts(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunD3DReflect(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunD3DReflect(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunDxr(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunDxr(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunLink(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunLink(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); FileRunCommandResult RunTee(const FileRunCommandResult *Prior); FileRunCommandResult RunXFail(const FileRunCommandResult *Prior); - FileRunCommandResult RunDxilVer(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunDxilVer(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); - FileRunCommandResult RunDxcHashTest(dxc::DxcDllSupport &DllSupport); + FileRunCommandResult RunDxcHashTest(dxc::DllLoader &DllSupport); FileRunCommandResult RunFromPath(const std::string &path, const FileRunCommandResult *Prior); FileRunCommandResult RunFileCompareText(const FileRunCommandResult *Prior); #ifdef _WIN32 - FileRunCommandResult RunFxc(dxc::DxcDllSupport &DllSupport, + FileRunCommandResult RunFxc(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior); #endif @@ -175,12 +175,12 @@ class FileRunTestResult { PluginToolsPaths *pPluginToolsPaths = nullptr, LPCWSTR dumpName = nullptr); static FileRunTestResult - RunFromFileCommands(LPCWSTR fileName, dxc::DxcDllSupport &dllSupport, + RunFromFileCommands(LPCWSTR fileName, dxc::DxCompilerDllLoader &dllSupport, PluginToolsPaths *pPluginToolsPaths = nullptr, LPCWSTR dumpName = nullptr); }; -void AssembleToContainer(dxc::DxcDllSupport &dllSupport, IDxcBlob *pModule, +void AssembleToContainer(dxc::DllLoader &dllSupport, IDxcBlob *pModule, IDxcBlob **pContainer); std::string BlobToUtf8(IDxcBlob *pBlob); std::wstring BlobToWide(IDxcBlob *pBlob); @@ -195,36 +195,34 @@ bool CheckMsgs(const LPCSTR pText, size_t TextCount, const LPCSTR *pErrorMsgs, size_t errorMsgCount, bool bRegex); bool CheckNotMsgs(const LPCSTR pText, size_t TextCount, const LPCSTR *pErrorMsgs, size_t errorMsgCount, bool bRegex); -void GetDxilPart(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram, +void GetDxilPart(dxc::DllLoader &dllSupport, IDxcBlob *pProgram, IDxcBlob **pDxilPart); -std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport, +std::string DisassembleProgram(dxc::DxCompilerDllLoader &dllSupport, IDxcBlob *pProgram); void SplitPassList(LPWSTR pPassesBuffer, std::vector &passes); -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, - const std::string &val, UINT32 codePoint, - IDxcBlob **ppBlob); -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, - const std::string &val, UINT32 codePoint, - IDxcBlobEncoding **ppBlob); -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, +void MultiByteStringToBlob(dxc::DllLoader &dllSupport, const std::string &val, + UINT32 codePoint, IDxcBlob **ppBlob); +void MultiByteStringToBlob(dxc::DllLoader &dllSupport, const std::string &val, + UINT32 codePoint, IDxcBlobEncoding **ppBlob); +void Utf8ToBlob(dxc::DllLoader &dllSupport, const std::string &val, IDxcBlob **ppBlob); -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, +void Utf8ToBlob(dxc::DllLoader &dllSupport, const std::string &val, IDxcBlobEncoding **ppBlob); -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, +void Utf8ToBlob(dxc::DllLoader &dllSupport, const char *pVal, IDxcBlobEncoding **ppBlob); -void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, +void WideToBlob(dxc::DllLoader &dllSupport, const std::wstring &val, IDxcBlob **ppBlob); -void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, +void WideToBlob(dxc::DllLoader &dllSupport, const std::wstring &val, IDxcBlobEncoding **ppBlob); -void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, +void VerifyCompileOK(dxc::DllLoader &dllSupport, LPCSTR pText, LPCWSTR pTargetProfile, LPCWSTR pArgs, IDxcBlob **ppResult); -void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, +void VerifyCompileOK(dxc::DllLoader &dllSupport, LPCSTR pText, LPCWSTR pTargetProfile, std::vector &args, IDxcBlob **ppResult); -HRESULT GetVersion(dxc::DxcDllSupport &DllSupport, REFCLSID clsid, - unsigned &Major, unsigned &Minor); +HRESULT GetVersion(dxc::DllLoader &DllSupport, REFCLSID clsid, unsigned &Major, + unsigned &Minor); bool ParseTargetProfile(llvm::StringRef targetProfile, llvm::StringRef &outStage, unsigned &outMajor, unsigned &outMinor); @@ -240,7 +238,7 @@ class VersionSupportInfo { VersionSupportInfo(); // Initialize version info structure. TODO: add device shader model support - void Initialize(dxc::DxcDllSupport &dllSupport); + void Initialize(dxc::DllLoader &dllSupport); // Return true if IR sensitive test should be skipped, and log comment bool SkipIRSensitiveTest(); // Return true if test requiring DXIL of given version should be skipped, and diff --git a/lib/DxcSupport/CMakeLists.txt b/lib/DxcSupport/CMakeLists.txt index dbc8ef0c26..96474bd620 100644 --- a/lib/DxcSupport/CMakeLists.txt +++ b/lib/DxcSupport/CMakeLists.txt @@ -10,6 +10,7 @@ add_llvm_library(LLVMDxcSupport WinAdapter.cpp WinIncludes.cpp WinFunctions.cpp + dxcapi.extval.cpp ) #generate header with platform-specific library name diff --git a/lib/DxcSupport/HLSLOptions.cpp b/lib/DxcSupport/HLSLOptions.cpp index b3eb422eb9..06e6a1bed6 100644 --- a/lib/DxcSupport/HLSLOptions.cpp +++ b/lib/DxcSupport/HLSLOptions.cpp @@ -1383,9 +1383,10 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude, return 0; } -/// Sets up the specified DxcDllSupport instance as per the given options. -int SetupDxcDllSupport(const DxcOpts &opts, dxc::DxcDllSupport &dxcSupport, - llvm::raw_ostream &errors) { +/// Sets up a SpecificDllLoader instance as per the given options. +int SetupSpecificDllLoader(const DxcOpts &opts, + dxc::SpecificDllLoader &dxcSupport, + llvm::raw_ostream &errors) { if (!opts.ExternalLib.empty()) { DXASSERT(!opts.ExternalFn.empty(), "else ReadDxcOpts should have failed"); HRESULT hrLoad = dxcSupport.InitializeForDll(opts.ExternalLib.data(), diff --git a/lib/DxcSupport/dxcapi.extval.cpp b/lib/DxcSupport/dxcapi.extval.cpp new file mode 100644 index 0000000000..699873cc3d --- /dev/null +++ b/lib/DxcSupport/dxcapi.extval.cpp @@ -0,0 +1,54 @@ +#include "dxc/Support/WinIncludes.h" +#include // for hresult handling with DXC_FAILED +#include // C++17 and later +// WinIncludes must come before dxcapi.extval.h +#include "dxc/Support/dxcapi.extval.h" + +namespace dxc { + +HRESULT DxcDllExtValidationLoader::CreateInstanceImpl(REFCLSID clsid, + REFIID riid, + IUnknown **pResult) { + if (DxilExtValSupport.IsEnabled() && clsid == CLSID_DxcValidator) + return DxilExtValSupport.CreateInstance(clsid, riid, pResult); + + return DxCompilerSupport.CreateInstance(clsid, riid, pResult); +} + +HRESULT DxcDllExtValidationLoader::CreateInstance2Impl(IMalloc *pMalloc, + REFCLSID clsid, + REFIID riid, + IUnknown **pResult) { + if (DxilExtValSupport.IsEnabled() && clsid == CLSID_DxcValidator) + return DxilExtValSupport.CreateInstance2(pMalloc, clsid, riid, pResult); + + return DxCompilerSupport.CreateInstance2(pMalloc, clsid, riid, pResult); +} + +HRESULT DxcDllExtValidationLoader::Initialize() { + // Load dxcompiler.dll + HRESULT Result = + DxCompilerSupport.InitializeForDll(kDxCompilerLib, "DxcCreateInstance"); + // if dxcompiler.dll fails to load, return the failed HRESULT + if (DXC_FAILED(Result)) { + return Result; + } + + // now handle external dxil.dll + const char *EnvVarVal = std::getenv("DXC_DXIL_DLL_PATH"); + if (!EnvVarVal || std::string(EnvVarVal).empty()) { + return S_OK; + } + + DxilDllPath = std::string(EnvVarVal); + std::filesystem::path DllPath(DxilDllPath); + + // Check if path is absolute and exists + if (!DllPath.is_absolute() || !std::filesystem::exists(DllPath)) { + return E_INVALIDARG; + } + + return DxilExtValSupport.InitializeForDll(DxilDllPath.c_str(), + "DxcCreateInstance"); +} +} // namespace dxc diff --git a/lib/DxcSupport/dxcapi.use.cpp b/lib/DxcSupport/dxcapi.use.cpp index 399259ef87..d6084f2334 100644 --- a/lib/DxcSupport/dxcapi.use.cpp +++ b/lib/DxcSupport/dxcapi.use.cpp @@ -73,13 +73,13 @@ void IFT_Data(HRESULT hr, LPCWSTR data) { throw ::hlsl::Exception(hr, errMsg); } -void EnsureEnabled(DxcDllSupport &dxcSupport) { +void EnsureEnabled(LibraryDllLoader &dxcSupport) { if (!dxcSupport.IsEnabled()) { - IFT(dxcSupport.Initialize()); + IFT(dxcSupport.InitializeForDll(kDxCompilerLib, "DxcCreateInstance")); } } -void ReadFileIntoBlob(DxcDllSupport &dxcSupport, LPCWSTR pFileName, +void ReadFileIntoBlob(DllLoader &dxcSupport, LPCWSTR pFileName, IDxcBlobEncoding **ppBlobEncoding) { CComPtr library; IFT(dxcSupport.CreateInstance(CLSID_DxcLibrary, &library)); diff --git a/projects/dxilconv/unittests/DxilConvTests.cpp b/projects/dxilconv/unittests/DxilConvTests.cpp index 6589647f73..c166abb7c8 100644 --- a/projects/dxilconv/unittests/DxilConvTests.cpp +++ b/projects/dxilconv/unittests/DxilConvTests.cpp @@ -67,7 +67,7 @@ class DxilConvTest { END_TEST_METHOD() private: - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; PluginToolsPaths m_TestToolPaths; void DxilConvTestCheckFile(LPCWSTR path) { diff --git a/tools/clang/lib/SPIRV/EmitVisitor.cpp b/tools/clang/lib/SPIRV/EmitVisitor.cpp index bf802ad208..1f7a9c5d3c 100644 --- a/tools/clang/lib/SPIRV/EmitVisitor.cpp +++ b/tools/clang/lib/SPIRV/EmitVisitor.cpp @@ -139,7 +139,7 @@ ReadSourceCode(llvm::StringRef filePath, std::string localFilePath(filePath.begin(), filePath.end()); try { - dxc::DxcDllSupport dllSupport; + dxc::DxCompilerDllLoader dllSupport; IFT(dllSupport.Initialize()); CComPtr pLibrary; diff --git a/tools/clang/tools/dxa/dxa.cpp b/tools/clang/tools/dxa/dxa.cpp index 11d9d642e5..7e391c3d0d 100644 --- a/tools/clang/tools/dxa/dxa.cpp +++ b/tools/clang/tools/dxa/dxa.cpp @@ -79,14 +79,14 @@ static cl::opt DumpPSV("dumppsv", class DxaContext { private: - DxcDllSupport &m_dxcSupport; + SpecificDllLoader &m_dxcSupport; HRESULT FindModule(hlsl::DxilFourCC fourCC, IDxcBlob *pSource, IDxcLibrary *pLibrary, IDxcBlob **ppTarget); bool ExtractPart(uint32_t Part, IDxcBlob **ppTargetBlob); bool ExtractPart(IDxcBlob *pSource, uint32_t Part, IDxcBlob **ppTargetBlob); public: - DxaContext(DxcDllSupport &dxcSupport) : m_dxcSupport(dxcSupport) {} + DxaContext(SpecificDllLoader &dxcSupport) : m_dxcSupport(dxcSupport) {} void Assemble(); bool ExtractFile(const char *pName); @@ -546,7 +546,7 @@ int main(int argc, const char **argv) { return 2; } - DxcDllSupport dxcSupport; + LibraryDllLoader dxcSupport; dxc::EnsureEnabled(dxcSupport); DxaContext context(dxcSupport); if (ListParts) { diff --git a/tools/clang/tools/dxclib/dxc.cpp b/tools/clang/tools/dxclib/dxc.cpp index cdcfe2b3f6..8fbe55af0a 100644 --- a/tools/clang/tools/dxclib/dxc.cpp +++ b/tools/clang/tools/dxclib/dxc.cpp @@ -125,7 +125,7 @@ class DxcContext { private: DxcOpts &m_Opts; - DxcDllSupport &m_dxcSupport; + SpecificDllLoader &m_dxcSupport; int ActOnBlob(IDxcBlob *pBlob); int ActOnBlob(IDxcBlob *pBlob, IDxcBlob *pDebugBlob, LPCWSTR pDebugBlobName); @@ -155,7 +155,7 @@ class DxcContext { } public: - DxcContext(DxcOpts &Opts, DxcDllSupport &dxcSupport) + DxcContext(DxcOpts &Opts, SpecificDllLoader &dxcSupport) : m_Opts(Opts), m_dxcSupport(dxcSupport) {} int Compile(); @@ -1234,8 +1234,7 @@ namespace dxc { // Writes compiler version info to stream void WriteDxCompilerVersionInfo(llvm::raw_ostream &OS, const char *ExternalLib, - const char *ExternalFn, - DxcDllSupport &DxcSupport) { + const char *ExternalFn, DllLoader &DxcSupport) { if (DxcSupport.IsEnabled()) { UINT32 compilerMajor = 1; UINT32 compilerMinor = 0; @@ -1294,7 +1293,7 @@ void WriteDxCompilerVersionInfo(llvm::raw_ostream &OS, const char *ExternalLib, } // Writes compiler version info to stream -void WriteDXILVersionInfo(llvm::raw_ostream &OS, DxcDllSupport &DxilSupport) { +void WriteDXILVersionInfo(llvm::raw_ostream &OS, DllLoader &DxilSupport) { if (DxilSupport.IsEnabled()) { CComPtr VerInfo; if (SUCCEEDED(DxilSupport.CreateInstance(CLSID_DxcValidator, &VerInfo))) { @@ -1325,7 +1324,7 @@ void DxcContext::GetCompilerVersionInfo(llvm::raw_string_ostream &OS) { m_dxcSupport); // Print validator if exists - DxcDllSupport DxilSupport; + SpecificDllLoader DxilSupport; DxilSupport.InitializeForDll(kDxilLib, "DxcCreateInstance"); WriteDXILVersionInfo(OS, DxilSupport); } @@ -1417,7 +1416,7 @@ int dxc::main(int argc, const char **argv_) { const OptTable *optionTable = getHlslOptTable(); MainArgs argStrings(argc, argv_); DxcOpts dxcOpts; - DxcDllSupport dxcSupport; + LibraryDllLoader dxcSupport; // Read options and check errors. { @@ -1452,7 +1451,8 @@ int dxc::main(int argc, const char **argv_) { { std::string dllErrorString; llvm::raw_string_ostream dllErrorStream(dllErrorString); - int dllResult = SetupDxcDllSupport(dxcOpts, dxcSupport, dllErrorStream); + int dllResult = + SetupSpecificDllLoader(dxcOpts, dxcSupport, dllErrorStream); dllErrorStream.flush(); if (dllErrorString.size()) { fprintf(stderr, "%s\n", dllErrorString.data()); diff --git a/tools/clang/tools/dxclib/dxc.h b/tools/clang/tools/dxclib/dxc.h index 9ae7a06ffb..387c97cab0 100644 --- a/tools/clang/tools/dxclib/dxc.h +++ b/tools/clang/tools/dxclib/dxc.h @@ -18,14 +18,12 @@ class raw_ostream; } namespace dxc { -class DxcDllSupport; +class DllLoader; // Writes compiler version info to stream void WriteDxCompilerVersionInfo(llvm::raw_ostream &OS, const char *ExternalLib, - const char *ExternalFn, - dxc::DxcDllSupport &DxcSupport); -void WriteDXILVersionInfo(llvm::raw_ostream &OS, - dxc::DxcDllSupport &DxilSupport); + const char *ExternalFn, DllLoader &DxcSupport); +void WriteDXILVersionInfo(llvm::raw_ostream &OS, DllLoader &DxilSupport); #ifdef _WIN32 int main(int argc, const wchar_t **argv_); diff --git a/tools/clang/tools/dxlib-sample/lib_cache_manager.cpp b/tools/clang/tools/dxlib-sample/lib_cache_manager.cpp index e6379415af..f8a93a59f9 100644 --- a/tools/clang/tools/dxlib-sample/lib_cache_manager.cpp +++ b/tools/clang/tools/dxlib-sample/lib_cache_manager.cpp @@ -40,7 +40,7 @@ class NoFuncBodyRewriter { private: CComPtr m_pRewriter; - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; }; HRESULT NoFuncBodyRewriter::RewriteToNoFuncBody( diff --git a/tools/clang/tools/dxopt/CMakeLists.txt b/tools/clang/tools/dxopt/CMakeLists.txt index 1d41efc0d2..090ce21d87 100644 --- a/tools/clang/tools/dxopt/CMakeLists.txt +++ b/tools/clang/tools/dxopt/CMakeLists.txt @@ -8,8 +8,11 @@ set( LLVM_LINK_COMPONENTS Support # just for assert and raw streams ) +set(DXCSUPPORT_DIR "${CMAKE_SOURCE_DIR}/lib/DxcSupport") + add_clang_executable(dxopt dxopt.cpp + ${DXCSUPPORT_DIR}/dxcapi.use.cpp ) target_link_libraries(dxopt diff --git a/tools/clang/tools/dxopt/dxopt.cpp b/tools/clang/tools/dxopt/dxopt.cpp index 29e3876e7d..e03c11ccc7 100644 --- a/tools/clang/tools/dxopt/dxopt.cpp +++ b/tools/clang/tools/dxopt/dxopt.cpp @@ -12,6 +12,7 @@ #include "dxc/Support/Global.h" #include "dxc/Support/Unicode.h" #include "dxc/Support/WinIncludes.h" +#include "dxc/Support/dxcapi.use.h" #include #include @@ -30,6 +31,8 @@ #include "llvm/Support/FileSystem.h" +extern const char *kDxCompilerLib; + inline bool wcseq(LPCWSTR a, LPCWSTR b) { return (a == nullptr && b == nullptr) || (a != nullptr && b != nullptr && wcscmp(a, b) == 0); @@ -43,7 +46,7 @@ inline bool wcsieqopt(LPCWSTR text, LPCWSTR opt) { return (text[0] == L'-' || text[0] == L'/') && wcsieq(text + 1, opt); } -static dxc::DxcDllSupport g_DxcSupport; +static dxc::SpecificDllLoader g_DxcSupport; enum class ProgramAction { PrintHelp, @@ -319,7 +322,8 @@ int main(int argc, const char **argv) { CW2A externalLibA(externalLib); IFT(g_DxcSupport.InitializeForDll(externalLibA, externalFnA)); } else { - IFT(g_DxcSupport.Initialize()); + IFT(g_DxcSupport.InitializeForDll(dxc::kDxCompilerLib, + "DxcCreateInstance")); } CComPtr pBlob; diff --git a/tools/clang/tools/dxr/dxr.cpp b/tools/clang/tools/dxr/dxr.cpp index e64a050ffc..e88865694e 100644 --- a/tools/clang/tools/dxr/dxr.cpp +++ b/tools/clang/tools/dxr/dxr.cpp @@ -50,7 +50,7 @@ int main(int argc, const char **argv) { const OptTable *optionTable = getHlslOptTable(); MainArgs argStrings(argc, argv_); DxcOpts dxcOpts; - DxcDllSupport dxcSupport; + LibraryDllLoader dxcSupport; // Read options and check errors. { @@ -76,7 +76,8 @@ int main(int argc, const char **argv) { { std::string dllErrorString; llvm::raw_string_ostream dllErrorStream(dllErrorString); - int dllResult = SetupDxcDllSupport(dxcOpts, dxcSupport, dllErrorStream); + int dllResult = + SetupSpecificDllLoader(dxcOpts, dxcSupport, dllErrorStream); dllErrorStream.flush(); if (dllErrorString.size()) { fprintf(stderr, "%s\n", dllErrorString.data()); @@ -92,7 +93,7 @@ int main(int argc, const char **argv) { llvm::raw_string_ostream helpStream(helpString); std::string version; llvm::raw_string_ostream versionStream(version); - WriteDxCompilerVersionInfo( + dxc::WriteDxCompilerVersionInfo( versionStream, dxcOpts.ExternalLib.empty() ? (LPCSTR) nullptr : dxcOpts.ExternalLib.data(), @@ -111,7 +112,7 @@ int main(int argc, const char **argv) { if (dxcOpts.ShowVersion) { std::string version; llvm::raw_string_ostream versionStream(version); - WriteDxCompilerVersionInfo( + dxc::WriteDxCompilerVersionInfo( versionStream, dxcOpts.ExternalLib.empty() ? (LPCSTR) nullptr : dxcOpts.ExternalLib.data(), diff --git a/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp b/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp index 1c54ea6fa3..e12a7412da 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp @@ -15,7 +15,7 @@ using namespace dxc; -static DxcDllSupport g_DllSupport; +static SpecificDllLoader g_DllSupport; static HRESULT g_DllLibResult = S_OK; static CRITICAL_SECTION cs; diff --git a/tools/clang/tools/dxv/dxv.cpp b/tools/clang/tools/dxv/dxv.cpp index 6e1ea8013e..eabae86a75 100644 --- a/tools/clang/tools/dxv/dxv.cpp +++ b/tools/clang/tools/dxv/dxv.cpp @@ -42,10 +42,10 @@ static cl::opt class DxvContext { private: - DxcDllSupport &m_dxcSupport; + SpecificDllLoader &m_dxcSupport; public: - DxvContext(DxcDllSupport &dxcSupport) : m_dxcSupport(dxcSupport) {} + DxvContext(SpecificDllLoader &dxcSupport) : m_dxcSupport(dxcSupport) {} void Validate(); }; @@ -160,7 +160,7 @@ int main(int argc, const char **argv) { return 2; } - DxcDllSupport dxcSupport; + LibraryDllLoader dxcSupport; dxc::EnsureEnabled(dxcSupport); DxvContext context(dxcSupport); diff --git a/tools/clang/unittests/DxrFallback/ShaderTesterImpl.cpp b/tools/clang/unittests/DxrFallback/ShaderTesterImpl.cpp index 08ae2c3c75..ad37f5fe18 100644 --- a/tools/clang/unittests/DxrFallback/ShaderTesterImpl.cpp +++ b/tools/clang/unittests/DxrFallback/ShaderTesterImpl.cpp @@ -32,7 +32,7 @@ using Microsoft::WRL::ComPtr; #include "dxc/dxcapi.h" #include -static dxc::DxcDllSupport g_DxcDllHelper; +static dxc::DxCompilerDllLoader g_DxcDllHelper; #define VERIFY_SUCCEEDED(expr) \ { \ diff --git a/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp b/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp index d8352ae1c1..85d4c33255 100644 --- a/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp +++ b/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp @@ -49,11 +49,11 @@ void printErrors(CComPtr pResult) { // IFTMSG(status, msg); } -void CompileToDxilFromFile(DxcDllSupport &dxcSupport, - LPCWSTR pShaderTextFilePath, LPCWSTR pEntryPoint, - LPCWSTR pTargetProfile, LPCWSTR *pArgs, - UINT32 argCount, const DxcDefine *pDefines, - UINT32 defineCount, IDxcBlob **ppBlob) { +void CompileToDxilFromFile(DllLoader &dxcSupport, LPCWSTR pShaderTextFilePath, + LPCWSTR pEntryPoint, LPCWSTR pTargetProfile, + LPCWSTR *pArgs, UINT32 argCount, + const DxcDefine *pDefines, UINT32 defineCount, + IDxcBlob **ppBlob) { CComPtr pLibrary; IFT(dxcSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary)); @@ -83,7 +83,7 @@ void CompileToDxilFromFile(DxcDllSupport &dxcSupport, } } -bool DxrCompile(DxcDllSupport &dxrFallbackSupport, const std::string &entryName, +bool DxrCompile(DllLoader &dxrFallbackSupport, const std::string &entryName, std::vector &libs, const std::vector &shaderNames, std::vector &shaderIds, bool findCalledShaders, @@ -161,8 +161,8 @@ class Tester { } protected: - DxcDllSupport m_dxcSupport; - DxcDllSupport m_dxrFallbackSupport; + LibraryDllLoader m_dxcSupport; + SpecificDllLoader m_dxrFallbackSupport; std::wstring m_deviceName; std::vector> m_inputBlobs; std::vector m_inputBlobPtrs; diff --git a/tools/clang/unittests/HLSL/CompilerTest.cpp b/tools/clang/unittests/HLSL/CompilerTest.cpp index 3f4fb30d58..02b8652ad5 100644 --- a/tools/clang/unittests/HLSL/CompilerTest.cpp +++ b/tools/clang/unittests/HLSL/CompilerTest.cpp @@ -80,9 +80,9 @@ class TestIncludeHandler : public IDxcIncludeHandler { DXC_MICROCOM_REF_FIELD(m_dwRef) public: DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef) - dxc::DxcDllSupport &m_dllSupport; + dxc::DxCompilerDllLoader &m_dllSupport; HRESULT m_defaultErrorCode = E_FAIL; - TestIncludeHandler(dxc::DxcDllSupport &dllSupport) + TestIncludeHandler(dxc::DxCompilerDllLoader &dllSupport) : m_dwRef(0), m_dllSupport(dllSupport), callIndex(0) {} HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override { @@ -285,7 +285,7 @@ class CompilerTest : public ::testing::Test { TEST_METHOD_PROPERTY(L"Ignore", L"true") END_TEST_METHOD() - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; void CreateBlobPinned(LPCVOID data, SIZE_T size, UINT32 codePage, @@ -1264,7 +1264,7 @@ TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeMS) { } static void VerifyPdbUtil( - dxc::DxcDllSupport &dllSupport, IDxcBlob *pBlob, IDxcPdbUtils *pPdbUtils, + dxc::DllLoader &dllSupport, IDxcBlob *pBlob, IDxcPdbUtils *pPdbUtils, const WCHAR *pMainFileName, llvm::ArrayRef> ExpectedArgs, llvm::ArrayRef> ExpectedFlags, @@ -2902,9 +2902,9 @@ class SimpleIncludeHanlder : public IDxcIncludeHandler { DXC_MICROCOM_REF_FIELD(m_dwRef) public: DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef) - dxc::DxcDllSupport &m_dllSupport; + dxc::DxCompilerDllLoader &m_dllSupport; HRESULT m_defaultErrorCode = E_FAIL; - SimpleIncludeHanlder(dxc::DxcDllSupport &dllSupport) + SimpleIncludeHanlder(dxc::DxCompilerDllLoader &dllSupport) : m_dwRef(0), m_dllSupport(dllSupport) {} HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override { diff --git a/tools/clang/unittests/HLSL/DxilContainerTest.cpp b/tools/clang/unittests/HLSL/DxilContainerTest.cpp index 34b4d338fe..5869923802 100644 --- a/tools/clang/unittests/HLSL/DxilContainerTest.cpp +++ b/tools/clang/unittests/HLSL/DxilContainerTest.cpp @@ -124,7 +124,7 @@ class DxilContainerTest : public ::testing::Test { TEST_METHOD_PROPERTY(L"Priority", L"1") END_TEST_METHOD() - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; void CreateBlobPinned(LPCVOID data, SIZE_T size, UINT32 codePage, diff --git a/tools/clang/unittests/HLSL/DxilModuleTest.cpp b/tools/clang/unittests/HLSL/DxilModuleTest.cpp index 9893127809..51ff34c07c 100644 --- a/tools/clang/unittests/HLSL/DxilModuleTest.cpp +++ b/tools/clang/unittests/HLSL/DxilModuleTest.cpp @@ -46,7 +46,7 @@ class DxilModuleTest : public ::testing::Test { TEST_CLASS_SETUP(InitSupport); - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; // Basic loading tests. @@ -96,7 +96,7 @@ bool DxilModuleTest::InitSupport() { namespace { class Compiler { public: - Compiler(dxc::DxcDllSupport &dll) + Compiler(dxc::DxCompilerDllLoader &dll) : m_dllSupport(dll), m_msf(CreateMSFileSystem()), m_pts(m_msf.get()) { m_ver.Initialize(m_dllSupport); VERIFY_SUCCEEDED( @@ -179,7 +179,7 @@ class Compiler { return msfPtr; } - dxc::DxcDllSupport &m_dllSupport; + dxc::DxCompilerDllLoader &m_dllSupport; VersionSupportInfo m_ver; CComPtr pCompiler; CComPtr pCodeBlob; diff --git a/tools/clang/unittests/HLSL/ExtensionTest.cpp b/tools/clang/unittests/HLSL/ExtensionTest.cpp index 74acdd6f6f..47d19a3e0d 100644 --- a/tools/clang/unittests/HLSL/ExtensionTest.cpp +++ b/tools/clang/unittests/HLSL/ExtensionTest.cpp @@ -572,7 +572,7 @@ class TestSemanticDefineValidator : public IDxcSemanticDefineValidator { auto Check = [pName](const std::vector &errors, IDxcBlobEncoding **blob) { if (std::find(errors.begin(), errors.end(), pName) != errors.end()) { - dxc::DxcDllSupport dllSupport; + dxc::DxCompilerDllLoader dllSupport; VERIFY_SUCCEEDED(dllSupport.Initialize()); std::string error("bad define: "); error.append(pName); @@ -601,7 +601,7 @@ static std::string GetCompileErrors(IDxcOperationResult *pResult) { class Compiler { public: - Compiler(dxc::DxcDllSupport &dll) : m_dllSupport(dll) { + Compiler(dxc::DxCompilerDllLoader &dll) : m_dllSupport(dll) { VERIFY_SUCCEEDED(m_dllSupport.Initialize()); VERIFY_SUCCEEDED( m_dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler)); @@ -654,7 +654,7 @@ class Compiler { return DisassembleProgram(m_dllSupport, pBlob); } - dxc::DxcDllSupport &m_dllSupport; + dxc::DxCompilerDllLoader &m_dllSupport; CComPtr pCompiler; CComPtr pLangExtensions; CComPtr pCodeBlob; @@ -677,7 +677,7 @@ class ExtensionTest : public ::testing::Test { TEST_METHOD_PROPERTY(L"Priority", L"0") END_TEST_CLASS() - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; TEST_METHOD(EvalAttributeCollision) TEST_METHOD(NoUnwind) diff --git a/tools/clang/unittests/HLSL/FunctionTest.cpp b/tools/clang/unittests/HLSL/FunctionTest.cpp index e8b087a369..5234b4f1f0 100644 --- a/tools/clang/unittests/HLSL/FunctionTest.cpp +++ b/tools/clang/unittests/HLSL/FunctionTest.cpp @@ -36,7 +36,7 @@ class FunctionTest : public ::testing::Test { TEST_METHOD(AllowedInParamUsesClass) TEST_METHOD(ParseRootSignature) - dxc::DxcDllSupport m_support; + dxc::DxCompilerDllLoader m_support; std::vector rootSigText; std::string BuildSampleFunction(const char *StorageClassKeyword) { diff --git a/tools/clang/unittests/HLSL/LinkerTest.cpp b/tools/clang/unittests/HLSL/LinkerTest.cpp index df8bb644e1..2eddcc7f6f 100644 --- a/tools/clang/unittests/HLSL/LinkerTest.cpp +++ b/tools/clang/unittests/HLSL/LinkerTest.cpp @@ -80,7 +80,7 @@ class LinkerTest : public ::testing::Test { TEST_METHOD(RunLinkWithDxcResultRdat) TEST_METHOD(RunLinkWithDxcResultErrors) - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; void CreateLinker(IDxcLinker **pResultLinker) { diff --git a/tools/clang/unittests/HLSL/OptimizerTest.cpp b/tools/clang/unittests/HLSL/OptimizerTest.cpp index 42eff4b1a7..1294a41434 100644 --- a/tools/clang/unittests/HLSL/OptimizerTest.cpp +++ b/tools/clang/unittests/HLSL/OptimizerTest.cpp @@ -117,7 +117,7 @@ class OptimizerTest : public ::testing::Test { const wchar_t *profile, bool usesViewId, int streamCount = 1); - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; HRESULT CreateCompiler(IDxcCompiler **ppResult) { diff --git a/tools/clang/unittests/HLSL/PixDiaTest.cpp b/tools/clang/unittests/HLSL/PixDiaTest.cpp index d36e762762..8890a0082c 100644 --- a/tools/clang/unittests/HLSL/PixDiaTest.cpp +++ b/tools/clang/unittests/HLSL/PixDiaTest.cpp @@ -85,7 +85,7 @@ const char *DataKindText[] = { "FileStatic", "Global", "Member", "StaticMember", "Constant", }; -static void CompileAndGetDebugPart(dxc::DxcDllSupport &dllSupport, +static void CompileAndGetDebugPart(dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, IDxcBlob **ppDebugPart) { CComPtr pContainer; @@ -201,7 +201,7 @@ class PixDiaTest { TEST_METHOD(DxcPixDxilDebugInfo_VariableScopes_Function) TEST_METHOD(DxcPixDxilDebugInfo_VariableScopes_Member) - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; void RunSubProgramsCase(const char *hlsl); @@ -641,14 +641,12 @@ class PixDiaTest { } void CompileAndRunAnnotationAndGetDebugPart( - dxc::DxcDllSupport &dllSupport, const char *source, - const wchar_t *profile, IDxcIncludeHandler *includer, - IDxcBlob **ppDebugPart, + dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, + IDxcIncludeHandler *includer, IDxcBlob **ppDebugPart, std::vector extraArgs = {L"-Od"}); void CompileAndRunAnnotationAndLoadDiaSource( - dxc::DxcDllSupport &dllSupport, const char *source, - const wchar_t *profile, IDxcIncludeHandler *includer, - IDiaDataSource **ppDataSource, + dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, + IDxcIncludeHandler *includer, IDiaDataSource **ppDataSource, std::vector extraArgs = {L"-Od"}); struct VariableComponentInfo { @@ -781,7 +779,7 @@ bool PixDiaTest::InitSupport() { } void PixDiaTest::CompileAndRunAnnotationAndGetDebugPart( - dxc::DxcDllSupport &dllSupport, const char *source, const wchar_t *profile, + dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, IDxcIncludeHandler *includer, IDxcBlob **ppDebugPart, std::vector extraArgs) { @@ -1022,7 +1020,7 @@ TEST_F(PixDiaTest, DiaLoadBadBitcodeThenFail) { VERIFY_FAILED(pDiaSource->loadDataFromIStream(pStream)); } -static void CompileTestAndLoadDiaSource(dxc::DxcDllSupport &dllSupport, +static void CompileTestAndLoadDiaSource(dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, IDiaDataSource **ppDataSource) { @@ -1042,7 +1040,7 @@ static void CompileTestAndLoadDiaSource(dxc::DxcDllSupport &dllSupport, } } -static void CompileTestAndLoadDia(dxc::DxcDllSupport &dllSupport, +static void CompileTestAndLoadDia(dxc::DllLoader &dllSupport, IDiaDataSource **ppDataSource) { CompileTestAndLoadDiaSource(dllSupport, "[numthreads(8,8,1)] void main() { }", L"cs_6_0", ppDataSource); @@ -1204,7 +1202,7 @@ TEST_F(PixDiaTest, DiaCompileArgs) { args.push_back(L"/D"); args.push_back(DefineList[i]); } - auto CompileAndGetDebugPart = [&args](dxc::DxcDllSupport &dllSupport, + auto CompileAndGetDebugPart = [&args](dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, IDxcBlob **ppDebugPart) { @@ -1464,7 +1462,7 @@ TEST_F(PixDiaTest, PixDebugCompileInfo) { args.push_back(DefineList[i]); } - auto CompileAndGetDebugPart = [&args](dxc::DxcDllSupport &dllSupport, + auto CompileAndGetDebugPart = [&args](dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, IDxcBlob **ppDebugPart) { @@ -1532,7 +1530,7 @@ TEST_F(PixDiaTest, PixDebugCompileInfo) { } void PixDiaTest::CompileAndRunAnnotationAndLoadDiaSource( - dxc::DxcDllSupport &dllSupport, const char *source, const wchar_t *profile, + dxc::DllLoader &dllSupport, const char *source, const wchar_t *profile, IDxcIncludeHandler *includer, IDiaDataSource **ppDataSource, std::vector extraArgs) { CComPtr pDebugContent; diff --git a/tools/clang/unittests/HLSL/PixTest.cpp b/tools/clang/unittests/HLSL/PixTest.cpp index c032e9e872..991c4f38fc 100644 --- a/tools/clang/unittests/HLSL/PixTest.cpp +++ b/tools/clang/unittests/HLSL/PixTest.cpp @@ -156,7 +156,7 @@ class PixTest : public ::testing::Test { TEST_METHOD(NonUniformResourceIndex_DescriptorHeap) TEST_METHOD(NonUniformResourceIndex_Raytracing) - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; HRESULT CreateContainerBuilder(IDxcContainerBuilder **ppResult) { diff --git a/tools/clang/unittests/HLSL/PixTestUtils.cpp b/tools/clang/unittests/HLSL/PixTestUtils.cpp index 61647ff5fa..4707ca9f7f 100644 --- a/tools/clang/unittests/HLSL/PixTestUtils.cpp +++ b/tools/clang/unittests/HLSL/PixTestUtils.cpp @@ -166,7 +166,7 @@ DxilRegisterToNameMap BuildDxilRegisterToNameMap(char const *disassembly) { return ret; } -std::wstring Disassemble(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram) { +std::wstring Disassemble(dxc::DllLoader &dllSupport, IDxcBlob *pProgram) { CComPtr pCompiler; VERIFY_SUCCEEDED(pix_test::CreateCompiler(dllSupport, &pCompiler)); @@ -182,7 +182,7 @@ std::wstring Disassemble(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram) { // For CreateBlobFromText namespace { -void CreateBlobPinned(dxc::DxcDllSupport &dllSupport, +void CreateBlobPinned(dxc::DllLoader &dllSupport, _In_bytecount_(size) LPCVOID data, SIZE_T size, UINT32 codePage, IDxcBlobEncoding **ppBlob) { CComPtr library; @@ -215,7 +215,7 @@ std::vector SplitAndPreserveEmptyLines(std::string const &str, return lines; } -void CompileAndLogErrors(dxc::DxcDllSupport &dllSupport, LPCSTR pText, +void CompileAndLogErrors(dxc::DllLoader &dllSupport, LPCSTR pText, LPCWSTR pTargetProfile, std::vector &args, IDxcIncludeHandler *includer, _Outptr_ IDxcBlob **ppResult) { @@ -241,7 +241,7 @@ void CompileAndLogErrors(dxc::DxcDllSupport &dllSupport, LPCSTR pText, VERIFY_SUCCEEDED(pResult->GetResult(ppResult)); } -PassOutput RunAnnotationPasses(dxc::DxcDllSupport &dllSupport, IDxcBlob *dxil, +PassOutput RunAnnotationPasses(dxc::DllLoader &dllSupport, IDxcBlob *dxil, int startingLineNumber) { CComPtr pOptimizer; VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcOptimizer, &pOptimizer)); @@ -334,7 +334,7 @@ GatherDebugLocLabelsFromDxcUtils(DebuggerInterfaces &debuggerInterfaces) { return std::make_unique(debuggerInterfaces); } -CComPtr GetDebugPart(dxc::DxcDllSupport &dllSupport, +CComPtr GetDebugPart(dxc::DllLoader &dllSupport, IDxcBlob *container) { CComPtr pLib; @@ -355,17 +355,16 @@ CComPtr GetDebugPart(dxc::DxcDllSupport &dllSupport, return debugPart; } -void CreateBlobFromText(dxc::DxcDllSupport &dllSupport, const char *pText, +void CreateBlobFromText(dxc::DllLoader &dllSupport, const char *pText, IDxcBlobEncoding **ppBlob) { CreateBlobPinned(dllSupport, pText, strlen(pText) + 1, CP_UTF8, ppBlob); } -HRESULT CreateCompiler(dxc::DxcDllSupport &dllSupport, - IDxcCompiler **ppResult) { +HRESULT CreateCompiler(dxc::DllLoader &dllSupport, IDxcCompiler **ppResult) { return dllSupport.CreateInstance(CLSID_DxcCompiler, ppResult); } -CComPtr Compile(dxc::DxcDllSupport &dllSupport, const char *hlsl, +CComPtr Compile(dxc::DllLoader &dllSupport, const char *hlsl, const wchar_t *target, std::vector extraArgs, const wchar_t *entry) { @@ -428,7 +427,7 @@ CComPtr Compile(dxc::DxcDllSupport &dllSupport, const char *hlsl, return pProgram; } -CComPtr WrapInNewContainer(dxc::DxcDllSupport &dllSupport, +CComPtr WrapInNewContainer(dxc::DllLoader &dllSupport, IDxcBlob *part) { CComPtr pAssembler; IFT(dllSupport.CreateInstance(CLSID_DxcAssembler, &pAssembler)); diff --git a/tools/clang/unittests/HLSL/PixTestUtils.h b/tools/clang/unittests/HLSL/PixTestUtils.h index 8f7d0cdf45..d55868e75c 100644 --- a/tools/clang/unittests/HLSL/PixTestUtils.h +++ b/tools/clang/unittests/HLSL/PixTestUtils.h @@ -19,7 +19,7 @@ #include namespace dxc { -class DxcDllSupport; +class DllLoader; } namespace pix_test { @@ -27,23 +27,22 @@ namespace pix_test { std::vector SplitAndPreserveEmptyLines(std::string const &str, char delimeter); -CComPtr GetDebugPart(dxc::DxcDllSupport &dllSupport, - IDxcBlob *container); -void CreateBlobFromText(dxc::DxcDllSupport &dllSupport, const char *pText, +CComPtr GetDebugPart(dxc::DllLoader &dllSupport, IDxcBlob *container); +void CreateBlobFromText(dxc::DllLoader &dllSupport, const char *pText, IDxcBlobEncoding **ppBlob); -HRESULT CreateCompiler(dxc::DxcDllSupport &dllSupport, IDxcCompiler **ppResult); -CComPtr Compile(dxc::DxcDllSupport &dllSupport, const char *hlsl, +HRESULT CreateCompiler(dxc::DllLoader &dllSupport, IDxcCompiler **ppResult); +CComPtr Compile(dxc::DllLoader &dllSupport, const char *hlsl, const wchar_t *target, std::vector extraArgs = {}, const wchar_t *entry = L"main"); -void CompileAndLogErrors(dxc::DxcDllSupport &dllSupport, LPCSTR pText, +void CompileAndLogErrors(dxc::DllLoader &dllSupport, LPCSTR pText, LPCWSTR pTargetProfile, std::vector &args, IDxcIncludeHandler *includer, _Outptr_ IDxcBlob **ppResult); -CComPtr WrapInNewContainer(dxc::DxcDllSupport &dllSupport, +CComPtr WrapInNewContainer(dxc::DllLoader &dllSupport, IDxcBlob *part); struct ValueLocation { @@ -56,7 +55,7 @@ struct PassOutput { std::vector lines; }; -PassOutput RunAnnotationPasses(dxc::DxcDllSupport &dllSupport, IDxcBlob *dxil, +PassOutput RunAnnotationPasses(dxc::DllLoader &dllSupport, IDxcBlob *dxil, int startingLineNumber = 0); struct DebuggerInterfaces { diff --git a/tools/clang/unittests/HLSL/RewriterTest.cpp b/tools/clang/unittests/HLSL/RewriterTest.cpp index 613c8561a3..1d53a733ef 100644 --- a/tools/clang/unittests/HLSL/RewriterTest.cpp +++ b/tools/clang/unittests/HLSL/RewriterTest.cpp @@ -103,7 +103,7 @@ class RewriterTest : public ::testing::Test { TEST_METHOD(RunGlobalsUsedInMethod) TEST_METHOD(RunRewriterFails) - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; CComPtr m_pIncludeHandler; struct VerifyResult { @@ -173,7 +173,7 @@ class RewriterTest : public ::testing::Test { struct FileWithBlob { CComPtr BlobEncoding; - FileWithBlob(dxc::DxcDllSupport &support, LPCWSTR path) { + FileWithBlob(dxc::DllLoader &support, LPCWSTR path) { CComPtr library; IFT(support.CreateInstance(CLSID_DxcLibrary, &library)); UINT32 codePage = CP_UTF8; diff --git a/tools/clang/unittests/HLSL/SystemValueTest.cpp b/tools/clang/unittests/HLSL/SystemValueTest.cpp index be29612890..91d6cf1215 100644 --- a/tools/clang/unittests/HLSL/SystemValueTest.cpp +++ b/tools/clang/unittests/HLSL/SystemValueTest.cpp @@ -198,7 +198,7 @@ class SystemValueTest : public ::testing::Test { VERIFY_IS_TRUE(bMessageFound); } - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; unsigned m_HighestMajor, m_HighestMinor; // Shader Model Supported diff --git a/tools/clang/unittests/HLSL/ValidationTest.cpp b/tools/clang/unittests/HLSL/ValidationTest.cpp index 980bf6c7c2..1c64caf7aa 100644 --- a/tools/clang/unittests/HLSL/ValidationTest.cpp +++ b/tools/clang/unittests/HLSL/ValidationTest.cpp @@ -20,10 +20,12 @@ #include "dxc/DxilContainer/DxilContainerAssembler.h" #include "dxc/DxilContainer/DxilPipelineStateValidation.h" #include "dxc/DxilHash/DxilHash.h" +#include "dxc/Support/Unicode.h" // for wstring conversions like WideToUtf8String #include "dxc/Support/WinIncludes.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Regex.h" +#include #ifdef _WIN32 #include @@ -32,6 +34,7 @@ #include "dxc/Support/Global.h" #include "dxc/DXIL/DxilShaderModel.h" +#include "dxc/Support/dxcapi.extval.h" #include "dxc/Test/DxcTestUtils.h" #include "dxc/Test/HlslTestUtils.h" @@ -323,11 +326,12 @@ class ValidationTest : public ::testing::Test { TEST_METHOD(PSVContentValidationCS) TEST_METHOD(PSVContentValidationMS) TEST_METHOD(PSVContentValidationAS) + TEST_METHOD(UnitTestExtValidationSupport) TEST_METHOD(WrongPSVSize) TEST_METHOD(WrongPSVSizeOnZeros) TEST_METHOD(WrongPSVVersion) - dxc::DxcDllSupport m_dllSupport; + dxc::DxCompilerDllLoader m_dllSupport; VersionSupportInfo m_ver; void TestCheck(LPCWSTR name) { @@ -4207,6 +4211,97 @@ TEST_F(ValidationTest, ValidateWithHash) { VERIFY_ARE_EQUAL(memcmp(Result, pHeader->Hash.Digest, sizeof(Result)), 0); } +#ifdef _WIN32 +std::wstring GetEnvVarW(const std::wstring &VarName) { + if (const wchar_t *Result = _wgetenv(VarName.c_str())) + return std::wstring(Result); + return std::wstring(); +} + +void SetEnvVarW(const std::wstring &VarName, const std::wstring &VarValue) { + _wputenv_s(VarName.c_str(), VarValue.c_str()); +} + +// For now, 3 things are tested: +// 1. The environment variable is not set. GetDxilDllPath() is empty and +// DxilDllFailedToLoad() returns false +// 2. Given a bogus path in the environment variable, and an initialized +// DxcDllExtValidationSupport object, GetDxilDllPath() +// retrieves the bogus path despite DxcDllExtValidationSupport failing to load +// it as a dll, and DxilDllFailedToLoad() returns true. +// 3. CLSID_DxcCompiler, CLSID_DxcLinker, CLSID_DxcValidator +// may be created through DxcDllExtValidationSupport. +// This is all to simply test that the new class, DxcDllExtValidationSupport, +// works as intended. + +TEST_F(ValidationTest, UnitTestExtValidationSupport) { + dxc::DxcDllExtValidationLoader ExtSupportEmpty; + dxc::DxcDllExtValidationLoader ExtSupportBogus; + + // capture any existing value in the environment variable, + // so that it can be restored after the test + std::wstring OldEnvVal = GetEnvVarW(L"DXC_DXIL_DLL_PATH"); + + // 1. with no env var set, test GetDxilDllPath() and DxilDllFailedToLoad() + + // make sure the variable is cleared, in case other tests may have set it + SetEnvVarW(L"DXC_DXIL_DLL_PATH", L""); + + // empty initialization should succeed + VERIFY_SUCCEEDED(ExtSupportEmpty.Initialize()); + + VERIFY_IS_FALSE(ExtSupportEmpty.DxilDllFailedToLoad()); + std::string EmptyPath = ExtSupportBogus.GetDxilDllPath(); + VERIFY_ARE_EQUAL_STR(EmptyPath.c_str(), ""); + + // 2. Test with a bogus path in the environment variable + SetEnvVarW(L"DXC_DXIL_DLL_PATH", L"bogus"); + + if (!ExtSupportBogus.IsEnabled()) { + VERIFY_FAILED(ExtSupportBogus.Initialize()); + } + + // validate that m_dllExtSupport2 was able to capture the environment + // variable's value, and that loading the bogus path was unsuccessful + std::string BogusPath = ExtSupportBogus.GetDxilDllPath(); + VERIFY_ARE_EQUAL_STR(BogusPath.c_str(), "bogus"); + VERIFY_IS_TRUE(ExtSupportBogus.DxilDllFailedToLoad()); + + // 3. Test production of class IDs CLSID_DxcCompiler, CLSID_DxcLinker, + // and CLSID_DxcValidator through DxcDllExtValidationSupport. + CComPtr Compiler; + CComPtr Linker; + CComPtr Validator; + + VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance( + CLSID_DxcCompiler, __uuidof(IDxcCompiler), (IUnknown **)&Compiler)); + VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance( + CLSID_DxcLinker, __uuidof(IDxcLinker), (IUnknown **)&Linker)); + VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance( + CLSID_DxcValidator, __uuidof(IDxcValidator), (IUnknown **)&Validator)); + + Linker.Release(); + Validator.Release(); + Compiler.Release(); + + CComPtr Malloc; + CComPtr Compiler2; + VERIFY_SUCCEEDED(DxcCoGetMalloc(1, &Malloc)); + VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance2(Malloc, CLSID_DxcCompiler, + __uuidof(IDxcCompiler), + (IUnknown **)&Compiler2)); + VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance2( + Malloc, CLSID_DxcLinker, __uuidof(IDxcLinker), (IUnknown **)&Linker)); + VERIFY_SUCCEEDED(ExtSupportBogus.CreateInstance2(Malloc, CLSID_DxcValidator, + __uuidof(IDxcValidator), + (IUnknown **)&Validator)); + + // reset the environment variable to its previous value, + // or the empty string if there was no previous value + SetEnvVarW(L"DXC_DXIL_DLL_PATH", OldEnvVal); +} +#endif + TEST_F(ValidationTest, ValidatePreviewBypassHash) { if (m_ver.SkipDxilVersion(1, ShaderModel::kHighestMinor)) return; diff --git a/tools/clang/unittests/HLSLExec/CMakeLists.txt b/tools/clang/unittests/HLSLExec/CMakeLists.txt index b490ac94e9..ac305a31a1 100644 --- a/tools/clang/unittests/HLSLExec/CMakeLists.txt +++ b/tools/clang/unittests/HLSLExec/CMakeLists.txt @@ -5,6 +5,8 @@ find_package(D3D12 REQUIRED) # Used for ExecutionTest.cpp. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +set(DXCSUPPORT_DIR "${CMAKE_SOURCE_DIR}/lib/DxcSupport") + add_clang_library(ExecHLSLTests SHARED ExecutionTest.cpp ShaderOpTest.cpp diff --git a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp index 586c55328d..68e94794cc 100644 --- a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp +++ b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp @@ -459,7 +459,7 @@ class ExecutionTest { L"Table:ShaderOpArithTable.xml#PackUnpackOpTable") END_TEST_METHOD() - dxc::DxcDllSupport m_support; + dxc::DxCompilerDllLoader m_support; bool m_D3DInitCompleted = false; bool m_ExperimentalModeEnabled = false; @@ -3568,13 +3568,13 @@ struct Dispatch { }; std::shared_ptr RunDispatch(ID3D12Device *pDevice, - dxc::DxcDllSupport &support, + dxc::SpecificDllLoader &support, st::ShaderOp *pShaderOp, const Dispatch D) { char compilerOptions[256]; std::shared_ptr test = std::make_shared(); - test->SetDxcSupport(&support); + test->SetSpecificDllLoader(&support); test->SetInitCallback(nullptr); test->SetDevice(pDevice); @@ -10765,7 +10765,7 @@ TEST_F(ExecutionTest, DynamicResourcesDynamicIndexingTest) { void RunWaveSizeTest(UINT minWaveSize, UINT maxWaveSize, std::shared_ptr ShaderOpSet, CComPtr pDevice, - dxc::DxcDllSupport &m_support) { + dxc::SpecificDllLoader &m_support) { // format shader source const char waveSizeTestShader[] = R"(struct TestData { @@ -10835,7 +10835,7 @@ bool TestShaderRangeAgainstRequirements(UINT shaderminws, UINT shadermaxws, void ExecuteWaveSizeRangeInstance(UINT minWaveSize, UINT maxWaveSize, std::shared_ptr ShaderOpSet, CComPtr pDevice, - dxc::DxcDllSupport &m_support, + dxc::SpecificDllLoader &m_support, UINT minShaderWaveSize, UINT maxShaderWaveSize, UINT prefShaderWaveSize, bool usePreferred) { @@ -10918,7 +10918,7 @@ void ExecuteWaveSizeRangeInstance(UINT minWaveSize, UINT maxWaveSize, void RunWaveSizeRangeTest(UINT minWaveSize, UINT maxWaveSize, std::shared_ptr ShaderOpSet, CComPtr pDevice, - dxc::DxcDllSupport &m_support) { + dxc::SpecificDllLoader &m_support) { for (UINT minShaderWaveSize = 4; minShaderWaveSize <= maxWaveSize; minShaderWaveSize *= 2) { @@ -12427,7 +12427,7 @@ TEST_F(ExecutionTest, QuadAnyAll) { // input string pointers. st::ShaderOpTest::TShaderCallbackFn MakeShaderReplacementCallback( std::vector dxcArgs, std::vector lookFors, - std::vector replacements, dxc::DxcDllSupport &dllSupport) { + std::vector replacements, dxc::DllLoader &dllSupport) { auto ShaderInitFn = [dxcArgs, lookFors, replacements, &dllSupport]( LPCSTR Name, LPCSTR pText, IDxcBlob **ppShaderBlob, @@ -12743,7 +12743,7 @@ __declspec(dllexport) HRESULT WINAPI pOutputStrFn(pStrCtx, L"Unable to enable info queue for D3D.\r\n."); } try { - dxc::DxcDllSupport m_support; + dxc::DxCompilerDllLoader m_support; m_support.Initialize(); const char *pName = nullptr; @@ -12779,7 +12779,7 @@ __declspec(dllexport) HRESULT WINAPI std::shared_ptr test = std::make_shared(); test->SetupRenderTarget(pShaderOp, pDevice, pCommandQueue, pRenderTarget); - test->SetDxcSupport(&m_support); + test->SetSpecificDllLoader(&m_support); test->RunShaderOp(pShaderOp); test->PresentRenderTarget(pShaderOp, pCommandQueue, pRenderTarget); diff --git a/tools/clang/unittests/HLSLExec/HlslExecTestUtils.h b/tools/clang/unittests/HLSLExec/HlslExecTestUtils.h index 3822ef02ad..96b756f535 100644 --- a/tools/clang/unittests/HLSLExec/HlslExecTestUtils.h +++ b/tools/clang/unittests/HLSLExec/HlslExecTestUtils.h @@ -228,8 +228,9 @@ static bool createDevice(ID3D12Device **D3DDevice, } inline void readHlslDataIntoNewStream(LPCWSTR RelativePath, IStream **Stream, - dxc::DxcDllSupport &Support) { - VERIFY_SUCCEEDED(Support.Initialize()); + dxc::SpecificDllLoader &Support) { + VERIFY_SUCCEEDED( + Support.InitializeForDll(dxc::kDxCompilerLib, "DxcCreateInstance")); CComPtr Library; CComPtr Blob; CComPtr StreamCom; diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index a3c2c94d00..7de0b1b1a1 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -547,14 +547,14 @@ void OpTest::testBaseMethod( LPCSTR ShaderName = "LongVectorOp"; // ShaderOpArith.xml defines the input/output resources and the shader source. CComPtr TestXML; - readHlslDataIntoNewStream(L"ShaderOpArith.xml", &TestXML, DxcDllSupport); + readHlslDataIntoNewStream(L"ShaderOpArith.xml", &TestXML, DxilDllLoader); // RunShaderOpTest is a helper function that handles resource creation // and setup. It also handles the shader compilation and execution. It takes a // callback that is called when the shader is compiled, but before it is // executed. std::shared_ptr TestResult = st::RunShaderOpTest( - D3DDevice, DxcDllSupport, TestXML, ShaderName, + D3DDevice, DxilDllLoader, TestXML, ShaderName, [&](LPCSTR Name, std::vector &ShaderData, st::ShaderOp *ShaderOp) { hlsl_test::LogCommentFmt(L"RunShaderOpTest CallBack. Resource Name: %S", Name); diff --git a/tools/clang/unittests/HLSLExec/LongVectors.h b/tools/clang/unittests/HLSLExec/LongVectors.h index b7a37d09c1..38edc02341 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.h +++ b/tools/clang/unittests/HLSLExec/LongVectors.h @@ -299,7 +299,7 @@ class OpTest { void testBaseMethod(std::unique_ptr> &TestConfig); private: - dxc::DxcDllSupport DxcDllSupport; + dxc::SpecificDllLoader DxilDllLoader; bool Initialized = false; }; diff --git a/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp b/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp index 60ce3a9241..5ef2068165 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp +++ b/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp @@ -25,7 +25,7 @@ #include "HlslTestUtils.h" // LogCommentFmt #include "dxc/DXIL/DxilConstants.h" // ComponentType #include "dxc/Support/Global.h" // OutputDebugBytes -#include "dxc/Support/dxcapi.use.h" // DxcDllSupport +#include "dxc/Support/dxcapi.use.h" // *DllLoader #include "dxc/dxcapi.h" // IDxcCompiler #include @@ -1148,7 +1148,7 @@ void ShaderOpTest::SetRootValues(ID3D12GraphicsCommandList *pList, void ShaderOpTest::SetDevice(ID3D12Device *pDevice) { m_pDevice = pDevice; } -void ShaderOpTest::SetDxcSupport(dxc::DxcDllSupport *pDxcSupport) { +void ShaderOpTest::SetSpecificDllLoader(dxc::SpecificDllLoader *pDxcSupport) { m_pDxcSupport = pDxcSupport; } @@ -2758,8 +2758,8 @@ bool ShaderOpParser::ReadAtElementName(IXmlReader *pReader, LPCWSTR pName) { } std::shared_ptr -RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, - LPCSTR pName, +RunShaderOpTestAfterParse(ID3D12Device *pDevice, + dxc::SpecificDllLoader &support, LPCSTR pName, st::ShaderOpTest::TInitCallbackFn pInitCallback, st::ShaderOpTest::TShaderCallbackFn pShaderCallback, std::shared_ptr ShaderOpSet) { @@ -2790,7 +2790,7 @@ RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, pShaderOp->UseWarpDevice = hlsl_test::GetTestParamUseWARP(true); std::shared_ptr test = std::make_shared(); - test->SetDxcSupport(&support); + test->SetSpecificDllLoader(&support); test->SetInitCallback(pInitCallback); test->SetShaderCallback(pShaderCallback); test->SetDevice(pDevice); @@ -2805,8 +2805,8 @@ RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, } std::shared_ptr -RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, - LPCSTR pName, +RunShaderOpTestAfterParse(ID3D12Device *pDevice, + dxc::SpecificDllLoader &support, LPCSTR pName, st::ShaderOpTest::TInitCallbackFn pInitCallback, std::shared_ptr ShaderOpSet) { return RunShaderOpTestAfterParse(pDevice, support, pName, pInitCallback, @@ -2814,7 +2814,7 @@ RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, } std::shared_ptr -RunShaderOpTest(ID3D12Device *pDevice, dxc::DxcDllSupport &support, +RunShaderOpTest(ID3D12Device *pDevice, dxc::SpecificDllLoader &support, IStream *pStream, LPCSTR pName, st::ShaderOpTest::TInitCallbackFn pInitCallback) { DXASSERT_NOMSG(pStream != nullptr); diff --git a/tools/clang/unittests/HLSLExec/ShaderOpTest.h b/tools/clang/unittests/HLSLExec/ShaderOpTest.h index 76983aa48f..23078f5303 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpTest.h +++ b/tools/clang/unittests/HLSLExec/ShaderOpTest.h @@ -31,7 +31,7 @@ /////////////////////////////////////////////////////////////////////////////// // Forward declarations. namespace dxc { -class DxcDllSupport; +class SpecificDllLoader; } struct IStream; struct IXmlReader; @@ -284,7 +284,7 @@ class ShaderOpTest { void RunShaderOp(ShaderOp *pShaderOp); void RunShaderOp(std::shared_ptr pShaderOp); void SetDevice(ID3D12Device *pDevice); - void SetDxcSupport(dxc::DxcDllSupport *pDxcSupport); + void SetSpecificDllLoader(dxc::SpecificDllLoader *pDxcSupport); void SetInitCallback(TInitCallbackFn InitCallbackFn); void SetShaderCallback(TShaderCallbackFn ShaderCallbackFn); void SetupRenderTarget(ShaderOp *pShaderOp, ID3D12Device *pDevice, @@ -314,7 +314,7 @@ class ShaderOpTest { CComPtr m_pRootSignature; CComPtr m_pQueryHeap; CComPtr m_pQueryBuffer; - dxc::DxcDllSupport *m_pDxcSupport = nullptr; + dxc::SpecificDllLoader *m_pDxcSupport = nullptr; CommandListRefs m_CommandList; HANDLE m_hFence; ShaderOp *m_pShaderOp; @@ -354,20 +354,20 @@ struct ShaderOpTestResult { }; std::shared_ptr -RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, - LPCSTR pName, +RunShaderOpTestAfterParse(ID3D12Device *pDevice, + dxc::SpecificDllLoader &support, LPCSTR pName, st::ShaderOpTest::TInitCallbackFn pInitCallback, st::ShaderOpTest::TShaderCallbackFn pShaderCallback, std::shared_ptr ShaderOpSet); std::shared_ptr -RunShaderOpTestAfterParse(ID3D12Device *pDevice, dxc::DxcDllSupport &support, - LPCSTR pName, +RunShaderOpTestAfterParse(ID3D12Device *pDevice, + dxc::SpecificDllLoader &support, LPCSTR pName, st::ShaderOpTest::TInitCallbackFn pInitCallback, std::shared_ptr ShaderOpSet); std::shared_ptr -RunShaderOpTest(ID3D12Device *pDevice, dxc::DxcDllSupport &support, +RunShaderOpTest(ID3D12Device *pDevice, dxc::SpecificDllLoader &support, IStream *pStream, LPCSTR pName, st::ShaderOpTest::TInitCallbackFn pInitCallback); diff --git a/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp b/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp index 7e59b8f10f..207a77e1ea 100644 --- a/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp +++ b/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp @@ -13,6 +13,7 @@ #include "dxc/Support/Global.h" #include "dxc/Support/HLSLOptions.h" #include "dxc/Support/Unicode.h" +#include "dxc/Support/dxcapi.use.h" #include "dxc/Test/CompilationResult.h" #include "dxc/Test/HlslTestUtils.h" #include "llvm/ADT/APInt.h" @@ -24,6 +25,13 @@ using namespace std; using namespace hlsl_test; +namespace dxc { + +extern const char *kDxCompilerLib; +extern const char *kDxilLib; + +} // namespace dxc + MODULE_SETUP(TestModuleSetup) MODULE_CLEANUP(TestModuleCleanup) @@ -173,13 +181,14 @@ bool CheckOperationResultMsgs(IDxcOperationResult *pResult, maySucceedAnyway, bRegex); } -std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport, +std::string DisassembleProgram(dxc::DxCompilerDllLoader &dllSupport, IDxcBlob *pProgram) { CComPtr pCompiler; CComPtr pDisassembly; if (!dllSupport.IsEnabled()) { - VERIFY_SUCCEEDED(dllSupport.Initialize()); + VERIFY_SUCCEEDED( + dllSupport.InitializeForDll(dxc::kDxCompilerLib, "DxcCreateInstance")); } VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler)); @@ -187,7 +196,7 @@ std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport, return BlobToUtf8(pDisassembly); } -void AssembleToContainer(dxc::DxcDllSupport &dllSupport, IDxcBlob *pModule, +void AssembleToContainer(dxc::DllLoader &dllSupport, IDxcBlob *pModule, IDxcBlob **pContainer) { CComPtr pAssembler; CComPtr pResult; @@ -302,7 +311,7 @@ std::wstring BlobToWide(IDxcBlob *pBlob) { } } -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, +void Utf8ToBlob(dxc::DllLoader &dllSupport, const char *pVal, IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); @@ -310,32 +319,30 @@ void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, ppBlob)); } -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, - const std::string &val, UINT32 codePage, - IDxcBlobEncoding **ppBlob) { +void MultiByteStringToBlob(dxc::DllLoader &dllSupport, const std::string &val, + UINT32 codePage, IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingOnHeapCopy(val.data(), val.size(), codePage, ppBlob)); } -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, - const std::string &val, UINT32 codePage, - IDxcBlob **ppBlob) { +void MultiByteStringToBlob(dxc::DllLoader &dllSupport, const std::string &val, + UINT32 codePage, IDxcBlob **ppBlob) { MultiByteStringToBlob(dllSupport, val, codePage, (IDxcBlobEncoding **)ppBlob); } -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, +void Utf8ToBlob(dxc::DllLoader &dllSupport, const std::string &val, IDxcBlobEncoding **ppBlob) { MultiByteStringToBlob(dllSupport, val, CP_UTF8, ppBlob); } -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, +void Utf8ToBlob(dxc::DllLoader &dllSupport, const std::string &val, IDxcBlob **ppBlob) { Utf8ToBlob(dllSupport, val, (IDxcBlobEncoding **)ppBlob); } -void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, +void WideToBlob(dxc::DllLoader &dllSupport, const std::wstring &val, IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); @@ -343,12 +350,12 @@ void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, val.data(), val.size() * sizeof(wchar_t), DXC_CP_WIDE, ppBlob)); } -void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, +void WideToBlob(dxc::DllLoader &dllSupport, const std::wstring &val, IDxcBlob **ppBlob) { WideToBlob(dllSupport, val, (IDxcBlobEncoding **)ppBlob); } -void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, +void VerifyCompileOK(dxc::DllLoader &dllSupport, LPCSTR pText, LPCWSTR pTargetProfile, LPCWSTR pArgs, IDxcBlob **ppResult) { std::vector argsW; @@ -363,7 +370,7 @@ void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, VerifyCompileOK(dllSupport, pText, pTargetProfile, args, ppResult); } -void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, +void VerifyCompileOK(dxc::DllLoader &dllSupport, LPCSTR pText, LPCWSTR pTargetProfile, std::vector &args, IDxcBlob **ppResult) { CComPtr pCompiler; @@ -381,8 +388,8 @@ void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, VERIFY_SUCCEEDED(pResult->GetResult(ppResult)); } -HRESULT GetVersion(dxc::DxcDllSupport &DllSupport, REFCLSID clsid, - unsigned &Major, unsigned &Minor) { +HRESULT GetVersion(dxc::DllLoader &DllSupport, REFCLSID clsid, unsigned &Major, + unsigned &Minor) { CComPtr pUnk; if (SUCCEEDED(DllSupport.CreateInstance(clsid, &pUnk))) { CComPtr pVersionInfo; @@ -418,7 +425,7 @@ VersionSupportInfo::VersionSupportInfo() : m_CompilerIsDebugBuild(false), m_InternalValidator(false), m_DxilMajor(0), m_DxilMinor(0), m_ValMajor(0), m_ValMinor(0) {} -void VersionSupportInfo::Initialize(dxc::DxcDllSupport &dllSupport) { +void VersionSupportInfo::Initialize(dxc::DllLoader &dllSupport) { VERIFY_IS_TRUE(dllSupport.IsEnabled()); // Default to Dxil 1.0 and internal Val 1.0 diff --git a/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp b/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp index 2d9ee7315d..1fc0664fa9 100644 --- a/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp +++ b/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp @@ -59,7 +59,7 @@ FileRunCommandPart::FileRunCommandPart(const std::string &command, } FileRunCommandResult -FileRunCommandPart::RunHashTests(dxc::DxcDllSupport &DllSupport) { +FileRunCommandPart::RunHashTests(dxc::DllLoader &DllSupport) { if (0 == _stricmp(Command.c_str(), "%dxc")) { return RunDxcHashTest(DllSupport); } else { @@ -68,7 +68,7 @@ FileRunCommandPart::RunHashTests(dxc::DxcDllSupport &DllSupport) { } FileRunCommandResult -FileRunCommandPart::Run(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::Run(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior, PluginToolsPaths *pPluginToolsPaths /*=nullptr*/, LPCWSTR dumpName /*=nullptr*/) { @@ -302,7 +302,7 @@ static void AddOutputsToFileMap(IUnknown *pUnkResult, FileMap *pVFS) { static HRESULT CompileForHash(hlsl::options::DxcOpts &opts, LPCWSTR CommandFileName, - dxc::DxcDllSupport &DllSupport, + dxc::DllLoader &DllSupport, std::vector &flags, IDxcBlob **ppHashBlob, std::string &output) { CComPtr pLibrary; @@ -375,7 +375,7 @@ static HRESULT CompileForHash(hlsl::options::DxcOpts &opts, } FileRunCommandResult -FileRunCommandPart::RunDxcHashTest(dxc::DxcDllSupport &DllSupport) { +FileRunCommandPart::RunDxcHashTest(dxc::DllLoader &DllSupport) { hlsl::options::MainArgs args; hlsl::options::DxcOpts opts; ReadOptsForDxc(args, opts); @@ -453,7 +453,7 @@ FileRunCommandPart::RunDxcHashTest(dxc::DxcDllSupport &DllSupport) { return FileRunCommandResult::Success(); } -static FileRunCommandResult CheckDxilVer(dxc::DxcDllSupport &DllSupport, +static FileRunCommandResult CheckDxilVer(dxc::DllLoader &DllSupport, unsigned RequiredDxilMajor, unsigned RequiredDxilMinor, bool bCheckValidator = true) { @@ -487,7 +487,7 @@ static FileRunCommandResult CheckDxilVer(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunDxc(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunDxc(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { // Support piping stdin from prior if needed. UNREFERENCED_PARAMETER(Prior); @@ -597,7 +597,7 @@ FileRunCommandPart::RunDxc(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunDxv(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunDxv(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { std::string args(strtrim(Arguments)); const char *inputPos = strstr(args.c_str(), "%s"); @@ -650,7 +650,7 @@ FileRunCommandPart::RunDxv(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunOpt(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunOpt(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { std::string args(strtrim(Arguments)); const char *inputPos = strstr(args.c_str(), "%s"); @@ -701,7 +701,7 @@ FileRunCommandPart::RunOpt(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunListParts(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunListParts(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { std::string args(strtrim(Arguments)); const char *inputPos = strstr(args.c_str(), "%s"); @@ -769,7 +769,7 @@ FileRunCommandPart::RunListParts(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunD3DReflect(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunD3DReflect(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { std::string args(strtrim(Arguments)); if (args != "%s") @@ -865,7 +865,7 @@ FileRunCommandPart::RunD3DReflect(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunDxr(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunDxr(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { // Support piping stdin from prior if needed. UNREFERENCED_PARAMETER(Prior); @@ -918,7 +918,7 @@ FileRunCommandPart::RunDxr(dxc::DxcDllSupport &DllSupport, } FileRunCommandResult -FileRunCommandPart::RunLink(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunLink(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { hlsl::options::MainArgs args; hlsl::options::DxcOpts opts; @@ -1153,7 +1153,7 @@ FileRunCommandPart::RunXFail(const FileRunCommandResult *Prior) { } FileRunCommandResult -FileRunCommandPart::RunDxilVer(dxc::DxcDllSupport &DllSupport, +FileRunCommandPart::RunDxilVer(dxc::DllLoader &DllSupport, const FileRunCommandResult *Prior) { Arguments = strtrim(Arguments); if (Arguments.size() != 3 || !std::isdigit(Arguments[0]) || @@ -1258,7 +1258,7 @@ FileRunCommandPart::RunFromPath(const std::string &toolPath, #endif //_WIN32 class FileRunTestResultImpl : public FileRunTestResult { - dxc::DxcDllSupport &m_support; + dxc::DxCompilerDllLoader &m_support; PluginToolsPaths *m_pPluginToolsPaths; LPCWSTR m_dumpName = nullptr; // keep track of virtual files for duration of this test (for all RUN lines) @@ -1332,7 +1332,7 @@ class FileRunTestResultImpl : public FileRunTestResult { } public: - FileRunTestResultImpl(dxc::DxcDllSupport &support, + FileRunTestResultImpl(dxc::DxCompilerDllLoader &support, PluginToolsPaths *pPluginToolsPaths = nullptr, LPCWSTR dumpName = nullptr) : m_support(support), m_pPluginToolsPaths(pPluginToolsPaths), @@ -1371,7 +1371,7 @@ class FileRunTestResultImpl : public FileRunTestResult { FileRunTestResult FileRunTestResult::RunHashTestFromFileCommands(LPCWSTR fileName) { - dxc::DxcDllSupport dllSupport; + dxc::DxCompilerDllLoader dllSupport; IFT(dllSupport.Initialize()); FileRunTestResultImpl result(dllSupport); result.RunHashTestFromFileCommands(fileName); @@ -1381,7 +1381,7 @@ FileRunTestResult::RunHashTestFromFileCommands(LPCWSTR fileName) { FileRunTestResult FileRunTestResult::RunFromFileCommands( LPCWSTR fileName, PluginToolsPaths *pPluginToolsPaths /*=nullptr*/, LPCWSTR dumpName /*=nullptr*/) { - dxc::DxcDllSupport dllSupport; + dxc::DxCompilerDllLoader dllSupport; IFT(dllSupport.Initialize()); FileRunTestResultImpl result(dllSupport, pPluginToolsPaths, dumpName); result.RunFileCheckFromFileCommands(fileName); @@ -1389,7 +1389,7 @@ FileRunTestResult FileRunTestResult::RunFromFileCommands( } FileRunTestResult FileRunTestResult::RunFromFileCommands( - LPCWSTR fileName, dxc::DxcDllSupport &dllSupport, + LPCWSTR fileName, dxc::DxCompilerDllLoader &dllSupport, PluginToolsPaths *pPluginToolsPaths /*=nullptr*/, LPCWSTR dumpName /*=nullptr*/) { FileRunTestResultImpl result(dllSupport, pPluginToolsPaths, dumpName); diff --git a/tools/clang/unittests/SPIRV/LibTestUtils.cpp b/tools/clang/unittests/SPIRV/LibTestUtils.cpp index a5ec27977b..d5f5b32e5f 100644 --- a/tools/clang/unittests/SPIRV/LibTestUtils.cpp +++ b/tools/clang/unittests/SPIRV/LibTestUtils.cpp @@ -130,7 +130,7 @@ bool compileCodeWithSpirvGeneration(const llvm::StringRef code, rest.emplace_back(arg.begin(), arg.end()); try { - dxc::DxcDllSupport dllSupport; + dxc::DxCompilerDllLoader dllSupport; IFT(dllSupport.Initialize()); if (hlsl::options::initHlslOptTable()) diff --git a/tools/clang/unittests/dxc_batch/dxc_batch.cpp b/tools/clang/unittests/dxc_batch/dxc_batch.cpp index 1c3c86b46f..a642cacf78 100644 --- a/tools/clang/unittests/dxc_batch/dxc_batch.cpp +++ b/tools/clang/unittests/dxc_batch/dxc_batch.cpp @@ -68,7 +68,7 @@ class DxcContext { private: DxcOpts &m_Opts; - DxcDllSupport &m_dxcSupport; + SpecificDllLoader &m_dxcSupport; int ActOnBlob(IDxcBlob *pBlob); int ActOnBlob(IDxcBlob *pBlob, IDxcBlob *pDebugBlob, LPCWSTR pDebugBlobName); @@ -83,7 +83,7 @@ class DxcContext { int VerifyRootSignature(); public: - DxcContext(DxcOpts &Opts, DxcDllSupport &dxcSupport) + DxcContext(DxcOpts &Opts, SpecificDllLoader &dxcSupport) : m_Opts(Opts), m_dxcSupport(dxcSupport) {} int Compile(llvm::StringRef path, bool bLibLink); @@ -124,7 +124,7 @@ static void PrintHlslException(const ::hlsl::Exception &hlslException, } } -static int Compile(llvm::StringRef command, DxcDllSupport &dxcSupport, +static int Compile(llvm::StringRef command, SpecificDllLoader &dxcSupport, llvm::StringRef path, bool bLinkLib, std::string &errorString) { // llvm::raw_string_ostream &errorStream) { @@ -756,14 +756,14 @@ void DxcContext::WriteHeader(IDxcBlobEncoding *pDisassembly, IDxcBlob *pCode, class DxcBatchContext { public: - DxcBatchContext(DxcOpts &Opts, DxcDllSupport &dxcSupport) + DxcBatchContext(DxcOpts &Opts, SpecificDllLoader &dxcSupport) : m_Opts(Opts), m_dxcSupport(dxcSupport) {} int BatchCompile(bool bMultiThread, bool bLibLink); private: DxcOpts &m_Opts; - DxcDllSupport &m_dxcSupport; + SpecificDllLoader &m_dxcSupport; }; int DxcBatchContext::BatchCompile(bool bMultiThread, bool bLibLink) { @@ -880,7 +880,7 @@ int __cdecl wmain(int argc, const wchar_t **argv_) { MainArgs batchArgStrings(refArgs); DxcOpts dxcOpts; - DxcDllSupport dxcSupport; + LibraryDllLoader dxcSupport; // Read options and check errors. { @@ -913,7 +913,8 @@ int __cdecl wmain(int argc, const wchar_t **argv_) { { std::string dllErrorString; llvm::raw_string_ostream dllErrorStream(dllErrorString); - int dllResult = SetupDxcDllSupport(dxcOpts, dxcSupport, dllErrorStream); + int dllResult = + SetupSpecificDllLoader(dxcOpts, dxcSupport, dllErrorStream); dllErrorStream.flush(); if (dllErrorString.size()) { fprintf(stderr, "%s", dllErrorString.data());