Skip to content

Commit

Permalink
Updated DXC headers
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Feb 5, 2024
1 parent 7263d5d commit 9b92ddf
Show file tree
Hide file tree
Showing 8 changed files with 2,677 additions and 2,200 deletions.
3,484 changes: 1,946 additions & 1,538 deletions ThirdParty/DirectXShaderCompiler/dxc/DXIL/DxilConstants.h

Large diffs are not rendered by default.

323 changes: 182 additions & 141 deletions ThirdParty/DirectXShaderCompiler/dxc/DxilContainer/DxilContainer.h

Large diffs are not rendered by default.

77 changes: 35 additions & 42 deletions ThirdParty/DirectXShaderCompiler/dxc/Support/Unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,65 +33,58 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t dwFlags,
bool *lpUsedDefaultChar = nullptr);
#endif // _WIN32

namespace Unicode
{

// Based on http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.
enum class Encoding { ASCII = 0, UTF8, UTF8_BOM, UTF16_LE, UTF16_BE, UTF32_LE, UTF32_BE };
namespace Unicode {

// Based on
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.
enum class Encoding {
ASCII = 0,
UTF8,
UTF8_BOM,
UTF16_LE,
UTF16_BE,
UTF32_LE,
UTF32_BE
};

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

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

_Success_(return != false)
bool UTF8ToConsoleString(_In_opt_count_(textLen) const char* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue,
bool *lossy);

_Success_(return != false)
bool UTF8ToConsoleString(_In_z_ const char* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
bool UTF8ToConsoleString(const char *text, std::string *pValue, bool *lossy);

_Success_(return != false)
bool WideToConsoleString(_In_opt_count_(textLen) const wchar_t* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
bool WideToConsoleString(const wchar_t *text, size_t textLen,
std::string *pValue, bool *lossy);

_Success_(return != false)
bool WideToConsoleString(_In_z_ const wchar_t* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);
bool WideToConsoleString(const wchar_t *text, std::string *pValue, bool *lossy);

_Success_(return != false)
bool UTF8ToWideString(_In_opt_z_ const char *pUTF8, _Inout_ std::wstring *pWide);
bool UTF8ToWideString(const char *pUTF8, std::wstring *pWide);

_Success_(return != false)
bool UTF8ToWideString(_In_opt_count_(cbUTF8) const char *pUTF8, size_t cbUTF8, _Inout_ std::wstring *pWide);
bool UTF8ToWideString(const char *pUTF8, size_t cbUTF8, std::wstring *pWide);

std::wstring UTF8ToWideStringOrThrow(_In_z_ const char *pUTF8);
std::wstring UTF8ToWideStringOrThrow(const char *pUTF8);

_Success_(return != false)
bool WideToUTF8String(_In_z_ const wchar_t *pWide, size_t cWide, _Inout_ std::string *pUTF8);
bool WideToUTF8String(_In_z_ const wchar_t *pWide, _Inout_ std::string *pUTF8);
bool WideToUTF8String(const wchar_t *pWide, size_t cWide, std::string *pUTF8);
bool WideToUTF8String(const wchar_t *pWide, std::string *pUTF8);

std::string WideToUTF8StringOrThrow(_In_z_ const wchar_t *pWide);
std::string WideToUTF8StringOrThrow(const wchar_t *pWide);

bool IsStarMatchUTF8(_In_reads_opt_(maskLen) const char *pMask, size_t maskLen,
_In_reads_opt_(nameLen) const char *pName, size_t nameLen);
bool IsStarMatchWide(_In_reads_opt_(maskLen) const wchar_t *pMask, size_t maskLen,
_In_reads_opt_(nameLen) const wchar_t *pName, size_t nameLen);
bool IsStarMatchUTF8(const char *pMask, size_t maskLen, const char *pName,
size_t nameLen);
bool IsStarMatchWide(const wchar_t *pMask, size_t maskLen, const wchar_t *pName,
size_t nameLen);

_Success_(return != false)
bool UTF8BufferToWideComHeap(_In_z_ const char *pUTF8,
_Outptr_result_z_ wchar_t **ppWide) throw();
bool UTF8BufferToWideComHeap(const char *pUTF8, wchar_t **ppWide) throw();

_Success_(return != false)
bool UTF8BufferToWideBuffer(
_In_NLS_string_(cbUTF8) const char *pUTF8,
int cbUTF8,
_Outptr_result_buffer_(*pcchWide) wchar_t **ppWide,
size_t *pcchWide) throw();
bool UTF8BufferToWideBuffer(const char *pUTF8, int cbUTF8, wchar_t **ppWide,
size_t *pcchWide) throw();

_Success_(return != false)
bool WideBufferToUTF8Buffer(
_In_NLS_string_(cchWide) const wchar_t *pWide,
int cchWide,
_Outptr_result_buffer_(*pcbUTF8) char **ppUTF8,
size_t *pcbUTF8) throw();
bool WideBufferToUTF8Buffer(const wchar_t *pWide, int cchWide, char **ppUTF8,
size_t *pcbUTF8) throw();

} // namespace Unicode
} // namespace Unicode
27 changes: 14 additions & 13 deletions ThirdParty/DirectXShaderCompiler/dxc/Support/WinAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//

#include "dxc/Support/WinIncludes.h"
#include "dxc/Support/WinFunctions.h"
#include "assert.h"
#include "dxc/Support/WinFunctions.h"
#include "dxc/Support/WinIncludes.h"
#ifndef _WIN32

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

return strOut;
}
//===--------------------------- BSTR Length ------------------------------===//
unsigned int SysStringLen(const BSTR bstrString) {
if (!bstrString)
return 0;

uint32_t *blobIn = (uint32_t *)((uintptr_t)bstrString - sizeof(uint32_t));

return blobIn[0] / sizeof(OLECHAR);
}
//===---------------------- Char converstion ------------------------------===//

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

// CComBSTR
CComBSTR::CComBSTR(_In_ int nSize, LPCWSTR sz) {
CComBSTR::CComBSTR(int nSize, LPCWSTR sz) {
if (nSize < 0) {
throw std::invalid_argument("CComBSTR must have size >= 0");
throw std::invalid_argument("CComBSTR must have size >= 0");
}

if (nSize == 0) {
Expand All @@ -93,12 +101,10 @@ CComBSTR::CComBSTR(_In_ int nSize, LPCWSTR sz) {
}
}

bool CComBSTR::operator==(_In_ const CComBSTR &bstrSrc) const throw() {
bool CComBSTR::operator==(const CComBSTR &bstrSrc) const throw() {
return wcscmp(m_str, bstrSrc.m_str) == 0;
}

#endif

//===--------------------------- WArgV -------------------------------===//
WArgV::WArgV(int argc, const char **argv)
: WStringVector(argc), WCharPtrVector(argc) {
Expand All @@ -115,9 +121,4 @@ WArgV::WArgV(int argc, const char **argv)
}
}

WArgV::WArgV(int argc, const wchar_t **argv)
: WCharPtrVector(argc) {
for (int i = 0; i < argc; ++i) {
WCharPtrVector[i] = argv[i];
}
}
#endif
33 changes: 13 additions & 20 deletions ThirdParty/DirectXShaderCompiler/dxc/Support/WinFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,26 @@ int _stricmp(const char *str1, const char *str2);
int _wcsicmp(const wchar_t *str1, const wchar_t *str2);
int _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n);
int wsprintf(wchar_t *wcs, const wchar_t *fmt, ...);
unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask);
unsigned char _BitScanForward(unsigned long *Index, unsigned long Mask);

HANDLE CreateFile2(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess,
_In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition,
_In_opt_ void *pCreateExParams);
HANDLE CreateFile2(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
DWORD dwCreationDisposition, void *pCreateExParams);

HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess,
_In_ DWORD dwShareMode, _In_opt_ void *lpSecurityAttributes,
_In_ DWORD dwCreationDisposition,
_In_ DWORD dwFlagsAndAttributes,
_In_opt_ HANDLE hTemplateFile);
HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
void *lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);

