summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/SDL-3.2.8/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp')
-rw-r--r--contrib/SDL-3.2.8/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp b/contrib/SDL-3.2.8/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp
new file mode 100644
index 0000000..6c1c037
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp
@@ -0,0 +1,133 @@
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#if defined(SDL_VIDEO_RENDER_D3D12) && defined(SDL_PLATFORM_XBOXSERIES)
24
25#include <SDL3/SDL_stdinc.h>
26
27#include "../../core/windows/SDL_windows.h"
28#include "../../video/directx/SDL_d3d12.h"
29
30#include "SDL_shaders_d3d12.h"
31
32#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
33
34
35// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat
36
37#define g_main D3D12_PixelShader_Colors
38#include "D3D12_PixelShader_Colors_Series.h"
39#undef g_main
40
41#define g_main D3D12_PixelShader_Textures
42#include "D3D12_PixelShader_Textures_Series.h"
43#undef g_main
44
45#define g_main D3D12_PixelShader_Advanced
46#include "D3D12_PixelShader_Advanced_Series.h"
47#undef g_main
48
49
50#define g_mainColor D3D12_VertexShader_Colors
51#include "D3D12_VertexShader_Color_Series.h"
52#undef g_mainColor
53
54#define g_mainTexture D3D12_VertexShader_Textures
55#include "D3D12_VertexShader_Texture_Series.h"
56#undef g_mainTexture
57
58#define g_mainAdvanced D3D12_VertexShader_Advanced
59#include "D3D12_VertexShader_Advanced_Series.h"
60#undef g_mainAdvanced
61
62
63#define g_ColorRS D3D12_RootSig_Color
64#include "D3D12_RootSig_Color_Series.h"
65#undef g_ColorRS
66
67#define g_TextureRS D3D12_RootSig_Texture
68#include "D3D12_RootSig_Texture_Series.h"
69#undef g_TextureRS
70
71#define g_AdvancedRS D3D12_RootSig_Advanced
72#include "D3D12_RootSig_Advanced_Series.h"
73#undef g_AdvancedRS
74
75
76static struct
77{
78 const void *ps_shader_data;
79 SIZE_T ps_shader_size;
80 const void *vs_shader_data;
81 SIZE_T vs_shader_size;
82 D3D12_RootSignature root_sig;
83} D3D12_shaders[NUM_SHADERS] = {
84 { D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
85 D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
86 ROOTSIG_COLOR },
87 { D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
88 D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
89 ROOTSIG_TEXTURE },
90 { D3D12_PixelShader_Advanced, sizeof(D3D12_PixelShader_Advanced),
91 D3D12_VertexShader_Advanced, sizeof(D3D12_VertexShader_Advanced),
92 ROOTSIG_ADVANCED },
93};
94
95static struct
96{
97 const void *rs_shader_data;
98 SIZE_T rs_shader_size;
99} D3D12_rootsigs[NUM_ROOTSIGS] = {
100 { D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
101 { D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
102 { D3D12_RootSig_Advanced, sizeof(D3D12_RootSig_Advanced) },
103};
104
105extern "C"
106void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
107{
108 outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
109 outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
110}
111
112extern "C"
113void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
114{
115 outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
116 outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
117}
118
119extern "C"
120D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader)
121{
122 return D3D12_shaders[shader].root_sig;
123}
124
125extern "C"
126void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
127{
128 outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
129 outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
130}
131
132#endif // SDL_VIDEO_RENDER_D3D12 && SDL_PLATFORM_XBOXSERIES
133