|
11 | 11 |
|
12 | 12 | #if defined(__clang__) && !defined(_MSC_VER) && defined(_WIN32) // Zig windows-gnu target |
13 | 13 |
|
| 14 | +// MinGW UUIDOF specializations |
| 15 | +//------------------------------------------------------------- |
| 16 | +// This is needed because clang GNU target / MinGW headers will emit references to e.g. |
| 17 | +// |
| 18 | +// error: undefined symbol: _GUID const& __mingw_uuidof<IDxcSystemAccess>() |
| 19 | +// |
| 20 | +// which do not match MSVC. |
| 21 | +#include <guiddef.h> |
| 22 | +#include <stdint.h> |
| 23 | + |
| 24 | +#ifdef __cplusplus |
| 25 | +#define MINGW_UUIDOF(type, spec) \ |
| 26 | + extern "C++" { \ |
| 27 | + struct __declspec(uuid(spec)) type; \ |
| 28 | + template<> const GUID &__mingw_uuidof<type>() { \ |
| 29 | + static constexpr IID __uuid_inst = guid_from_string(spec); \ |
| 30 | + return __uuid_inst; \ |
| 31 | + } \ |
| 32 | + template<> const GUID &__mingw_uuidof<type*>() { \ |
| 33 | + return __mingw_uuidof<type>(); \ |
| 34 | + } \ |
| 35 | + } |
| 36 | + |
| 37 | +constexpr uint8_t nybble_from_hex(char c) { |
| 38 | + return ((c >= '0' && c <= '9') |
| 39 | + ? (c - '0') |
| 40 | + : ((c >= 'a' && c <= 'f') |
| 41 | + ? (c - 'a' + 10) |
| 42 | + : ((c >= 'A' && c <= 'F') ? (c - 'A' + 10) |
| 43 | + : /* Should be an error */ -1))); |
| 44 | +} |
| 45 | + |
| 46 | +constexpr uint8_t byte_from_hex(char c1, char c2) { |
| 47 | + return nybble_from_hex(c1) << 4 | nybble_from_hex(c2); |
| 48 | +} |
| 49 | + |
| 50 | +constexpr uint8_t byte_from_hexstr(const char str[2]) { |
| 51 | + return nybble_from_hex(str[0]) << 4 | nybble_from_hex(str[1]); |
| 52 | +} |
| 53 | + |
| 54 | +constexpr GUID guid_from_string(const char str[37]) { |
| 55 | + return GUID{static_cast<uint32_t>(byte_from_hexstr(str)) << 24 | |
| 56 | + static_cast<uint32_t>(byte_from_hexstr(str + 2)) << 16 | |
| 57 | + static_cast<uint32_t>(byte_from_hexstr(str + 4)) << 8 | |
| 58 | + byte_from_hexstr(str + 6), |
| 59 | + static_cast<uint16_t>( |
| 60 | + static_cast<uint16_t>(byte_from_hexstr(str + 9)) << 8 | |
| 61 | + byte_from_hexstr(str + 11)), |
| 62 | + static_cast<uint16_t>( |
| 63 | + static_cast<uint16_t>(byte_from_hexstr(str + 14)) << 8 | |
| 64 | + byte_from_hexstr(str + 16)), |
| 65 | + {byte_from_hexstr(str + 19), byte_from_hexstr(str + 21), |
| 66 | + byte_from_hexstr(str + 24), byte_from_hexstr(str + 26), |
| 67 | + byte_from_hexstr(str + 28), byte_from_hexstr(str + 30), |
| 68 | + byte_from_hexstr(str + 32), byte_from_hexstr(str + 34)}}; |
| 69 | +} |
| 70 | + |
| 71 | +#ifdef ZIG_MINGW_DECLARE_SPECIALIZATIONS |
| 72 | +#define CROSS_PLATFORM_UUIDOF(type, spec) MINGW_UUIDOF(type, spec) |
| 73 | +#else // ZIG_MINGW_DECLARE_SPECIALIZATIONS |
| 74 | +#define CROSS_PLATFORM_UUIDOF(type, spec) |
| 75 | +#endif // ZIG_MINGW_DECLARE_SPECIALIZATIONS |
| 76 | +#endif // __cplusplus |
| 77 | + |
| 78 | + |
| 79 | + |
14 | 80 | // General |
15 | 81 | //------------------------------------------------------------- |
16 | 82 | // mingw-w64 tends to define it as 0x0502 in its headers. |
@@ -563,8 +629,9 @@ HRESULT UInt32Mult(UINT a, UINT b, UINT *out); |
563 | 629 | #define D3D12_SHVER_GET_MINOR(_Version) \ |
564 | 630 | (((_Version) >> 0) & 0xf) |
565 | 631 |
|
566 | | -#define D3D_NAME_STENCIL_REF ((D3D_NAME)69) |
567 | | -#define D3D_NAME_INNER_COVERAGE ((D3D_NAME)70) |
| 632 | +// TODO: #ifndef? |
| 633 | +// #define D3D_NAME_STENCIL_REF ((D3D_NAME)69) |
| 634 | +// #define D3D_NAME_INNER_COVERAGE ((D3D_NAME)70) |
568 | 635 |
|
569 | 636 | #define D3D_SHADER_REQUIRES_DOUBLES 0x00000001 |
570 | 637 | #define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL 0x00000002 |
@@ -1020,6 +1087,30 @@ class CComBSTR { |
1020 | 1087 | return s; |
1021 | 1088 | } |
1022 | 1089 | }; |
| 1090 | + |
| 1091 | +//===--------- Convert argv to wchar ----------------===// |
| 1092 | +class WArgV { |
| 1093 | + std::vector<std::wstring> WStringVector; |
| 1094 | + std::vector<const wchar_t *> WCharPtrVector; |
| 1095 | + |
| 1096 | +public: |
| 1097 | + WArgV(int argc, const char **argv); |
| 1098 | + const wchar_t **argv() { return WCharPtrVector.data(); } |
| 1099 | +}; |
| 1100 | + |
| 1101 | + |
| 1102 | + |
| 1103 | +#ifdef ZIG_MINGW_DECLARE_SPECIALIZATIONS |
| 1104 | +#include "dxc/dxcapi.h" |
| 1105 | +#include "dxc/dxcapi.internal.h" |
| 1106 | +#include "dxc/dxcisense.h" |
| 1107 | +#include "dxc/dxctools.h" |
| 1108 | +CROSS_PLATFORM_UUIDOF(IDiaDataSource, "79F1BB5F-B66E-48e5-B6A9-1545C323CA3D") |
| 1109 | +CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection, "8E349D19-54DB-4A56-9DC9-119D87BDB804") |
| 1110 | +CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection, "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") |
| 1111 | +CROSS_PLATFORM_UUIDOF(IDxcPixDxilDebugInfoFactory, "9c2a040d-8068-44ec-8c68-8bfef1b43789") |
| 1112 | +#endif // ZIG_MINGW_DECLARE_SPECIALIZATIONS |
| 1113 | + |
1023 | 1114 | #endif // __cplusplus |
1024 | 1115 |
|
1025 | 1116 | #endif // defined(__clang__) && !defined(_MSC_VER) && defined(_WIN32) // Zig windows-gnu target |
|
0 commit comments