Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,13 @@ include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})

include_directories( ${LLVM_INCLUDE_DIR}/dxc/Tracing) # HLSL Change

# HLSL - Change Start - Make DirectX-Headers includes visible to all targets
if(EXISTS "${LLVM_MAIN_SRC_DIR}/external")
add_subdirectory(external) # SPIRV change
endif()
include_directories(AFTER ${DIRECTX_HEADER_INCLUDE_DIR} ${DIRECTX_HEADER_INCLUDE_DIR}/directx ${DIRECTX_HEADER_INCLUDE_DIR}/wsl/stubs)
# HLSL Change Ends

# when crosscompiling import the executable targets from a file
if(LLVM_USE_HOST_TOOLS)
include(CrossCompile)
Expand Down Expand Up @@ -679,10 +686,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

Expand Down
2 changes: 1 addition & 1 deletion external/DirectX-Headers
Submodule DirectX-Headers updated 67 files
+6 −0 .github/dependabot.yml
+57 −0 .github/workflows/codeql.yml
+95 −0 .github/workflows/main.yml
+53 −0 .github/workflows/msvc.yml
+63 −0 .github/workflows/uwp.yml
+42 −0 .github/workflows/wsl.yml
+23 −0 .gitignore
+43 −17 CMakeLists.txt
+224 −0 CMakePresets.json
+10 −0 CODE_OF_CONDUCT.md
+41 −41 SECURITY.md
+10 −0 cmake/DirectX-Headers.pc.in
+23 −0 cmake/JoinPaths.cmake
+32 −2 googletest/CMakeLists.txt
+184 −137 googletest/MockDevice.hpp
+2 −0 googletest/feature_support_test.cpp
+13 −0 googletest/meson.build
+85 −0 include/composition/dcomp-preview.h
+119 −0 include/directx/D3D12MarkerApiEnums.idl
+2,634 −0 include/directx/D3D12TokenizedProgramFormat.hpp
+2,651 −0 include/directx/DirectML.h
+20,151 −6,744 include/directx/d3d12.h
+1,823 −328 include/directx/d3d12.idl
+247 −7 include/directx/d3d12compatibility.h
+15 −4 include/directx/d3d12compatibility.idl
+977 −0 include/directx/d3d12compiler.h
+290 −0 include/directx/d3d12compiler.idl
+489 −19 include/directx/d3d12sdklayers.h
+177 −24 include/directx/d3d12sdklayers.idl
+34 −28 include/directx/d3d12shader.h
+2,388 −100 include/directx/d3d12video.h
+1,509 −169 include/directx/d3d12video.idl
+64 −4 include/directx/d3dcommon.h
+78 −4 include/directx/d3dcommon.idl
+998 −0 include/directx/d3dshadercacheregistration.h
+194 −0 include/directx/d3dshadercacheregistration.idl
+12 −5,039 include/directx/d3dx12.h
+192 −0 include/directx/d3dx12_barriers.h
+1,193 −0 include/directx/d3dx12_check_feature_support.h
+2,071 −0 include/directx/d3dx12_core.h
+12 −0 include/directx/d3dx12_default.h
+1,717 −0 include/directx/d3dx12_pipeline_state_stream.h
+128 −0 include/directx/d3dx12_property_format_table.h
+105 −0 include/directx/d3dx12_render_pass.h
+611 −0 include/directx/d3dx12_resource_helpers.h
+1,227 −0 include/directx/d3dx12_root_signature.h
+2,573 −0 include/directx/d3dx12_state_object.h
+184 −3 include/directx/dxcore_interface.h
+1 −0 include/directx/dxgicommon.idl
+2 −0 include/directx/dxgiformat.h
+2 −0 include/directx/dxgiformat.idl
+113 −12 include/dxguids/dxguids.h
+406 −0 include/wsl/stubs/basetsd.h
+0 −0 include/wsl/stubs/oaidl.h
+0 −0 include/wsl/stubs/ocidl.h
+73 −1 include/wsl/stubs/rpcndr.h
+3 −0 include/wsl/stubs/unknwn.h
+124 −0 include/wsl/stubs/unknwnbase.h
+1 −400 include/wsl/winadapter.h
+7 −7 include/wsl/wrladapter.h
+33 −4 meson.build
+2,591 −0 src/d3dx12_property_format_table.cpp
+2 −3 src/dxguids.cpp
+56 −4 test/CMakeLists.txt
+132 −38 test/feature_check_test.cpp
+11 −5 test/meson.build
+16 −3 test/test.cpp
14 changes: 6 additions & 8 deletions include/dxc/Support/Unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
// MultiByteToWideChar which is a Windows-specific method.
// This is a very simplistic implementation for non-Windows platforms. This
// implementation completely ignores CodePage and dwFlags.
int MultiByteToWideChar(uint32_t CodePage, uint32_t dwFlags,
const char *lpMultiByteStr, int cbMultiByte,
wchar_t *lpWideCharStr, int cchWideChar);
int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCCH lpMultiByteStr,
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);

