GPU: Remove D3D11 backend and allow D3D12 to ingest DXBC (#11456)

This commit is contained in:
Evan Hemsley 2024-11-12 10:55:21 -08:00 committed by GitHub
parent fc12cc6dfd
commit 119b4fa5f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 6 additions and 8305 deletions

View File

@ -884,7 +884,6 @@
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_sse.c" />
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_std.c" />
<ClCompile Include="..\..\src\gpu\SDL_gpu.c" />
<ClCompile Include="..\..\src\gpu\d3d11\SDL_gpu_d3d11.c" />
<ClCompile Include="..\..\src\gpu\d3d12\SDL_gpu_d3d12.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.Scarlett.x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.XboxOne.x64'">CompileAsCpp</CompileAs>

View File

@ -58,7 +58,6 @@
<ClCompile Include="..\..\src\file\SDL_iostream.c" />
<ClCompile Include="..\..\src\filesystem\gdk\SDL_sysfilesystem.cpp" />
<ClCompile Include="..\..\src\gpu\SDL_gpu.c" />
<ClCompile Include="..\..\src\gpu\d3d11\SDL_gpu_d3d11.c" />
<ClCompile Include="..\..\src\gpu\d3d12\SDL_gpu_d3d12.c" />
<ClCompile Include="..\..\src\gpu\vulkan\SDL_gpu_vulkan.c" />
<ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c" />

View File

@ -413,7 +413,6 @@
<ClCompile Include="..\..\src\filesystem\SDL_filesystem.c" />
<ClCompile Include="..\..\src\filesystem\windows\SDL_sysfsops.c" />
<ClCompile Include="..\..\src\gpu\SDL_gpu.c" />
<ClCompile Include="..\..\src\gpu\d3d11\SDL_gpu_d3d11.c" />
<ClCompile Include="..\..\src\gpu\d3d12\SDL_gpu_d3d12.c" />
<ClCompile Include="..\..\src\gpu\vulkan\SDL_gpu_vulkan.c" />
<ClCompile Include="..\..\src\main\generic\SDL_sysmain_callbacks.c" />

View File

@ -1601,9 +1601,6 @@
<ClCompile Include="..\..\src\gpu\SDL_gpu.c">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gpu\d3d11\SDL_gpu_d3d11.c">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gpu\d3d12\SDL_gpu_d3d12.c">
<Filter>gpu</Filter>
</ClCompile>

View File

@ -782,8 +782,8 @@ typedef Uint32 SDL_GPUShaderFormat;
#define SDL_GPU_SHADERFORMAT_INVALID 0
#define SDL_GPU_SHADERFORMAT_PRIVATE (1u << 0) /**< Shaders for NDA'd platforms. */
#define SDL_GPU_SHADERFORMAT_SPIRV (1u << 1) /**< SPIR-V shaders for Vulkan. */
#define SDL_GPU_SHADERFORMAT_DXBC (1u << 2) /**< DXBC SM5_0 shaders for D3D11. */
#define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL shaders for D3D12. */
#define SDL_GPU_SHADERFORMAT_DXBC (1u << 2) /**< DXBC SM5_1 shaders for D3D12. */
#define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL SM6_0 shaders for D3D12. */
#define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */
#define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */
@ -2076,15 +2076,7 @@ extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUD
* - 1: Write-only storage textures, followed by write-only storage buffers
* - 2: Uniform buffers
*
* For DXBC Shader Model 5_0 shaders, use the following register order:
*
* - t registers: Sampled textures, followed by read-only storage textures,
* followed by read-only storage buffers
* - u registers: Write-only storage textures, followed by write-only storage
* buffers
* - b registers: Uniform buffers
*
* For DXIL shaders, use the following register order:
* For DXBC and DXIL shaders, use the following register order:
*
* - (t[n], space0): Sampled textures, followed by read-only storage textures,
* followed by read-only storage buffers
@ -2172,14 +2164,7 @@ extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(
* buffers
* - 3: Uniform buffers
*
* For DXBC Shader Model 5_0 shaders, use the following register order:
*
* - t registers: Sampled textures, followed by storage textures, followed by
* storage buffers
* - s registers: Samplers with indices corresponding to the sampled textures
* - b registers: Uniform buffers
*
* For DXIL shaders, use the following register order:
* For DXBC and DXIL shaders, use the following register order:
*
* For vertex shaders:
*

View File

@ -207,7 +207,6 @@
#endif // SDL_RENDER_DISABLED
#ifdef SDL_GPU_DISABLED
#undef SDL_GPU_D3D11
#undef SDL_GPU_D3D12
#undef SDL_GPU_METAL
#undef SDL_GPU_VULKAN

View File

@ -166,9 +166,6 @@ static const SDL_GPUBootstrap *backends[] = {
#endif
#ifdef SDL_GPU_D3D12
&D3D12Driver,
#endif
#ifdef SDL_GPU_D3D11
&D3D11Driver,
#endif
NULL
};

View File

@ -953,7 +953,6 @@ extern "C" {
#endif
extern SDL_GPUBootstrap VulkanDriver;
extern SDL_GPUBootstrap D3D11Driver;
extern SDL_GPUBootstrap D3D12Driver;
extern SDL_GPUBootstrap MetalDriver;
extern SDL_GPUBootstrap PS5Driver;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
fxc /T vs_5_0 /E FullscreenVert /Fh D3D11_FullscreenVert.h ..\d3dcommon\D3D_Blit.hlsl
fxc /T ps_5_0 /E BlitFrom2D /Fh D3D11_BlitFrom2D.h ..\d3dcommon\D3D_Blit.hlsl
fxc /T ps_5_0 /E BlitFrom2DArray /Fh D3D11_BlitFrom2DArray.h ..\d3dcommon\D3D_Blit.hlsl
fxc /T ps_5_0 /E BlitFrom3D /Fh D3D11_BlitFrom3D.h ..\d3dcommon\D3D_Blit.hlsl
fxc /T ps_5_0 /E BlitFromCube /Fh D3D11_BlitFromCube.h ..\d3dcommon\D3D_Blit.hlsl
fxc /T ps_5_0 /E BlitFromCubeArray /Fh D3D11_BlitFromCubeArray.h ..\d3dcommon\D3D_Blit.hlsl
copy /b D3D11_FullscreenVert.h+D3D11_BlitFrom2D.h+D3D11_BlitFrom2DArray.h+D3D11_BlitFrom3D.h+D3D11_BlitFromCube.h+D3D11_BlitFromCubeArray.h D3D11_Blit.h
del D3D11_FullscreenVert.h D3D11_BlitFrom2D.h D3D11_BlitFrom2DArray.h D3D11_BlitFrom3D.h D3D11_BlitFromCube.h D3D11_BlitFromCubeArray.h

View File

@ -5898,7 +5898,7 @@ static void D3D12_DownloadFromTexture(
* And just for some extra fun, D3D12 doesn't actually support depth pitch, so we have to realign that too!
*
* Since this is an async download we have to do all these fixups after the command is finished,
* so we'll cache the metadata similar to D3D11 and map and copy it when the command buffer is cleaned.
* so we'll cache the metadata and map and copy it when the command buffer is cleaned.
*/
if (pixelsPerRow == 0) {
@ -8676,7 +8676,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
SDL_GPUBootstrap D3D12Driver = {
"direct3d12",
SDL_GPU_SHADERFORMAT_DXIL,
SDL_GPU_SHADERFORMAT_DXIL | SDL_GPU_SHADERFORMAT_DXBC,
D3D12_PrepareDriver,
D3D12_CreateDevice
};

View File

@ -42,15 +42,6 @@ typedef struct GPU_ShaderModuleSource
#define HAVE_SPIRV_SHADERS 0
#endif
#ifdef SDL_GPU_D3D11
#define IF_D3D11(...) __VA_ARGS__
#define HAVE_DXBC50_SHADERS 1
#include "shaders/dxbc50.h"
#else
#define IF_D3D11(...)
#define HAVE_DXBC50_SHADERS 0
#endif
#ifdef SDL_GPU_D3D12
#define IF_D3D12(...) __VA_ARGS__
#define HAVE_DXIL60_SHADERS 1
@ -72,7 +63,6 @@ typedef struct GPU_ShaderModuleSource
typedef struct GPU_ShaderSources
{
IF_VULKAN(GPU_ShaderModuleSource spirv;)
IF_D3D11(GPU_ShaderModuleSource dxbc50;)
IF_D3D12(GPU_ShaderModuleSource dxil60;)
IF_METAL(GPU_ShaderModuleSource msl;)
unsigned int num_samplers;
@ -82,9 +72,6 @@ typedef struct GPU_ShaderSources
#define SHADER_SPIRV(code) \
IF_VULKAN(.spirv = { code, sizeof(code), SDL_GPU_SHADERFORMAT_SPIRV }, )
#define SHADER_DXBC50(code) \
IF_D3D11(.dxbc50 = { (const unsigned char *)code, sizeof(code), SDL_GPU_SHADERFORMAT_DXBC }, )
#define SHADER_DXIL60(code) \
IF_D3D12(.dxil60 = { code, sizeof(code), SDL_GPU_SHADERFORMAT_DXIL }, )
@ -97,7 +84,6 @@ static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
.num_samplers = 0,
.num_uniform_buffers = 1,
SHADER_SPIRV(linepoint_vert_spv)
SHADER_DXBC50(linepoint_vert_sm50_dxbc)
SHADER_DXIL60(linepoint_vert_sm60_dxil)
SHADER_METAL(linepoint_vert_metal)
},
@ -105,7 +91,6 @@ static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
.num_samplers = 0,
.num_uniform_buffers = 1,
SHADER_SPIRV(tri_color_vert_spv)
SHADER_DXBC50(tri_color_vert_sm50_dxbc)
SHADER_DXIL60(tri_color_vert_sm60_dxil)
SHADER_METAL(tri_color_vert_metal)
},
@ -113,7 +98,6 @@ static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
.num_samplers = 0,
.num_uniform_buffers = 1,
SHADER_SPIRV(tri_texture_vert_spv)
SHADER_DXBC50(tri_texture_vert_sm50_dxbc)
SHADER_DXIL60(tri_texture_vert_sm60_dxil)
SHADER_METAL(tri_texture_vert_metal)
},
@ -124,7 +108,6 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
.num_samplers = 0,
.num_uniform_buffers = 0,
SHADER_SPIRV(color_frag_spv)
SHADER_DXBC50(color_frag_sm50_dxbc)
SHADER_DXIL60(color_frag_sm60_dxil)
SHADER_METAL(color_frag_metal)
},
@ -132,7 +115,6 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
.num_samplers = 1,
.num_uniform_buffers = 0,
SHADER_SPIRV(texture_rgb_frag_spv)
SHADER_DXBC50(texture_rgb_frag_sm50_dxbc)
SHADER_DXIL60(texture_rgb_frag_sm60_dxil)
SHADER_METAL(texture_rgb_frag_metal)
},
@ -140,7 +122,6 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
.num_samplers = 1,
.num_uniform_buffers = 0,
SHADER_SPIRV(texture_rgba_frag_spv)
SHADER_DXBC50(texture_rgba_frag_sm50_dxbc)
SHADER_DXIL60(texture_rgba_frag_sm60_dxil)
SHADER_METAL(texture_rgba_frag_metal)
},
@ -159,10 +140,6 @@ static SDL_GPUShader *CompileShader(const GPU_ShaderSources *sources, SDL_GPUDev
} else if (formats & SDL_GPU_SHADERFORMAT_SPIRV) {
sms = &sources->spirv;
#endif // HAVE_SPIRV_SHADERS
#if HAVE_DXBC50_SHADERS
} else if (formats & SDL_GPU_SHADERFORMAT_DXBC) {
sms = &sources->dxbc50;
#endif // HAVE_DXBC50_SHADERS
#if HAVE_DXIL60_SHADERS
} else if (formats & SDL_GPU_SHADERFORMAT_DXIL) {
sms = &sources->dxil60;
@ -248,7 +225,6 @@ SDL_GPUShader *GPU_GetFragmentShader(GPU_Shaders *shaders, GPU_FragmentShaderID
void GPU_FillSupportedShaderFormats(SDL_PropertiesID props)
{
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN, HAVE_SPIRV_SHADERS);
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN, HAVE_DXBC50_SHADERS);
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN, HAVE_DXIL60_SHADERS);
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN, HAVE_METAL_SHADERS);
}