diff --git a/CMakeLists.txt b/CMakeLists.txt index 5210718005..4bbf62afdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -662,6 +662,15 @@ if(LLVM_INCLUDE_TESTS AND WIN32) add_definitions(/DMSFT_SUPPORTS_CHILD_PROCESSES) endif() +if(EXISTS "${LLVM_MAIN_SRC_DIR}/external") + add_subdirectory(external) # SPIRV change +endif() +if(WIN32) + include_directories(${DIRECTX_HEADER_INCLUDE_DIR}/directx) +else() + include_directories(AFTER ${DIRECTX_HEADER_INCLUDE_DIR}/wsl/stubs ${DIRECTX_HEADER_INCLUDE_DIR}/directx) +endif() + # Put this before tblgen. Else we have a circular dependence. add_subdirectory(lib/Support) add_subdirectory(lib/MSSupport) # HLSL Change @@ -679,11 +688,6 @@ list(APPEND LLVM_COMMON_DEPENDS HCTGen) add_subdirectory(utils/hct) -if(EXISTS "${LLVM_MAIN_SRC_DIR}/external") - add_subdirectory(external) # SPIRV change -endif() -include_directories(AFTER ${DIRECTX_HEADER_INCLUDE_DIR}/directx ${DIRECTX_HEADER_INCLUDE_DIR}/wsl/stubs) - # HLSL - Change End add_subdirectory(lib) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index a8b2638e3d..b56bc1d2ab 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -9,13 +9,11 @@ endif (NOT HLSL_ENABLE_DEBUG_ITERATORS) # Need DirectX-Headers module if not on windows if (NOT DIRECTX_HEADER_INCLUDE_DIR) - if (NOT WIN32) - if (IS_DIRECTORY "${DXC_EXTERNAL_ROOT_DIR}/DirectX-Headers") - set(DIRECTX_HEADER_INCLUDE_DIR ${DXC_EXTERNAL_ROOT_DIR}/DirectX-Headers/include PARENT_SCOPE) - else() - message(FATAL_ERROR "DirectX-Headers was not found - required for reflection support on *nix see https://github.com/microsoft/DirectX-Headers") - endif() - endif (NOT WIN32) + if (IS_DIRECTORY "${DXC_EXTERNAL_ROOT_DIR}/DirectX-Headers") + set(DIRECTX_HEADER_INCLUDE_DIR ${DXC_EXTERNAL_ROOT_DIR}/DirectX-Headers/include PARENT_SCOPE) + else() + message(FATAL_ERROR "DirectX-Headers was not found - required for reflection support on *nix see https://github.com/microsoft/DirectX-Headers") + endif() endif(NOT DIRECTX_HEADER_INCLUDE_DIR) # Enabling SPIR-V codegen requires SPIRV-Headers for spirv.hpp and diff --git a/external/DirectX-Headers b/external/DirectX-Headers index 980971e835..ac66e97e62 160000 --- a/external/DirectX-Headers +++ b/external/DirectX-Headers @@ -1 +1 @@ -Subproject commit 980971e835876dc0cde415e8f9bc646e64667bf7 +Subproject commit ac66e97e625939923cda47c3cbfd00bebbfdabd0 diff --git a/include/dxc/Support/D3DReflection.h b/include/dxc/Support/D3DReflection.h index aeb004c7bb..4e5c0684b3 100644 --- a/include/dxc/Support/D3DReflection.h +++ b/include/dxc/Support/D3DReflection.h @@ -22,5 +22,5 @@ #undef interface #pragma GCC diagnostic pop #else -#include +#include "d3d12shader.h" #endif diff --git a/include/dxc/Support/Unicode.h b/include/dxc/Support/Unicode.h index 64e3abccd8..3f9442c1cd 100644 --- a/include/dxc/Support/Unicode.h +++ b/include/dxc/Support/Unicode.h @@ -14,6 +14,7 @@ #include #ifdef _WIN32 +typedef int *LPBOOL; #include #else // MultiByteToWideChar which is a Windows-specific method. @@ -30,7 +31,7 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t dwFlags, const wchar_t *lpWideCharStr, int cchWideChar, char *lpMultiByteStr, int cbMultiByte, const char *lpDefaultChar = nullptr, - bool *lpUsedDefaultChar = nullptr); + LPBOOL lpUsedDefaultChar = nullptr); #endif // _WIN32 namespace Unicode { @@ -54,14 +55,15 @@ typedef char acp_char; typedef char ccp_char; bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue, - bool *lossy); + LPBOOL lossy); -bool UTF8ToConsoleString(const char *text, std::string *pValue, bool *lossy); +bool UTF8ToConsoleString(const char *text, std::string *pValue, LPBOOL lossy); bool WideToConsoleString(const wchar_t *text, size_t textLen, - std::string *pValue, bool *lossy); + std::string *pValue, LPBOOL lossy); -bool WideToConsoleString(const wchar_t *text, std::string *pValue, bool *lossy); +bool WideToConsoleString(const wchar_t *text, std::string *pValue, + LPBOOL lossy); bool UTF8ToWideString(const char *pUTF8, std::wstring *pWide); diff --git a/include/dxc/WinAdapter.h b/include/dxc/WinAdapter.h index d02ad1ac38..a5c68f2fb7 100644 --- a/include/dxc/WinAdapter.h +++ b/include/dxc/WinAdapter.h @@ -33,6 +33,8 @@ #include #endif // __cplusplus +#include "../winadapter.h" //To avoid duplicates, some things are defined by WSL, some by dxc + #define COM_NO_WINDOWS_H // needed to inform d3d headers that this isn't windows //===----------------------------------------------------------------------===// @@ -40,7 +42,6 @@ // Begin: Macro Definitions // //===----------------------------------------------------------------------===// -#define C_ASSERT(expr) static_assert((expr), "") #define ATLASSERT assert #define CoTaskMemAlloc malloc @@ -48,8 +49,6 @@ #define ARRAYSIZE(array) (sizeof(array) / sizeof(array[0])) -#define _countof(a) (sizeof(a) / sizeof(*(a))) - // If it is GCC, there is no UUID support and we must emulate it. // Clang support depends on the -fms-extensions compiler flag. #if !defined(__clang__) || !defined(_MSC_EXTENSIONS) @@ -69,11 +68,6 @@ #define STDMETHODCALLTYPE #define STDMETHODIMP_(type) type STDMETHODCALLTYPE #define STDMETHODIMP STDMETHODIMP_(HRESULT) -#define STDMETHOD_(type, name) virtual STDMETHODIMP_(type) name -#define STDMETHOD(name) STDMETHOD_(HRESULT, name) -#define EXTERN_C extern "C" - -#define UNREFERENCED_PARAMETER(P) (void)(P) #define RtlEqualMemory(Destination, Source, Length) \ (!memcmp((Destination), (Source), (Length))) @@ -89,9 +83,6 @@ #define FillMemory RtlFillMemory #define ZeroMemory RtlZeroMemory -#define FALSE 0 -#define TRUE 1 - // We ignore the code page completely on Linux. #define GetConsoleOutputCP() 0 @@ -217,24 +208,9 @@ //===--------------------- HRESULT Related Macros -------------------------===// -#define S_OK ((HRESULT)0L) -#define S_FALSE ((HRESULT)1L) - -#define E_ABORT (HRESULT)0x80004004 -#define E_ACCESSDENIED (HRESULT)0x80070005 #define E_BOUNDS (HRESULT)0x8000000B -#define E_FAIL (HRESULT)0x80004005 -#define E_HANDLE (HRESULT)0x80070006 -#define E_INVALIDARG (HRESULT)0x80070057 -#define E_NOINTERFACE (HRESULT)0x80004002 -#define E_NOTIMPL (HRESULT)0x80004001 #define E_NOT_VALID_STATE (HRESULT)0x8007139F -#define E_OUTOFMEMORY (HRESULT)0x8007000E -#define E_POINTER (HRESULT)0x80004003 -#define E_UNEXPECTED (HRESULT)0x8000FFFF -#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -#define FAILED(hr) (((HRESULT)(hr)) < 0) #define DXC_FAILED(hr) (((HRESULT)(hr)) < 0) #define HRESULT_FROM_WIN32(x) \ @@ -246,16 +222,7 @@ // Begin: Disable SAL Annotations // //===----------------------------------------------------------------------===// -#define _In_ -#define _In_z_ -#define _In_opt_ -#define _In_opt_count_(size) -#define _In_opt_z_ -#define _In_count_(size) -#define _In_bytecount_(size) - -#define _Out_ -#define _Out_opt_ + #define _Outptr_ #define _Outptr_opt_ #define _Outptr_result_z_ @@ -265,15 +232,6 @@ #define _Outptr_result_buffer_maybenull_(ptr) #define _Outptr_result_buffer_(ptr) -#define _COM_Outptr_ -#define _COM_Outptr_opt_ -#define _COM_Outptr_result_maybenull_ -#define _COM_Outptr_opt_result_maybenull_ - -#define THIS_ -#define THIS -#define PURE = 0 - #define _Maybenull_ #define __debugbreak() @@ -297,53 +255,64 @@ #ifdef __cplusplus -typedef unsigned char BYTE, UINT8; -typedef unsigned char *LPBYTE; - -typedef BYTE BOOLEAN; +// Note: using fixed-width here to match Windows widths +// Specifically this is different for 'long' vs 'LONG' +typedef uint8_t UINT8; +typedef int8_t INT8; +typedef uint16_t UINT16; +typedef int16_t INT16; +typedef uint32_t UINT32, UINT, ULONG, DWORD, WINBOOL, BOOL; +typedef int32_t INT32, INT, LONG; +typedef uint64_t UINT64, ULONG_PTR; +typedef int64_t INT64, LONG_PTR; +typedef void VOID, *HANDLE, *RPC_IF_HANDLE, *LPVOID; +typedef const void *LPCVOID; +typedef size_t SIZE_T; +typedef float FLOAT; +typedef double DOUBLE; +typedef unsigned char BYTE; +typedef int HWND; +typedef int PALETTEENTRY; +typedef int HDC; +typedef uint16_t WORD; +typedef void *PVOID; +typedef char BOOLEAN; +typedef uint64_t ULONGLONG; +typedef uint16_t USHORT, *PUSHORT; +typedef int64_t LONGLONG, *PLONGLONG; +typedef int64_t LONG_PTR, *PLONG_PTR; +typedef int64_t LONG64, *PLONG64; +typedef uint64_t ULONG64, *PULONG64; +typedef wchar_t WCHAR, *PWSTR; +typedef uint8_t UCHAR, *PUCHAR; +typedef uint64_t ULONG_PTR, *PULONG_PTR; +typedef uint64_t UINT_PTR, *PUINT_PTR; +typedef int64_t INT_PTR, *PINT_PTR; + +// Note: WCHAR is not the same between Windows and Linux, to enable +// string manipulation APIs to work with resulting strings. +// APIs to D3D/DXCore will work on Linux wchars, but beware with +// interactions directly with the Windows kernel. +typedef char CHAR, *PSTR, *LPSTR, TCHAR, *PTSTR; +typedef const char *LPCSTR, *PCSTR, *LPCTSTR, *PCTSTR; +typedef wchar_t WCHAR, *PWSTR, *LPWSTR, *PWCHAR; +typedef const wchar_t *LPCWSTR, *PCWSTR; + +typedef BYTE *LPBYTE; typedef BOOLEAN *PBOOLEAN; -typedef bool BOOL; typedef BOOL *LPBOOL; -typedef int INT; -typedef long LONG; -typedef unsigned int UINT; -typedef unsigned long ULONG; -typedef long long LONGLONG; -typedef long long LONG_PTR; -typedef unsigned long long ULONG_PTR; -typedef unsigned long long ULONGLONG; - -typedef uint16_t WORD; -typedef uint32_t DWORD; typedef DWORD *LPDWORD; -typedef uint32_t UINT32; -typedef uint64_t UINT64; - -typedef signed char INT8, *PINT8; -typedef signed int INT32, *PINT32; - -typedef size_t SIZE_T; -typedef const char *LPCSTR; -typedef const char *PCSTR; +typedef INT8 *PINT8; +typedef INT32 *PINT32; typedef int errno_t; -typedef wchar_t WCHAR; -typedef wchar_t *LPWSTR; -typedef wchar_t *PWCHAR; -typedef const wchar_t *LPCWSTR; -typedef const wchar_t *PCWSTR; - typedef WCHAR OLECHAR; typedef OLECHAR *BSTR; typedef OLECHAR *LPOLESTR; -typedef char *LPSTR; - -typedef void *LPVOID; -typedef const void *LPCVOID; typedef std::nullptr_t nullptr_t; @@ -369,45 +338,11 @@ typedef void *HMODULE; //===--------------------- ID Types and Macros for COM --------------------===// -#ifdef __EMULATE_UUID -struct GUID -#else // __EMULATE_UUID -// These specific definitions are required by clang -fms-extensions. -typedef struct _GUID -#endif // __EMULATE_UUID -{ - uint32_t Data1; - uint16_t Data2; - uint16_t Data3; - uint8_t Data4[8]; -} -#ifdef __EMULATE_UUID -; -#else // __EMULATE_UUID -GUID; -#endif // __EMULATE_UUID -typedef GUID CLSID; typedef const GUID &REFGUID; typedef const GUID &REFCLSID; -typedef GUID IID; typedef IID *LPIID; typedef const IID &REFIID; -inline bool IsEqualGUID(REFGUID rguid1, REFGUID rguid2) { - // Optimization: - if (&rguid1 == &rguid2) - return true; - - return !memcmp(&rguid1, &rguid2, sizeof(GUID)); -} - -inline bool operator==(REFGUID guidOne, REFGUID guidOther) { - return !!IsEqualGUID(guidOne, guidOther); -} - -inline bool operator!=(REFGUID guidOne, REFGUID guidOther) { - return !(guidOne == guidOther); -} inline bool IsEqualIID(REFIID riid1, REFIID riid2) { return IsEqualGUID(riid1, riid2); @@ -451,26 +386,6 @@ typedef struct _WIN32_FIND_DATAW { WCHAR cAlternateFileName[14]; } WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW; -typedef union _LARGE_INTEGER { - struct { - DWORD LowPart; - DWORD HighPart; - } u; - LONGLONG QuadPart; -} LARGE_INTEGER; - -typedef LARGE_INTEGER *PLARGE_INTEGER; - -typedef union _ULARGE_INTEGER { - struct { - DWORD LowPart; - DWORD HighPart; - } u; - ULONGLONG QuadPart; -} ULARGE_INTEGER; - -typedef ULARGE_INTEGER *PULARGE_INTEGER; - typedef struct tagSTATSTG { LPOLESTR pwcsName; DWORD type; @@ -493,8 +408,6 @@ enum tagSTATFLAG { //===--------------------- UUID Related Macros ----------------------------===// -#ifdef __EMULATE_UUID - // The following macros are defined to facilitate the lack of 'uuid' on Linux. constexpr uint8_t nybble_from_hex(char c) { @@ -531,56 +444,50 @@ constexpr GUID guid_from_string(const char str[37]) { byte_from_hexstr(str + 32), byte_from_hexstr(str + 34)}}; } -template inline GUID __emulated_uuidof(); +#ifdef __EMULATE_UUID + +template inline GUID __emulated_uuidof(); -#define CROSS_PLATFORM_UUIDOF(interface, spec) \ - struct interface; \ - template <> inline GUID __emulated_uuidof() { \ +#define CROSS_PLATFORM_UUIDOF(interfce, spec) \ + struct interfce; \ + template <> inline GUID __emulated_uuidof() { \ static const IID _IID = guid_from_string(spec); \ return _IID; \ + } \ + extern "C++" { \ + template <> inline const GUID &__wsl_stub_uuidof() { \ + static const IID _IID = guid_from_string(spec); \ + return _IID; \ + } \ + template <> inline const GUID &__wsl_stub_uuidof() { \ + return __wsl_stub_uuidof(); \ + } \ } -#define __uuidof(T) __emulated_uuidof::type>() - -#define IID_PPV_ARGS(ppType) \ - __uuidof(decltype(**(ppType))), reinterpret_cast(ppType) - #else // __EMULATE_UUID -#ifndef CROSS_PLATFORM_UUIDOF +#ifndef _WIN32 +#define CROSS_PLATFORM_UUIDOF(interfce, spec) \ + struct __declspec(uuid(spec)) interfce; \ + extern "C++" { \ + template <> inline const GUID &__wsl_stub_uuidof() { \ + static const IID _IID = guid_from_string(spec); \ + return _IID; \ + } \ + template <> inline const GUID &__wsl_stub_uuidof() { \ + return __wsl_stub_uuidof(); \ + } \ + } +#elif !defined(CROSS_PLATFORM_UUIDOF) // Warning: This macro exists in dxcapi.h as well -#define CROSS_PLATFORM_UUIDOF(interface, spec) \ - struct __declspec(uuid(spec)) interface; +#define CROSS_PLATFORM_UUIDOF(interfce, spec) \ + struct __declspec(uuid(spec)) interfce; #endif -template inline void **IID_PPV_ARGS_Helper(T **pp) { - return reinterpret_cast(pp); -} -#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType) - #endif // __EMULATE_UUID -// Needed for d3d headers, but fail to create actual interfaces -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}} -#define DECLSPEC_UUID(x) -#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x) -#define DECLARE_INTERFACE(iface) struct iface -#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent - //===--------------------- COM Interfaces ---------------------------------===// -CROSS_PLATFORM_UUIDOF(IUnknown, "00000000-0000-0000-C000-000000000046") -struct IUnknown { - IUnknown(){}; - virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) = 0; - virtual ULONG AddRef() = 0; - virtual ULONG Release() = 0; - template HRESULT QueryInterface(Q **pp) { - return QueryInterface(__uuidof(Q), (void **)pp); - } -}; - CROSS_PLATFORM_UUIDOF(INoMarshal, "ECC8691B-C1DB-4DC0-855E-65F6C551AF49") struct INoMarshal : public IUnknown {}; diff --git a/lib/DxcSupport/Unicode.cpp b/lib/DxcSupport/Unicode.cpp index 1481ae27ff..be4bcfa005 100644 --- a/lib/DxcSupport/Unicode.cpp +++ b/lib/DxcSupport/Unicode.cpp @@ -79,7 +79,7 @@ int WideCharToMultiByte(uint32_t /*CodePage*/, uint32_t /*dwFlags*/, const wchar_t *lpWideCharStr, int cchWideChar, char *lpMultiByteStr, int cbMultiByte, const char * /*lpDefaultChar*/, - bool *lpUsedDefaultChar) { + LPBOOL lpUsedDefaultChar) { if (lpUsedDefaultChar) { *lpUsedDefaultChar = FALSE; } @@ -132,7 +132,7 @@ int WideCharToMultiByte(uint32_t /*CodePage*/, uint32_t /*dwFlags*/, namespace Unicode { bool WideToEncodedString(const wchar_t *text, size_t cWide, DWORD cp, - DWORD flags, std::string *pValue, bool *lossy) { + DWORD flags, std::string *pValue, LPBOOL lossy) { BOOL usedDefaultChar; LPBOOL pUsedDefaultChar = (lossy == nullptr) ? nullptr : &usedDefaultChar; if (lossy != nullptr) @@ -204,7 +204,7 @@ std::wstring UTF8ToWideStringOrThrow(const char *pUTF8) { } bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue, - bool *lossy) { + LPBOOL lossy) { DXASSERT_NOMSG(text != nullptr); DXASSERT_NOMSG(pValue != nullptr); std::wstring text16; @@ -216,12 +216,12 @@ bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue, return WideToConsoleString(text16.c_str(), text16.length(), pValue, lossy); } -bool UTF8ToConsoleString(const char *text, std::string *pValue, bool *lossy) { +bool UTF8ToConsoleString(const char *text, std::string *pValue, LPBOOL lossy) { return UTF8ToConsoleString(text, strlen(text), pValue, lossy); } bool WideToConsoleString(const wchar_t *text, size_t textLen, - std::string *pValue, bool *lossy) { + std::string *pValue, LPBOOL lossy) { DXASSERT_NOMSG(text != nullptr); DXASSERT_NOMSG(pValue != nullptr); UINT cp = GetConsoleOutputCP(); @@ -229,7 +229,7 @@ bool WideToConsoleString(const wchar_t *text, size_t textLen, } bool WideToConsoleString(const wchar_t *text, std::string *pValue, - bool *lossy) { + LPBOOL lossy) { return WideToConsoleString(text, wcslen(text), pValue, lossy); } diff --git a/lib/DxcSupport/dxcapi.use.cpp b/lib/DxcSupport/dxcapi.use.cpp index fed47e2e86..e25463155b 100644 --- a/lib/DxcSupport/dxcapi.use.cpp +++ b/lib/DxcSupport/dxcapi.use.cpp @@ -114,7 +114,7 @@ static void WriteWideNullTermToConsole(const wchar_t *pText, DWORD streamType) { return; } - bool lossy; // Note: even if there was loss, print anyway + BOOL lossy; // Note: even if there was loss, print anyway std::string consoleMessage; Unicode::WideToConsoleString(pText, &consoleMessage, &lossy); if (streamType == STD_OUTPUT_HANDLE) { diff --git a/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp b/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp index c485709c57..ac50370052 100644 --- a/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp +++ b/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp @@ -373,7 +373,7 @@ int __cdecl wmain(int argc, wchar_t **argv) { } std::string textMessage; - bool lossy; + BOOL lossy; if (!Unicode::UTF8ToConsoleString(pMsg, &textMessage, &lossy) || lossy) { // Do a direct assignment as a last-ditch effort and print out as UTF-8. textMessage = pMsg; diff --git a/tools/clang/include/clang/AST/Attr.h b/tools/clang/include/clang/AST/Attr.h index 4e282d68b7..8abc524ba7 100644 --- a/tools/clang/include/clang/AST/Attr.h +++ b/tools/clang/include/clang/AST/Attr.h @@ -149,6 +149,7 @@ class InheritableParamAttr : public InheritableAttr { } }; +#undef interface #include "clang/AST/Attrs.inc" inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, diff --git a/tools/clang/tools/dxcvalidator/dxcvalidator.cpp b/tools/clang/tools/dxcvalidator/dxcvalidator.cpp index 60ad35036f..e07bc59db6 100644 --- a/tools/clang/tools/dxcvalidator/dxcvalidator.cpp +++ b/tools/clang/tools/dxcvalidator/dxcvalidator.cpp @@ -77,7 +77,7 @@ static void HashAndUpdateOrCopy(uint32_t Flags, IDxcBlob *Shader, } else { CComPtr HashedBlobStream; IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &HashedBlobStream)); - unsigned long CB; + ULONG CB; IFT(HashedBlobStream->Write(Shader->GetBufferPointer(), Shader->GetBufferSize(), &CB)); HashAndUpdate((DxilContainerHeader *)HashedBlobStream->GetPtr(), diff --git a/tools/clang/tools/dxr/dxr.cpp b/tools/clang/tools/dxr/dxr.cpp index 86d20c57a5..751751ec92 100644 --- a/tools/clang/tools/dxr/dxr.cpp +++ b/tools/clang/tools/dxr/dxr.cpp @@ -172,7 +172,7 @@ int main(int argc, const char **argv) { } std::string textMessage; - bool lossy; + BOOL lossy; if (!Unicode::UTF8ToConsoleString(msg, &textMessage, &lossy) || lossy) { // Do a direct assignment as a last-ditch effort and print out as UTF-8. textMessage = msg; diff --git a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp index 67c57f9f0a..3965f45607 100644 --- a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp +++ b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp @@ -69,6 +69,46 @@ #pragma comment(lib, "dxguid.lib") #pragma comment(lib, "version.lib") +// A more recent Windows SDK than currently required is needed for these. +typedef HRESULT(WINAPI *D3D12EnableExperimentalFeaturesFn)( + UINT NumFeatures, __in_ecount(NumFeatures) const IID *pIIDs, + __in_ecount_opt(NumFeatures) void *pConfigurationStructs, + __in_ecount_opt(NumFeatures) UINT *pConfigurationStructSizes); + +// Used to create D3D12SDKConfiguration to enable AgilitySDK programmatically. +typedef HRESULT(WINAPI *D3D12GetInterfaceFn)(REFCLSID rclsid, REFIID riid, + void **ppvDebug); + +#ifndef __ID3D12SDKConfiguration_INTERFACE_DEFINED__ +// Copied from AgilitySDK D3D12.h to programmatically enable when in developer +// mode. +#define __ID3D12SDKConfiguration_INTERFACE_DEFINED__ + +EXTERN_C const GUID DECLSPEC_SELECTANY IID_ID3D12SDKConfiguration = { + 0xe9eb5314, + 0x33aa, + 0x42b2, + {0xa7, 0x18, 0xd7, 0x7f, 0x58, 0xb1, 0xf1, 0xc7}}; +EXTERN_C const GUID DECLSPEC_SELECTANY CLSID_D3D12SDKConfiguration = { + 0x7cda6aca, + 0xa03e, + 0x49c8, + {0x94, 0x58, 0x03, 0x34, 0xd2, 0x0e, 0x07, 0xce}}; + +MIDL_INTERFACE("e9eb5314-33aa-42b2-a718-d77f58b1f1c7") +ID3D12SDKConfiguration : public IUnknown { +public: + virtual HRESULT STDMETHODCALLTYPE SetSDKVersion(UINT SDKVersion, + LPCSTR SDKPath) = 0; +}; +#elif defined(_WIN32) +EXTERN_C const GUID DECLSPEC_SELECTANY CLSID_D3D12SDKConfiguration = { + 0x7cda6aca, + 0xa03e, + 0x49c8, + {0x94, 0x58, 0x03, 0x34, 0xd2, 0x0e, 0x07, 0xce}}; +#endif /* __ID3D12SDKConfiguration_INTERFACE_DEFINED__ */ + using namespace DirectX; using namespace hlsl_test; diff --git a/tools/dxexp/dxexp.cpp b/tools/dxexp/dxexp.cpp index 4787200318..5ae24fbde9 100644 --- a/tools/dxexp/dxexp.cpp +++ b/tools/dxexp/dxexp.cpp @@ -42,150 +42,6 @@ static HRESULT AtlCheck(HRESULT hr) { return hr; } -// Not defined in Creators Update version of d3d12.h: -#if WDK_NTDDI_VERSION <= NTDDI_WIN10_RS2 -#define D3D12_FEATURE_D3D12_OPTIONS3 ((D3D12_FEATURE)21) -typedef enum D3D12_COMMAND_LIST_SUPPORT_FLAGS { - D3D12_COMMAND_LIST_SUPPORT_FLAG_NONE = 0, - D3D12_COMMAND_LIST_SUPPORT_FLAG_DIRECT = - (1 << D3D12_COMMAND_LIST_TYPE_DIRECT), - D3D12_COMMAND_LIST_SUPPORT_FLAG_BUNDLE = - (1 << D3D12_COMMAND_LIST_TYPE_BUNDLE), - D3D12_COMMAND_LIST_SUPPORT_FLAG_COMPUTE = - (1 << D3D12_COMMAND_LIST_TYPE_COMPUTE), - D3D12_COMMAND_LIST_SUPPORT_FLAG_COPY = (1 << D3D12_COMMAND_LIST_TYPE_COPY), - D3D12_COMMAND_LIST_SUPPORT_FLAG_VIDEO_DECODE = (1 << 4), - D3D12_COMMAND_LIST_SUPPORT_FLAG_VIDEO_PROCESS = (1 << 5) -} D3D12_COMMAND_LIST_SUPPORT_FLAGS; - -typedef enum D3D12_VIEW_INSTANCING_TIER { - D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED = 0, - D3D12_VIEW_INSTANCING_TIER_1 = 1, - D3D12_VIEW_INSTANCING_TIER_2 = 2, - D3D12_VIEW_INSTANCING_TIER_3 = 3 -} D3D12_VIEW_INSTANCING_TIER; - -typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS3 { - BOOL CopyQueueTimestampQueriesSupported; - BOOL CastingFullyTypedFormatSupported; - DWORD WriteBufferImmediateSupportFlags; - D3D12_VIEW_INSTANCING_TIER ViewInstancingTier; - BOOL BarycentricsSupported; -} D3D12_FEATURE_DATA_D3D12_OPTIONS3; -#endif - -#ifndef NTDDI_WIN10_RS3 -#define NTDDI_WIN10_RS3 0x0A000004 -#endif - -#if WDK_NTDDI_VERSION <= NTDDI_WIN10_RS3 -#define D3D12_FEATURE_D3D12_OPTIONS4 ((D3D12_FEATURE)23) -typedef enum D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER { - D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0, - D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_1, -} D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER; - -typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS4 { - BOOL ReservedBufferPlacementSupported; - D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; - BOOL Native16BitShaderOpsSupported; -} D3D12_FEATURE_DATA_D3D12_OPTIONS4; -#endif - -#ifndef NTDDI_WIN10_RS4 -#define NTDDI_WIN10_RS4 0x0A000005 -#endif - -#if WDK_NTDDI_VERSION <= NTDDI_WIN10_RS4 -#define D3D12_FEATURE_D3D12_OPTIONS5 ((D3D12_FEATURE)27) -typedef enum D3D12_RENDER_PASS_TIER { - D3D12_RENDER_PASS_TIER_0 = 0, - D3D12_RENDER_PASS_TIER_1 = 1, - D3D12_RENDER_PASS_TIER_2 = 2 -} D3D12_RENDER_PASS_TIER; - -typedef enum D3D12_RAYTRACING_TIER { - D3D12_RAYTRACING_TIER_NOT_SUPPORTED = 0, - D3D12_RAYTRACING_TIER_1_0 = 10 D3D12_RAYTRACING_TIER_1_1 = 11 -} D3D12_RAYTRACING_TIER; - -typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS5 { - BOOL SRVOnlyTiledResourceTier3; - D3D12_RENDER_PASS_TIER RenderPassesTier; - D3D12_RAYTRACING_TIER RaytracingTier; -} D3D12_FEATURE_DATA_D3D12_OPTIONS5; -#endif - -#ifndef NTDDI_WIN10_VB -#define NTDDI_WIN10_VB 0x0A000008 -#endif - -#if WDK_NTDDI_VERSION < NTDDI_WIN10_VB -#define D3D12_FEATURE_D3D12_OPTIONS7 ((D3D12_FEATURE)32) - -typedef enum D3D12_MESH_SHADER_TIER { - D3D12_MESH_SHADER_TIER_NOT_SUPPORTED = 0, - D3D12_MESH_SHADER_TIER_1 = 10 -} D3D12_MESH_SHADER_TIER; - -typedef enum D3D12_SAMPLER_FEEDBACK_TIER { - D3D12_SAMPLER_FEEDBACK_TIER_NOT_SUPPORTED = 0, - D3D12_SAMPLER_FEEDBACK_TIER_0_9 = 90, - D3D12_SAMPLER_FEEDBACK_TIER_1_0 = 100 -} D3D12_SAMPLER_FEEDBACK_TIER; - -typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS7 { - D3D12_MESH_SHADER_TIER MeshShaderTier; - D3D12_SAMPLER_FEEDBACK_TIER SamplerFeedbackTier; -} D3D12_FEATURE_DATA_D3D12_OPTIONS7; -#endif - -#ifndef NTDDI_WIN10_FE -#define NTDDI_WIN10_FE 0x0A00000A -#endif - -#if WDK_NTDDI_VERSION < NTDDI_WIN10_FE -#define D3D12_FEATURE_D3D12_OPTIONS9 ((D3D12_FEATURE)37) - -typedef enum D3D12_WAVE_MMA_TIER { - D3D12_WAVE_MMA_TIER_NOT_SUPPORTED = 0, - D3D12_WAVE_MMA_TIER_1_0 = 10 -} D3D12_WAVE_MMA_TIER; - -typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS9 { - BOOL MeshShaderPipelineStatsSupported; - BOOL MeshShaderSupportsFullRangeRenderTargetArrayIndex; - BOOL AtomicInt64OnTypedResourceSupported; - BOOL AtomicInt64OnGroupSharedSupported; - BOOL DerivativesInMeshAndAmplificationShadersSupported; - D3D12_WAVE_MMA_TIER WaveMMATier; -} D3D12_FEATURE_DATA_D3D12_OPTIONS9; -#endif - -#ifndef NTDDI_WIN10_NI -#define NTDDI_WIN10_NI 0x0A00000C -#endif - -#if WDK_NTDDI_VERSION <= NTDDI_WIN10_NI -#define D3D12_FEATURE_D3D12_OPTIONS14 ((D3D12_FEATURE)43) -typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS14 { - BOOL AdvancedTextureOpsSupported; - BOOL WriteableMSAATexturesSupported; - BOOL IndependentFrontAndBackStencilRefMaskSupported; -} D3D12_FEATURE_DATA_D3D12_OPTIONS14; -#endif - -#pragma warning(disable : 4063) -#define D3D12_RAYTRACING_TIER_1_1 ((D3D12_RAYTRACING_TIER)11) -#define D3D_SHADER_MODEL_6_1 ((D3D_SHADER_MODEL)0x61) -#define D3D_SHADER_MODEL_6_2 ((D3D_SHADER_MODEL)0x62) -#define D3D_SHADER_MODEL_6_3 ((D3D_SHADER_MODEL)0x63) -#define D3D_SHADER_MODEL_6_4 ((D3D_SHADER_MODEL)0x64) -#define D3D_SHADER_MODEL_6_5 ((D3D_SHADER_MODEL)0x65) -#define D3D_SHADER_MODEL_6_6 ((D3D_SHADER_MODEL)0x66) -#define D3D_SHADER_MODEL_6_7 ((D3D_SHADER_MODEL)0x67) -#define D3D_SHADER_MODEL_6_8 ((D3D_SHADER_MODEL)0x68) - #define DXEXP_HIGHEST_SHADER_MODEL D3D_SHADER_MODEL_6_8 static const char *BoolToStrJson(bool value) {