// WideCharToMultiByte is a Windows-specific method.
// This is a very simplistic implementation for non-Windows platforms. This
// implementation completely ignores CodePage and dwFlags.
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);
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr,
int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte,
LPCCH lpDefaultChar = nullptr,
LPBOOL lpUsedDefaultChar = nullptr);
#endif // _WIN32

namespace Unicode {
Expand Down
228 changes: 45 additions & 183 deletions include/dxc/WinAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,35 @@
#include <vector>
#endif // __cplusplus

// Include DirectX-Headers winadapter header. This is a required dependency on
// non-Windows.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnewline-eof"
#pragma clang diagnostic ignored "-Wcast-qual"
#endif

#include "wsl/winadapter.h"

#ifdef __clang__
#pragma clang diagnostic pop
#endif

// Undef certain macros from DirectX-Headers that collide with names used in the
// codebase
#undef OUT
#undef IN
#undef interface
#undef HeapAlloc
#undef HeapFree

#define COM_NO_WINDOWS_H // needed to inform d3d headers that this isn't windows

//===----------------------------------------------------------------------===//
//
// Begin: Macro Definitions
//
//===----------------------------------------------------------------------===//
#define C_ASSERT(expr) static_assert((expr), "")
#define ATLASSERT assert

#define CoTaskMemAlloc malloc
Expand All @@ -66,14 +87,8 @@
#define uuid(id)
#endif // __EMULATE_UUID

#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)))
Expand All @@ -89,9 +104,6 @@
#define FillMemory RtlFillMemory
#define ZeroMemory RtlZeroMemory

#define FALSE 0
#define TRUE 1

// We ignore the code page completely on Linux.
#define GetConsoleOutputCP() 0

Expand Down Expand Up @@ -220,21 +232,9 @@
#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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably the defines removed here conflicted with ones in DirectX headers? Are the remaining ones still required?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and yes. Both E_BOUNDS and E_NOT_VALID_STATE are used in the DXC codebase, but are not defined in wsl/stubs/basetsd.h (DirectX-Includes).

#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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does DXC_FAILED still need to exist?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in a few places. It could be removed and replaced with FAILED, but that should be done in a follow-up change, I think.


#define HRESULT_FROM_WIN32(x) \
Expand Down Expand Up @@ -270,10 +270,6 @@
#define _COM_Outptr_result_maybenull_
#define _COM_Outptr_opt_result_maybenull_

#define THIS_
#define THIS
#define PURE = 0

#define _Maybenull_

#define __debugbreak()
Expand All @@ -297,57 +293,17 @@

#ifdef __cplusplus

typedef unsigned char BYTE, UINT8;
typedef unsigned char *LPBYTE;

typedef BYTE BOOLEAN;
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 const char *LPCCH;
typedef const wchar_t *LPCWCH;
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 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;

typedef signed int HRESULT;

//===--------------------- Handle Types -----------------------------------===//

Expand All @@ -367,54 +323,12 @@ typedef void *HMODULE;
#define STD_OUTPUT_HANDLE ((DWORD)-11)
#define STD_ERROR_HANDLE ((DWORD)-12)

//===--------------------- ID Types and Macros for COM --------------------===//
//===--------------------- Functions 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);
}
inline bool IsEqualIID(REFIID riid1, REFIID riid2) { return riid1 == riid2; }