BOOL GetFileSizeEx(_In_ HANDLE hFile, _Out_ PLARGE_INTEGER lpFileSize);
BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize);

BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer,
_In_ DWORD nNumberOfBytesToRead,
_Out_opt_ LPDWORD lpNumberOfBytesRead,
_Inout_opt_ void *lpOverlapped);
BOOL WriteFile(_In_ HANDLE hFile, _In_ LPCVOID lpBuffer,
_In_ DWORD nNumberOfBytesToWrite,
_Out_opt_ LPDWORD lpNumberOfBytesWritten,
_Inout_opt_ void *lpOverlapped);
BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, void *lpOverlapped);
BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, void *lpOverlapped);

BOOL CloseHandle(_In_ HANDLE hObject);
BOOL CloseHandle(HANDLE hObject);

// Windows-specific heap functions
HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize , SIZE_T dwMaximumSize);
HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
BOOL HeapDestroy(HANDLE heap);
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T nBytes);
LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes);
Expand Down
104 changes: 51 additions & 53 deletions ThirdParty/DirectXShaderCompiler/dxc/Support/WinIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// Require at least Windows 7 (Updated from XP)
#define _WIN32_WINNT 0x0601
#define _WIN32_IE 0x0800 // MinGW at it again.
#define _WIN32_IE 0x0800 // MinGW at it again.

