Skip to content

Commit 7962896

Browse files
Updated DXC headers
1 parent 7263d5d commit 7962896

8 files changed

Lines changed: 2679 additions & 2200 deletions

File tree

ThirdParty/DirectXShaderCompiler/dxc/DXIL/DxilConstants.h

Lines changed: 1946 additions & 1538 deletions
Large diffs are not rendered by default.

ThirdParty/DirectXShaderCompiler/dxc/DxilContainer/DxilContainer.h

Lines changed: 182 additions & 141 deletions
Large diffs are not rendered by default.

ThirdParty/DirectXShaderCompiler/dxc/Support/Unicode.h

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,65 +33,58 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t dwFlags,
3333
bool *lpUsedDefaultChar = nullptr);
3434
#endif // _WIN32
3535

36-
namespace Unicode
37-
{
38-
39-
// Based on http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.
40-
enum class Encoding { ASCII = 0, UTF8, UTF8_BOM, UTF16_LE, UTF16_BE, UTF32_LE, UTF32_BE };
36+
namespace Unicode {
37+
38+
// Based on
39+
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.
40+
enum class Encoding {
41+
ASCII = 0,
42+
UTF8,
43+
UTF8_BOM,
44+
UTF16_LE,
45+
UTF16_BE,
46+
UTF32_LE,
47+
UTF32_BE
48+
};
4149

4250
// An acp_char is a character encoded in the current Windows ANSI code page.
4351
typedef char acp_char;
4452

4553
// A ccp_char is a character encoded in the console code page.
4654
typedef char ccp_char;
4755

48-
_Success_(return != false)
49-
bool UTF8ToConsoleString(_In_opt_count_(textLen) const char* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
56+
bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue,
57+
bool *lossy);
5058

51-
_Success_(return != false)
52-
bool UTF8ToConsoleString(_In_z_ const char* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
59+
bool UTF8ToConsoleString(const char *text, std::string *pValue, bool *lossy);
5360

54-
_Success_(return != false)
55-
bool WideToConsoleString(_In_opt_count_(textLen) const wchar_t* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
61+
bool WideToConsoleString(const wchar_t *text, size_t textLen,
62+
std::string *pValue, bool *lossy);
5663

57-
_Success_(return != false)
58-
bool WideToConsoleString(_In_z_ const wchar_t* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
64+
bool WideToConsoleString(const wchar_t *text, std::string *pValue, bool *lossy);
5965

60-
_Success_(return != false)
61-
bool UTF8ToWideString(_In_opt_z_ const char *pUTF8, _Inout_ std::wstring *pWide);
66+
bool UTF8ToWideString(const char *pUTF8, std::wstring *pWide);
6267

63-
_Success_(return != false)
64-
bool UTF8ToWideString(_In_opt_count_(cbUTF8) const char *pUTF8, size_t cbUTF8, _Inout_ std::wstring *pWide);
68+
bool UTF8ToWideString(const char *pUTF8, size_t cbUTF8, std::wstring *pWide);
6569

66-
std::wstring UTF8ToWideStringOrThrow(_In_z_ const char *pUTF8);
70+
std::wstring UTF8ToWideStringOrThrow(const char *pUTF8);
6771

68-
_Success_(return != false)
69-
bool WideToUTF8String(_In_z_ const wchar_t *pWide, size_t cWide, _Inout_ std::string *pUTF8);
70-
bool WideToUTF8String(_In_z_ const wchar_t *pWide, _Inout_ std::string *pUTF8);
72+
bool WideToUTF8String(const wchar_t *pWide, size_t cWide, std::string *pUTF8);
73+
bool WideToUTF8String(const wchar_t *pWide, std::string *pUTF8);
7174

72-
std::string WideToUTF8StringOrThrow(_In_z_ const wchar_t *pWide);
75+
std::string WideToUTF8StringOrThrow(const wchar_t *pWide);
7376

74-
bool IsStarMatchUTF8(_In_reads_opt_(maskLen) const char *pMask, size_t maskLen,
75-
_In_reads_opt_(nameLen) const char *pName, size_t nameLen);
76-
bool IsStarMatchWide(_In_reads_opt_(maskLen) const wchar_t *pMask, size_t maskLen,
77-
_In_reads_opt_(nameLen) const wchar_t *pName, size_t nameLen);
77+
bool IsStarMatchUTF8(const char *pMask, size_t maskLen, const char *pName,
78+
size_t nameLen);
79+
bool IsStarMatchWide(const wchar_t *pMask, size_t maskLen, const wchar_t *pName,
80+
size_t nameLen);
7881

79-
_Success_(return != false)
80-
bool UTF8BufferToWideComHeap(_In_z_ const char *pUTF8,
81-
_Outptr_result_z_ wchar_t **ppWide) throw();
82+
bool UTF8BufferToWideComHeap(const char *pUTF8, wchar_t **ppWide) throw();
8283

83-
_Success_(return != false)
84-
bool UTF8BufferToWideBuffer(
85-
_In_NLS_string_(cbUTF8) const char *pUTF8,
86-
int cbUTF8,
87-
_Outptr_result_buffer_(*pcchWide) wchar_t **ppWide,
88-
size_t *pcchWide) throw();
84+
bool UTF8BufferToWideBuffer(const char *pUTF8, int cbUTF8, wchar_t **ppWide,
85+
size_t *pcchWide) throw();
8986

90-
_Success_(return != false)
91-
bool WideBufferToUTF8Buffer(
92-
_In_NLS_string_(cchWide) const wchar_t *pWide,
93-
int cchWide,
94-
_Outptr_result_buffer_(*pcbUTF8) char **ppUTF8,
95-
size_t *pcbUTF8) throw();
87+
bool WideBufferToUTF8Buffer(const wchar_t *pWide, int cchWide, char **ppUTF8,
88+
size_t *pcbUTF8) throw();
9689

97-
} // namespace Unicode
90+
} // namespace Unicode

ThirdParty/DirectXShaderCompiler/dxc/Support/WinAdapter.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#include "dxc/Support/WinIncludes.h"
11-
#include "dxc/Support/WinFunctions.h"
1210
#include "assert.h"
11+
#include "dxc/Support/WinFunctions.h"
12+
#include "dxc/Support/WinIncludes.h"
1313
#ifndef _WIN32
1414

1515
#include "dxc/Support/Unicode.h"
@@ -51,7 +51,15 @@ BSTR SysAllocStringLen(const OLECHAR *strIn, UINT ui) {
5151

5252
return strOut;
5353
}
54+
//===--------------------------- BSTR Length ------------------------------===//
55+
unsigned int SysStringLen(const BSTR bstrString) {
56+
if (!bstrString)
57+
return 0;
58+
59+
uint32_t *blobIn = (uint32_t *)((uintptr_t)bstrString - sizeof(uint32_t));
5460

61+
return blobIn[0] / sizeof(OLECHAR);
62+
}
5563
//===---------------------- Char converstion ------------------------------===//
5664

5765
const char *CPToLocale(uint32_t CodePage) {
@@ -78,9 +86,9 @@ CHandle::~CHandle() { CloseHandle(m_h); }
7886
CHandle::operator HANDLE() const throw() { return m_h; }
7987

8088
// CComBSTR
81-
CComBSTR::CComBSTR(_In_ int nSize, LPCWSTR sz) {
89+
CComBSTR::CComBSTR(int nSize, LPCWSTR sz) {
8290
if (nSize < 0) {
83-
throw std::invalid_argument("CComBSTR must have size >= 0");
91+
throw std::invalid_argument("CComBSTR must have size >= 0");
8492
}
8593

8694
if (nSize == 0) {
@@ -93,12 +101,10 @@ CComBSTR::CComBSTR(_In_ int nSize, LPCWSTR sz) {
93101
}
94102
}
95103

96-
bool CComBSTR::operator==(_In_ const CComBSTR &bstrSrc) const throw() {
104+
bool CComBSTR::operator==(const CComBSTR &bstrSrc) const throw() {
97105
return wcscmp(m_str, bstrSrc.m_str) == 0;
98106
}
99107

100-
#endif
101-
102108
//===--------------------------- WArgV -------------------------------===//
103109
WArgV::WArgV(int argc, const char **argv)
104110
: WStringVector(argc), WCharPtrVector(argc) {
@@ -115,9 +121,4 @@ WArgV::WArgV(int argc, const char **argv)
115121
}
116122
}
117123

118-
WArgV::WArgV(int argc, const wchar_t **argv)
119-
: WCharPtrVector(argc) {
120-
for (int i = 0; i < argc; ++i) {
121-
WCharPtrVector[i] = argv[i];
122-
}
123-
}
124+
#endif

ThirdParty/DirectXShaderCompiler/dxc/Support/WinFunctions.h

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,26 @@ int _stricmp(const char *str1, const char *str2);
3030
int _wcsicmp(const wchar_t *str1, const wchar_t *str2);
3131
int _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n);
3232
int wsprintf(wchar_t *wcs, const wchar_t *fmt, ...);
33-
unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask);
33+
unsigned char _BitScanForward(unsigned long *Index, unsigned long Mask);
3434

35-
HANDLE CreateFile2(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess,
36-
_In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition,
37-
_In_opt_ void *pCreateExParams);
35+
HANDLE CreateFile2(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
36+
DWORD dwCreationDisposition, void *pCreateExParams);
3837

39-
HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess,
40-
_In_ DWORD dwShareMode, _In_opt_ void *lpSecurityAttributes,
41-
_In_ DWORD dwCreationDisposition,
42-
_In_ DWORD dwFlagsAndAttributes,
43-
_In_opt_ HANDLE hTemplateFile);
38+
HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
39+
void *lpSecurityAttributes, DWORD dwCreationDisposition,
40+
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
4441

45-
BOOL GetFileSizeEx(_In_ HANDLE hFile, _Out_ PLARGE_INTEGER lpFileSize);
42+
BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize);
4643

47-
BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer,
48-
_In_ DWORD nNumberOfBytesToRead,
49-
_Out_opt_ LPDWORD lpNumberOfBytesRead,
50-
_Inout_opt_ void *lpOverlapped);
51-
BOOL WriteFile(_In_ HANDLE hFile, _In_ LPCVOID lpBuffer,
52-
_In_ DWORD nNumberOfBytesToWrite,
53-
_Out_opt_ LPDWORD lpNumberOfBytesWritten,
54-
_Inout_opt_ void *lpOverlapped);
44+
BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
45+
LPDWORD lpNumberOfBytesRead, void *lpOverlapped);
46+
BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
47+
LPDWORD lpNumberOfBytesWritten, void *lpOverlapped);
5548

