summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-12-27 12:03:39 -0800
committer3gg <3gg@shellblade.net>2025-12-27 12:03:39 -0800
commit5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch)
tree8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h')
-rw-r--r--contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h b/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h
new file mode 100644
index 0000000..3173558
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h
@@ -0,0 +1,103 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_D3D12_H
24#define SDL_D3D12_H
25
26#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
27
28/* From the DirectX-Headers build system:
29 * "MinGW has RPC headers which define old versions, and complain if D3D
30 * headers are included before the RPC headers, since D3D headers were
31 * generated with new MIDL and "require" new RPC headers."
32 */
33#define __REQUIRED_RPCNDR_H_VERSION__ 475
34
35// May not be defined in winapifamily.h, can safely be ignored
36#ifndef WINAPI_PARTITION_GAMES
37#define WINAPI_PARTITION_GAMES 0
38#endif // WINAPI_PARTITION_GAMES
39
40#define COBJMACROS
41#include "d3d12.h"
42#include <dxgi1_6.h>
43#include <dxgidebug.h>
44
45#define D3D_GUID(X) &(X)
46
47#define D3D_SAFE_RELEASE(X) \
48 if (X) { \
49 (X)->lpVtbl->Release(X); \
50 X = NULL; \
51 }
52
53/* Some D3D12 calls are mismatched between Windows/Xbox, so we need to wrap the
54 * C function ourselves :(
55 */
56#define D3D_CALL_RET(THIS, FUNC, ...) (THIS)->lpVtbl->FUNC((THIS), ##__VA_ARGS__)
57
58#else // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
59
60#if defined(SDL_PLATFORM_XBOXONE)
61#include <d3d12_x.h>
62#else // SDL_PLATFORM_XBOXSERIES
63#include <d3d12_xs.h>
64#endif
65
66#define D3D_GUID(X) (X)
67
68#define D3D_SAFE_RELEASE(X) \
69 if (X) { \
70 (X)->Release(); \
71 X = NULL; \
72 }
73
74// Older versions of the Xbox GDK may not have this defined
75#ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
76#define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT 256
77#endif
78#ifndef D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE
79#define D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE ((D3D12_RESOURCE_STATES) (0x40 | 0x80))
80#endif
81#ifndef D3D12_HEAP_TYPE_GPU_UPLOAD
82#define D3D12_HEAP_TYPE_GPU_UPLOAD ((D3D12_HEAP_TYPE) 5)
83#endif
84
85// DXGI_PRESENT flags are removed on Xbox
86#define DXGI_PRESENT_ALLOW_TEARING 0
87
88// Xbox D3D12 does not define the COBJMACROS, so we need to define them ourselves
89#include "SDL_d3d12_xbox_cmacros.h"
90
91// They don't even define the CMACROS for ID3DBlob, come on man
92#define ID3D10Blob_GetBufferPointer(blob) blob->GetBufferPointer()
93#define ID3D10Blob_GetBufferSize(blob) blob->GetBufferSize()
94#define ID3D10Blob_Release(blob) blob->Release()
95
96/* Xbox's D3D12 ABI actually varies from Windows, if a function does not exist
97 * in the above header then you need to use this instead :(
98 */
99#define D3D_CALL_RET(THIS, FUNC, RETVAL, ...) *(RETVAL) = (THIS)->FUNC(__VA_ARGS__)
100
101#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
102
103#endif // SDL_D3D12_H