#define NOATOM 1
#define NOGDICAPMASKS 1
Expand All @@ -40,12 +40,12 @@
#define VC_EXTRALEAN 1
#define NONAMELESSSTRUCT 1

#include <windows.h>
#include <unknwn.h>
#include <ObjIdl.h>
#include <atlbase.h> // atlbase.h needs to come before strsafe.h
#include <strsafe.h>
#include <intsafe.h>
#include <ObjIdl.h>
#include <strsafe.h>
#include <unknwn.h>
#include <windows.h>

#include "dxc/config.h"

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

#ifdef __cplusplus
#if !defined(DEFINE_ENUM_FLAG_OPERATORS)
// Define operator overloads to enable bit operations on enum values that are
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable these
// operators on YOUR_TYPE.
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable
// these operators on YOUR_TYPE.
extern "C++" {
template <size_t S>
struct _ENUM_FLAG_INTEGER_FOR_SIZE;

template <>
struct _ENUM_FLAG_INTEGER_FOR_SIZE<1>
{
typedef int8_t type;
};

template <>
struct _ENUM_FLAG_INTEGER_FOR_SIZE<2>
{
typedef int16_t type;
};

template <>
struct _ENUM_FLAG_INTEGER_FOR_SIZE<4>
{
typedef int32_t type;
};

// used as an approximation of std::underlying_type<T>
template <class T>
struct _ENUM_FLAG_SIZED_INTEGER
{
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
};
template <size_t S> struct _ENUM_FLAG_INTEGER_FOR_SIZE;

template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<1> { typedef int8_t type; };

template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<2> { typedef int16_t type; };

template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<4> { typedef int32_t type; };

// used as an approximation of std::underlying_type<T>
template <class T> struct _ENUM_FLAG_SIZED_INTEGER {
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
};
}
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
extern "C++" { \
inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); } \
inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
}
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
extern "C++" { \
inline ENUMTYPE operator|(ENUMTYPE a, ENUMTYPE b) { \
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | \
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
} \
inline ENUMTYPE &operator|=(ENUMTYPE &a, ENUMTYPE b) { \
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= \
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
} \
inline ENUMTYPE operator&(ENUMTYPE a, ENUMTYPE b) { \
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & \
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
} \
inline ENUMTYPE &operator&=(ENUMTYPE &a, ENUMTYPE b) { \
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= \
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
} \
inline ENUMTYPE operator~(ENUMTYPE a) { \
return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); \
} \
inline ENUMTYPE operator^(ENUMTYPE a, ENUMTYPE b) { \
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ \
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
} \
inline ENUMTYPE &operator^=(ENUMTYPE &a, ENUMTYPE b) { \
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= \
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
} \
}
#endif // !defined(DEFINE_ENUM_FLAG_OPERATORS)
#else
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) // NOP, C allows these operators.
#endif
Expand All @@ -123,15 +129,7 @@ inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_
#else // defined(_WIN32) && !defined(DXC_DISABLE_ALLOCATOR_OVERRIDES)

#ifndef _WIN32
CROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046")
struct IMalloc : public IUnknown {
virtual void *Alloc(SIZE_T size) = 0;
virtual void *Realloc(void *ptr, SIZE_T size) = 0;
virtual void Free(void *ptr) = 0;
virtual SIZE_T GetSize(void *pv) = 0;
virtual int DidAlloc(void *pv) = 0;
virtual void HeapMinimize(void) = 0;
};
struct IMalloc;
#endif

HRESULT DxcCoGetMalloc(DWORD dwMemContext, IMalloc **ppMalloc);
Expand Down
Loading

0 comments on commit 9b92ddf

Please sign in to comment.