56-
BOOL CloseHandle(_In_ HANDLE hObject);
49+
BOOL CloseHandle(HANDLE hObject);
5750

5851
// Windows-specific heap functions
59-
HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize , SIZE_T dwMaximumSize);
52+
HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
6053
BOOL HeapDestroy(HANDLE heap);
6154
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T nBytes);
6255
LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes);

ThirdParty/DirectXShaderCompiler/dxc/Support/WinIncludes.h

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// Require at least Windows 7 (Updated from XP)
2020
#define _WIN32_WINNT 0x0601
21-
#define _WIN32_IE 0x0800 // MinGW at it again.
21+
#define _WIN32_IE 0x0800 // MinGW at it again.
2222

2323
#define NOATOM 1
2424
#define NOGDICAPMASKS 1
@@ -40,12 +40,12 @@
4040
#define VC_EXTRALEAN 1
4141
#define NONAMELESSSTRUCT 1
4242

43-
#include <windows.h>
44-
#include <unknwn.h>
43+
#include <ObjIdl.h>
4544
#include <atlbase.h> // atlbase.h needs to come before strsafe.h
46-
#include <strsafe.h>
4745
#include <intsafe.h>
48-
#include <ObjIdl.h>
46+
#include <strsafe.h>
47+
#include <unknwn.h>
48+
#include <windows.h>
4949

