diff options
Diffstat (limited to 'source/compiler-core')
| -rw-r--r-- | source/compiler-core/slang-dxc-compiler.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/source/compiler-core/slang-dxc-compiler.cpp b/source/compiler-core/slang-dxc-compiler.cpp index a39503b13..a275143f8 100644 --- a/source/compiler-core/slang-dxc-compiler.cpp +++ b/source/compiler-core/slang-dxc-compiler.cpp @@ -24,24 +24,39 @@ #include "slang-artifact-diagnostic-util.h" #include "slang-artifact-desc-util.h" +// Enable DXIL by default unless told not to +#ifndef SLANG_ENABLE_DXIL_SUPPORT +# define SLANG_ENABLE_DXIL_SUPPORT 1 +#endif + // Enable calling through to `dxc` to // generate code on Windows. -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# define NOMINMAX -# include <Windows.h> -# include <Unknwn.h> -# include "../../external/dxc/dxcapi.h" -# undef WIN32_LEAN_AND_MEAN -# undef NOMINMAX - -# ifndef SLANG_ENABLE_DXIL_SUPPORT -# define SLANG_ENABLE_DXIL_SUPPORT 1 +#if SLANG_ENABLE_DXIL_SUPPORT + +# ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# define NOMINMAX +# include <Windows.h> +# include <Unknwn.h> +# include "../../external/dxc/dxcapi.h" +# undef WIN32_LEAN_AND_MEAN +# undef NOMINMAX +# else +# include "../../external/dxc/dxcapi.h" + +# ifdef __uuidof + // DXC's WinAdapter.h defines __uuidof(T) over types, but the existing + // usage in this file is over values (both are accepted on MSVC.) + // We also need to decay through Slang::ComPtr, hence the helper struct + template <typename T> + struct StripSlangComPtr { using type = T; }; + template <typename T> + struct StripSlangComPtr<Slang::ComPtr<T>> { using type = T; }; +# undef __uuidof +# define __uuidof(x) __emulated_uuidof<StripSlangComPtr<std::decay_t<decltype(x)>>::type>() +# endif # endif -#endif -#ifndef SLANG_ENABLE_DXIL_SUPPORT -# define SLANG_ENABLE_DXIL_SUPPORT 0 #endif namespace Slang @@ -93,7 +108,7 @@ class DxcIncludeHandler : public IDxcIncludeHandler { public: // Implement IUnknown - SLANG_NO_THROW HRESULT SLANG_MCALL QueryInterface(const IID& uuid, void** out) + SLANG_NO_THROW HRESULT SLANG_MCALL QueryInterface(const IID& uuid, void** out) override { ISlangUnknown* intf = getInterface(reinterpret_cast<const Guid&>(uuid)); if (intf) @@ -739,7 +754,7 @@ SlangResult DXCDownstreamCompiler::getVersionString(slang::IBlob** outVersionStr else { // If we don't have the commitHash, we use the library timestamp, to uniquely identify. - versionString << " " << SharedLibraryUtils::getSharedLibraryTimestamp(m_createInstance); + versionString << " " << SharedLibraryUtils::getSharedLibraryTimestamp(reinterpret_cast<void*>(m_createInstance)); } *outVersionString = StringBlob::moveCreate(versionString).detach(); |