inline bool IsEqualCLSID(REFCLSID rclsid1, REFCLSID rclsid2) {
return IsEqualGUID(rclsid1, rclsid2);
return rclsid1 == rclsid2;
}

//===--------------------- Struct Types -----------------------------------===//
Expand Down Expand Up @@ -451,27 +365,7 @@ 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 {
struct STATSTG {
LPOLESTR pwcsName;
DWORD type;
ULARGE_INTEGER cbSize;
Expand All @@ -483,7 +377,7 @@ typedef struct tagSTATSTG {
CLSID clsid;
DWORD grfStateBits;
DWORD reserved;
} STATSTG;
};

enum tagSTATFLAG {
STATFLAG_DEFAULT = 0,
Expand Down Expand Up @@ -514,36 +408,23 @@ constexpr uint8_t byte_from_hexstr(const char str[2]) {
return nybble_from_hex(str[0]) << 4 | nybble_from_hex(str[1]);
}

constexpr GUID guid_from_string(const char str[37]) {
return GUID{static_cast<uint32_t>(byte_from_hexstr(str)) << 24 |
static_cast<uint32_t>(byte_from_hexstr(str + 2)) << 16 |
static_cast<uint32_t>(byte_from_hexstr(str + 4)) << 8 |
byte_from_hexstr(str + 6),
static_cast<uint16_t>(
static_cast<uint16_t>(byte_from_hexstr(str + 9)) << 8 |
byte_from_hexstr(str + 11)),
static_cast<uint16_t>(
static_cast<uint16_t>(byte_from_hexstr(str + 14)) << 8 |
byte_from_hexstr(str + 16)),
{byte_from_hexstr(str + 19), byte_from_hexstr(str + 21),
byte_from_hexstr(str + 24), byte_from_hexstr(str + 26),
byte_from_hexstr(str + 28), byte_from_hexstr(str + 30),
byte_from_hexstr(str + 32), byte_from_hexstr(str + 34)}};
}

template <typename interface> inline GUID __emulated_uuidof();

#define CROSS_PLATFORM_UUIDOF(interface, spec) \
#define CROSS_PLATFORM_UUIDOF(interface, str) \
struct interface; \
template <> inline GUID __emulated_uuidof<interface>() { \
static const IID _IID = guid_from_string(spec); \
return _IID; \
}

#define __uuidof(T) __emulated_uuidof<typename std::decay<T>::type>()

#define IID_PPV_ARGS(ppType) \
__uuidof(decltype(**(ppType))), reinterpret_cast<void **>(ppType)
__CRT_UUID_DECL( \
interface, \
static_cast<uint32_t>(byte_from_hexstr(&(str)[2])) << 16 | \
static_cast<uint32_t>(byte_from_hexstr(&(str)[4])) << 8 | \
byte_from_hexstr(&(str)[6]), \
static_cast<uint16_t>(static_cast<uint16_t>(byte_from_hexstr(&(str)[9])) \
<< 8 | \
byte_from_hexstr(&(str)[11])), \
static_cast<uint16_t>( \
static_cast<uint16_t>(byte_from_hexstr(&(str)[14])) << 8 | \
byte_from_hexstr(&(str)[16])), \
byte_from_hexstr(&(str)[19]), byte_from_hexstr(&(str)[21]), \
byte_from_hexstr(&(str)[24]), byte_from_hexstr(&(str)[26]), \
byte_from_hexstr(&(str)[28]), byte_from_hexstr(&(str)[30]), \
byte_from_hexstr(&(str)[32]), byte_from_hexstr(&(str)[34]));

#else // __EMULATE_UUID

Expand All @@ -560,27 +441,8 @@ template <typename T> inline void **IID_PPV_ARGS_Helper(T **pp) {

#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 <class Q> HRESULT QueryInterface(Q **pp) {
return QueryInterface(__uuidof(Q), (void **)pp);
}
};

CROSS_PLATFORM_UUIDOF(INoMarshal, "ECC8691B-C1DB-4DC0-855E-65F6C551AF49")
struct INoMarshal : public IUnknown {};

Expand Down
Loading
Loading