5050
#include "dxc/config.h"
5151

@@ -66,49 +66,55 @@ template <class T> void swap(CComHeapPtr<T> &a, CComHeapPtr<T> &b) {
6666
#include "dxc/WinAdapter.h"
6767

6868
#ifdef __cplusplus
69+
#if !defined(DEFINE_ENUM_FLAG_OPERATORS)
6970
// Define operator overloads to enable bit operations on enum values that are
70-
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable these
71-
// operators on YOUR_TYPE.
71+
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable
72+
// these operators on YOUR_TYPE.
7273
extern "C++" {
73-
template <size_t S>
74-
struct _ENUM_FLAG_INTEGER_FOR_SIZE;
75-
76-
template <>
77-
struct _ENUM_FLAG_INTEGER_FOR_SIZE<1>
78-
{
79-
typedef int8_t type;
80-
};
81-
82-
template <>
83-
struct _ENUM_FLAG_INTEGER_FOR_SIZE<2>
84-
{
85-
typedef int16_t type;
86-
};
87-
88-
template <>
89-
struct _ENUM_FLAG_INTEGER_FOR_SIZE<4>
90-
{
91-
typedef int32_t type;
92-
};
93-
94-
// used as an approximation of std::underlying_type<T>
95-
template <class T>
96-
struct _ENUM_FLAG_SIZED_INTEGER
97-
{
98-
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
99-
};
74+
template <size_t S> struct _ENUM_FLAG_INTEGER_FOR_SIZE;
10075

76+
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<1> { typedef int8_t type; };
77+
78+
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<2> { typedef int16_t type; };
79+
80+
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<4> { typedef int32_t type; };
81+
82+
// used as an approximation of std::underlying_type<T>
83+
template <class T> struct _ENUM_FLAG_SIZED_INTEGER {
84+
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
85+
};
10186
}
102-
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
103-
extern "C++" { \
104-
inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
105-
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
106-
inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
107-
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
108-
inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); } \
109-
inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
110-
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
111-
}
87+
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
88+
extern "C++" { \
89+
inline ENUMTYPE operator|(ENUMTYPE a, ENUMTYPE b) { \
90+
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | \
91+
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
92+
} \
93+
inline ENUMTYPE &operator|=(ENUMTYPE &a, ENUMTYPE b) { \
94+
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= \
95+
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
96+
} \
97+
inline ENUMTYPE operator&(ENUMTYPE a, ENUMTYPE b) { \
98+
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & \
99+
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
100+
} \
101+
inline ENUMTYPE &operator&=(ENUMTYPE &a, ENUMTYPE b) { \
102+
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= \
103+
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
104+
} \
105+
inline ENUMTYPE operator~(ENUMTYPE a) { \
106+
return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); \
107+
} \
108+
inline ENUMTYPE operator^(ENUMTYPE a, ENUMTYPE b) { \
109+
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ \
110+
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
111+
} \
112+
inline ENUMTYPE &operator^=(ENUMTYPE &a, ENUMTYPE b) { \
113+
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= \
114+
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
115+
} \
116+
}
117+
#endif // !defined(DEFINE_ENUM_FLAG_OPERATORS)
112118
#else
113119
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) // NOP, C allows these operators.
114120
#endif
@@ -123,15 +129,7 @@ inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_
123129
#else // defined(_WIN32) && !defined(DXC_DISABLE_ALLOCATOR_OVERRIDES)
124130

125131
#ifndef _WIN32
126-
CROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046")
127-
struct IMalloc : public IUnknown {
128-
virtual void *Alloc(SIZE_T size) = 0;
129-
virtual void *Realloc(void *ptr, SIZE_T size) = 0;
130-
virtual void Free(void *ptr) = 0;
131-
virtual SIZE_T GetSize(void *pv) = 0;
132-
virtual int DidAlloc(void *pv) = 0;
133-
virtual void HeapMinimize(void) = 0;
134-
};
132+
struct IMalloc;
135133
#endif
136134

137135
HRESULT DxcCoGetMalloc(DWORD dwMemContext, IMalloc **ppMalloc);

0 commit comments

Comments
 (0)