Add the SDL_GPU API

Project Lead: Evan Hemsley <evan@moonside.games>

Co-designer, Metal Port, Console Ports:

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>

Production, QA, Debug:

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>

SDL_Render Driver, Bugfixes:

Co-authored-by: Andrei Alexeyev <akari@taisei-project.org>

Additional D3D12 Programming, Bugfixes:

Co-authored-by: Bart van der Werf <bluelive@gmail.com>

Bugfixes and Feedback:

Co-authored-by: Zakary Strange <zakarystrange@gmail.com>
Co-authored-by: meyraud705 <meyraud705@gmail.com>
Co-authored-by: Joshua T. Fisher <playmer@gmail.com>
Co-authored-by: Topi Ritala <ritalat@fastmail.com>
Co-authored-by: David Gow <david@ingeniumdigital.com>

Original API Proposal:

Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
This commit is contained in:
cosmonaut
2024-03-18 11:43:23 -07:00
committed by Sam Lantinga
parent 8ddb099d3e
commit 2e7d5bb429
96 changed files with 60218 additions and 66 deletions
+2
View File
@@ -83,6 +83,8 @@ VisualC/tests/testyuv/testyuv.bmp
VisualC-GDK/**/Layout VisualC-GDK/**/Layout
src/render/direct3d12/D3D12_*_One.h src/render/direct3d12/D3D12_*_One.h
src/render/direct3d12/D3D12_*_Series.h src/render/direct3d12/D3D12_*_Series.h
src/gpu/d3d12/D3D12_*_One.h
src/gpu/d3d12/D3D12_*_Series.h
Directory.Build.props Directory.Build.props
# for Android # for Android
+2
View File
@@ -35,6 +35,8 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \ $(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \
$(wildcard $(LOCAL_PATH)/src/events/*.c) \ $(wildcard $(LOCAL_PATH)/src/events/*.c) \
$(wildcard $(LOCAL_PATH)/src/file/*.c) \ $(wildcard $(LOCAL_PATH)/src/file/*.c) \
$(wildcard $(LOCAL_PATH)/src/gpu/*.c) \
$(wildcard $(LOCAL_PATH)/src/gpu/vulkan/*.c) \
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \ $(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
$(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \ $(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
+39
View File
@@ -233,6 +233,7 @@ endmacro()
define_sdl_subsystem(Audio) define_sdl_subsystem(Audio)
define_sdl_subsystem(Video) define_sdl_subsystem(Video)
define_sdl_subsystem(Gpu DEPS SDL_VIDEO)
define_sdl_subsystem(Render DEPS SDL_VIDEO) define_sdl_subsystem(Render DEPS SDL_VIDEO)
define_sdl_subsystem(Camera DEPS SDL_VIDEO) define_sdl_subsystem(Camera DEPS SDL_VIDEO)
define_sdl_subsystem(Joystick) define_sdl_subsystem(Joystick)
@@ -331,6 +332,7 @@ dep_option(SDL_RENDER_D3D "Enable the Direct3D 9 render driver" ON "SDL
dep_option(SDL_RENDER_D3D11 "Enable the Direct3D 11 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF) dep_option(SDL_RENDER_D3D11 "Enable the Direct3D 11 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
dep_option(SDL_RENDER_D3D12 "Enable the Direct3D 12 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF) dep_option(SDL_RENDER_D3D12 "Enable the Direct3D 12 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;${APPLE}" OFF) dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;${APPLE}" OFF)
set_option(SDL_RENDER_GPU "Enable the SDL_Gpu render driver" ON)
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF) dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF) dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF)
dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN" OFF) dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN" OFF)
@@ -350,6 +352,7 @@ set_option(SDL_LIBUDEV "Enable libudev support" ON)
set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF) set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF)
set_option(SDL_CCACHE "Use Ccache to speed up build" OFF) set_option(SDL_CCACHE "Use Ccache to speed up build" OFF)
set_option(SDL_CLANG_TIDY "Run clang-tidy static analysis" OFF) set_option(SDL_CLANG_TIDY "Run clang-tidy static analysis" OFF)
set_option(SDL_GPU_DXVK "Build SDL_Gpu with DXVK support" OFF)
set(SDL_VENDOR_INFO "" CACHE STRING "Vendor name and/or version to add to SDL_REVISION") set(SDL_VENDOR_INFO "" CACHE STRING "Vendor name and/or version to add to SDL_REVISION")
@@ -1123,6 +1126,7 @@ sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/events/*.c" "${SDL3_SOURCE_DIR}/src/events/*.c"
"${SDL3_SOURCE_DIR}/src/file/*.c" "${SDL3_SOURCE_DIR}/src/file/*.c"
"${SDL3_SOURCE_DIR}/src/filesystem/*.c" "${SDL3_SOURCE_DIR}/src/filesystem/*.c"
"${SDL3_SOURCE_DIR}/src/gpu/*.c"
"${SDL3_SOURCE_DIR}/src/joystick/*.c" "${SDL3_SOURCE_DIR}/src/joystick/*.c"
"${SDL3_SOURCE_DIR}/src/haptic/*.c" "${SDL3_SOURCE_DIR}/src/haptic/*.c"
"${SDL3_SOURCE_DIR}/src/hidapi/*.c" "${SDL3_SOURCE_DIR}/src/hidapi/*.c"
@@ -1704,6 +1708,16 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
) )
endif() endif()
if(SDL_GPU AND SDL_GPU_DXVK)
if(PKG_CONFIG_FOUND)
pkg_search_module(DXVK_NATIVE dxvk-dxgi)
if(DXVK_NATIVE_FOUND)
set(HAVE_D3D11_H TRUE)
sdl_include_directories(PRIVATE SYSTEM ${DXVK_NATIVE_INCLUDE_DIRS})
endif()
endif()
endif()
# Always compiled for Linux, unconditionally: # Always compiled for Linux, unconditionally:
sdl_sources( sdl_sources(
"${SDL3_SOURCE_DIR}/src/core/linux/SDL_evdev_capabilities.c" "${SDL3_SOURCE_DIR}/src/core/linux/SDL_evdev_capabilities.c"
@@ -2363,6 +2377,10 @@ elseif(APPLE)
set(SDL_VIDEO_RENDER_METAL 1) set(SDL_VIDEO_RENDER_METAL 1)
set(HAVE_RENDER_METAL TRUE) set(HAVE_RENDER_METAL TRUE)
endif() endif()
if (SDL_GPU)
set(SDL_GPU_METAL 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/gpu/metal/*.m")
endif()
endif() endif()
endif() endif()
endif() endif()
@@ -2925,6 +2943,27 @@ if(SDL_VIDEO)
endif() endif()
endif() endif()
if(SDL_GPU)
if(HAVE_D3D11_H)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/gpu/d3d11/*.c")
set(SDL_GPU_D3D11 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(SDL_RENDER_D3D12)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/gpu/d3d12/*.c")
set(SDL_GPU_D3D12 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(SDL_VIDEO_VULKAN)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/gpu/vulkan/*.c")
set(SDL_GPU_VULKAN 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(SDL_RENDER_GPU)
set(SDL_VIDEO_RENDER_GPU 1)
endif()
endif()
# Dummies # Dummies
# configure.ac does it differently: # configure.ac does it differently:
# if not have X # if not have X
+15
View File
@@ -166,6 +166,7 @@
</Link> </Link>
<PreBuildEvent> <PreBuildEvent>
<Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir)</Command> <Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir)</Command>
<Command>$(SolutionDir)..\src\gpu\d3d12\compile_shaders_xbox.bat $(SolutionDir)</Command>
</PreBuildEvent> </PreBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Message>Building shader blobs (Xbox Series)</Message> <Message>Building shader blobs (Xbox Series)</Message>
@@ -200,6 +201,7 @@
</Link> </Link>
<PreBuildEvent> <PreBuildEvent>
<Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir) one</Command> <Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir) one</Command>
<Command>$(SolutionDir)..\src\gpu\d3d12\compile_shaders_xbox.bat $(SolutionDir) one</Command>
</PreBuildEvent> </PreBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Message>Building shader blobs (Xbox One)</Message> <Message>Building shader blobs (Xbox One)</Message>
@@ -266,6 +268,7 @@
</Link> </Link>
<PreBuildEvent> <PreBuildEvent>
<Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir)</Command> <Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir)</Command>
<Command>$(SolutionDir)..\src\gpu\d3d12\compile_shaders_xbox.bat $(SolutionDir)</Command>
</PreBuildEvent> </PreBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Message>Building shader blobs (Xbox Series)</Message> <Message>Building shader blobs (Xbox Series)</Message>
@@ -301,6 +304,7 @@
</Link> </Link>
<PreBuildEvent> <PreBuildEvent>
<Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir) one</Command> <Command>$(SolutionDir)..\src\render\direct3d12\compile_shaders_xbox.bat $(SolutionDir) one</Command>
<Command>$(SolutionDir)..\src\gpu\d3d12\compile_shaders_xbox.bat $(SolutionDir) one</Command>
</PreBuildEvent> </PreBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Message>Building shader blobs (Xbox One)</Message> <Message>Building shader blobs (Xbox One)</Message>
@@ -330,6 +334,7 @@
<ClInclude Include="..\..\include\SDL3\SDL_events.h" /> <ClInclude Include="..\..\include\SDL3\SDL_events.h" />
<ClInclude Include="..\..\include\SDL3\SDL_filesystem.h" /> <ClInclude Include="..\..\include\SDL3\SDL_filesystem.h" />
<ClInclude Include="..\..\include\SDL3\SDL_gamepad.h" /> <ClInclude Include="..\..\include\SDL3\SDL_gamepad.h" />
<ClInclude Include="..\..\include\SDL3\SDL_gpu.h" />
<ClInclude Include="..\..\include\SDL3\SDL_guid.h" /> <ClInclude Include="..\..\include\SDL3\SDL_guid.h" />
<ClInclude Include="..\..\include\SDL3\SDL_haptic.h" /> <ClInclude Include="..\..\include\SDL3\SDL_haptic.h" />
<ClInclude Include="..\..\include\SDL3\SDL_hints.h" /> <ClInclude Include="..\..\include\SDL3\SDL_hints.h" />
@@ -424,6 +429,7 @@
<ClInclude Include="..\..\src\events\SDL_touch_c.h" /> <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
<ClInclude Include="..\..\src\events\SDL_windowevents_c.h" /> <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
<ClInclude Include="..\..\src\filesystem\SDL_sysfilesystem.h" /> <ClInclude Include="..\..\src\filesystem\SDL_sysfilesystem.h" />
<ClInclude Include="..\..\src\gpu\SDL_sysgpu.h" />
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" /> <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" /> <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" /> <ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
@@ -865,6 +871,15 @@
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_lsx.c" /> <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_lsx.c" />
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_sse.c" /> <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_sse.c" />
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_std.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>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Xbox.Scarlett.x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Xbox.XboxOne.x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\..\src\gpu\vulkan\SDL_gpu_vulkan.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\src\core\windows\version.rc" /> <ResourceCompile Include="..\..\src\core\windows\version.rc" />
+6
View File
@@ -57,6 +57,10 @@
<ClCompile Include="..\..\src\events\SDL_windowevents.c" /> <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
<ClCompile Include="..\..\src\file\SDL_iostream.c" /> <ClCompile Include="..\..\src\file\SDL_iostream.c" />
<ClCompile Include="..\..\src\filesystem\gdk\SDL_sysfilesystem.cpp" /> <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" /> <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c" />
<ClCompile Include="..\..\src\haptic\SDL_haptic.c" /> <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
<ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" /> <ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" />
@@ -249,6 +253,7 @@
<ClInclude Include="..\..\include\SDL3\SDL_events.h" /> <ClInclude Include="..\..\include\SDL3\SDL_events.h" />
<ClInclude Include="..\..\include\SDL3\SDL_filesystem.h" /> <ClInclude Include="..\..\include\SDL3\SDL_filesystem.h" />
<ClInclude Include="..\..\include\SDL3\SDL_gamepad.h" /> <ClInclude Include="..\..\include\SDL3\SDL_gamepad.h" />
<ClInclude Include="..\..\include\SDL3\SDL_gpu.h" />
<ClInclude Include="..\..\include\SDL3\SDL_guid.h" /> <ClInclude Include="..\..\include\SDL3\SDL_guid.h" />
<ClInclude Include="..\..\include\SDL3\SDL_haptic.h" /> <ClInclude Include="..\..\include\SDL3\SDL_haptic.h" />
<ClInclude Include="..\..\include\SDL3\SDL_hints.h" /> <ClInclude Include="..\..\include\SDL3\SDL_hints.h" />
@@ -341,6 +346,7 @@
<ClInclude Include="..\..\src\filesystem\SDL_sysfilesystem.h"> <ClInclude Include="..\..\src\filesystem\SDL_sysfilesystem.h">
<Filter>filesystem</Filter> <Filter>filesystem</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\gpu\SDL_sysgpu.h" />
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" /> <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" /> <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" /> <ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
+4
View File
@@ -125,6 +125,7 @@
<ClInclude Include="..\src\events\SDL_touch_c.h" /> <ClInclude Include="..\src\events\SDL_touch_c.h" />
<ClInclude Include="..\src\events\SDL_windowevents_c.h" /> <ClInclude Include="..\src\events\SDL_windowevents_c.h" />
<ClInclude Include="..\src\filesystem\SDL_sysfilesystem.h" /> <ClInclude Include="..\src\filesystem\SDL_sysfilesystem.h" />
<ClInclude Include="..\src\gpu\SDL_sysgpu.h" />
<ClInclude Include="..\src\haptic\SDL_haptic_c.h" /> <ClInclude Include="..\src\haptic\SDL_haptic_c.h" />
<ClInclude Include="..\src\haptic\SDL_syshaptic.h" /> <ClInclude Include="..\src\haptic\SDL_syshaptic.h" />
<ClInclude Include="..\src\haptic\windows\SDL_dinputhaptic_c.h" /> <ClInclude Include="..\src\haptic\windows\SDL_dinputhaptic_c.h" />
@@ -343,6 +344,9 @@
<ClCompile Include="..\src\file\SDL_iostream.c" /> <ClCompile Include="..\src\file\SDL_iostream.c" />
<ClCompile Include="..\src\filesystem\SDL_filesystem.c" /> <ClCompile Include="..\src\filesystem\SDL_filesystem.c" />
<ClCompile Include="..\src\filesystem\windows\SDL_sysfsops.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\haptic\dummy\SDL_syshaptic.c" /> <ClCompile Include="..\src\haptic\dummy\SDL_syshaptic.c" />
<ClCompile Include="..\src\haptic\SDL_haptic.c" /> <ClCompile Include="..\src\haptic\SDL_haptic.c" />
<ClCompile Include="..\src\haptic\windows\SDL_dinputhaptic.c" /> <ClCompile Include="..\src\haptic\windows\SDL_dinputhaptic.c" />
+7
View File
@@ -254,6 +254,7 @@
<ClInclude Include="..\..\include\SDL3\SDL_events.h" /> <ClInclude Include="..\..\include\SDL3\SDL_events.h" />
<ClInclude Include="..\..\include\SDL3\SDL_filesystem.h" /> <ClInclude Include="..\..\include\SDL3\SDL_filesystem.h" />
<ClInclude Include="..\..\include\SDL3\SDL_gamepad.h" /> <ClInclude Include="..\..\include\SDL3\SDL_gamepad.h" />
<ClInclude Include="..\..\include\SDL3\SDL_gpu.h" />
<ClInclude Include="..\..\include\SDL3\SDL_guid.h" /> <ClInclude Include="..\..\include\SDL3\SDL_guid.h" />
<ClInclude Include="..\..\include\SDL3\SDL_haptic.h" /> <ClInclude Include="..\..\include\SDL3\SDL_haptic.h" />
<ClInclude Include="..\..\include\SDL3\SDL_hints.h" /> <ClInclude Include="..\..\include\SDL3\SDL_hints.h" />
@@ -348,6 +349,8 @@
<ClInclude Include="..\..\src\events\SDL_touch_c.h" /> <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
<ClInclude Include="..\..\src\events\SDL_windowevents_c.h" /> <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
<ClInclude Include="..\..\src\filesystem\SDL_sysfilesystem.h" /> <ClInclude Include="..\..\src\filesystem\SDL_sysfilesystem.h" />
<ClInclude Include="..\..\src\gpu\SDL_sysgpu.h" />
<ClInclude Include="..\..\src\gpu\vulkan\SDL_gpu_vulkan_vkfuncs.h" />
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" /> <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" /> <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" /> <ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
@@ -408,6 +411,10 @@
<ClCompile Include="..\..\src\dialog\SDL_dialog_utils.c" /> <ClCompile Include="..\..\src\dialog\SDL_dialog_utils.c" />
<ClCompile Include="..\..\src\filesystem\SDL_filesystem.c" /> <ClCompile Include="..\..\src\filesystem\SDL_filesystem.c" />
<ClCompile Include="..\..\src\filesystem\windows\SDL_sysfsops.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" /> <ClCompile Include="..\..\src\main\generic\SDL_sysmain_callbacks.c" />
<ClCompile Include="..\..\src\main\SDL_main_callbacks.c" /> <ClCompile Include="..\..\src\main\SDL_main_callbacks.c" />
<ClCompile Include="..\..\src\main\SDL_runapp.c" /> <ClCompile Include="..\..\src\main\SDL_runapp.c" />
+22
View File
@@ -198,6 +198,8 @@
</Filter> </Filter>
<Filter Include="time\windows"> <Filter Include="time\windows">
<UniqueIdentifier>{0000d7fda065b13b0ca4ab262c380000}</UniqueIdentifier> <UniqueIdentifier>{0000d7fda065b13b0ca4ab262c380000}</UniqueIdentifier>
<Filter Include="gpu">
<UniqueIdentifier>{098fbef9-d8a0-4b3b-b57b-d157d395335d}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="dialog"> <Filter Include="dialog">
<UniqueIdentifier>{00008dfdfa0190856fbf3c7db52d0000}</UniqueIdentifier> <UniqueIdentifier>{00008dfdfa0190856fbf3c7db52d0000}</UniqueIdentifier>
@@ -907,6 +909,14 @@
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\video\offscreen\SDL_offscreenwindow.h"> <ClInclude Include="..\..\src\video\offscreen\SDL_offscreenwindow.h">
<Filter>video\offscreen</Filter> <Filter>video\offscreen</Filter>
<ClInclude Include="..\..\include\SDL3\SDL_gpu.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gpu\SDL_sysgpu.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gpu\vulkan\SDL_gpu_vulkan_vkfuncs.h">
<Filter>gpu</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -1562,6 +1572,18 @@
<ClCompile Include="..\..\src\video\offscreen\SDL_offscreenwindow.c"> <ClCompile Include="..\..\src\video\offscreen\SDL_offscreenwindow.c">
<Filter>video\offscreen</Filter> <Filter>video\offscreen</Filter>
</ClCompile> </ClCompile>
<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>
<ClCompile Include="..\..\src\gpu\vulkan\SDL_gpu_vulkan.c">
<Filter>gpu</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\src\core\windows\version.rc" /> <ResourceCompile Include="..\..\src\core\windows\version.rc" />
+1
View File
@@ -43,6 +43,7 @@
#include <SDL3/SDL_events.h> #include <SDL3/SDL_events.h>
#include <SDL3/SDL_filesystem.h> #include <SDL3/SDL_filesystem.h>
#include <SDL3/SDL_gamepad.h> #include <SDL3/SDL_gamepad.h>
#include <SDL3/SDL_gpu.h>
#include <SDL3/SDL_guid.h> #include <SDL3/SDL_guid.h>
#include <SDL3/SDL_haptic.h> #include <SDL3/SDL_haptic.h>
#include <SDL3/SDL_hidapi.h> #include <SDL3/SDL_hidapi.h>
File diff suppressed because it is too large Load Diff
+102 -61
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -72,9 +72,9 @@ extern "C" {
/** /**
* The predefined log categories * The predefined log categories
* *
* By default the application category is enabled at the INFO level, the * By default the application and gpu categories are enabled at the INFO
* assert category is enabled at the WARN level, test is enabled at the * level, the assert category is enabled at the WARN level, test is enabled at
* VERBOSE level and all other categories are enabled at the ERROR level. * the VERBOSE level and all other categories are enabled at the ERROR level.
* *
* \since This enum is available since SDL 3.0.0. * \since This enum is available since SDL 3.0.0.
*/ */
@@ -87,6 +87,7 @@ typedef enum SDL_LogCategory
SDL_LOG_CATEGORY_AUDIO, SDL_LOG_CATEGORY_AUDIO,
SDL_LOG_CATEGORY_VIDEO, SDL_LOG_CATEGORY_VIDEO,
SDL_LOG_CATEGORY_RENDER, SDL_LOG_CATEGORY_RENDER,
SDL_LOG_CATEGORY_GPU,
SDL_LOG_CATEGORY_INPUT, SDL_LOG_CATEGORY_INPUT,
SDL_LOG_CATEGORY_TEST, SDL_LOG_CATEGORY_TEST,
@@ -426,6 +426,7 @@
#cmakedefine SDL_VIDEO_RENDER_PS2 @SDL_VIDEO_RENDER_PS2@ #cmakedefine SDL_VIDEO_RENDER_PS2 @SDL_VIDEO_RENDER_PS2@
#cmakedefine SDL_VIDEO_RENDER_PSP @SDL_VIDEO_RENDER_PSP@ #cmakedefine SDL_VIDEO_RENDER_PSP @SDL_VIDEO_RENDER_PSP@
#cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@ #cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@
#cmakedefine SDL_VIDEO_RENDER_GPU @SDL_VIDEO_RENDER_GPU@
/* Enable OpenGL support */ /* Enable OpenGL support */
#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
@@ -445,6 +446,12 @@
/* Enable Metal support */ /* Enable Metal support */
#cmakedefine SDL_VIDEO_METAL @SDL_VIDEO_METAL@ #cmakedefine SDL_VIDEO_METAL @SDL_VIDEO_METAL@
/* Enable GPU support */
#cmakedefine SDL_GPU_D3D11 @SDL_GPU_D3D11@
#cmakedefine SDL_GPU_D3D12 @SDL_GPU_D3D12@
#cmakedefine SDL_GPU_VULKAN @SDL_GPU_VULKAN@
#cmakedefine SDL_GPU_METAL @SDL_GPU_METAL@
/* Enable system power support */ /* Enable system power support */
#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@ #cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@
#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@ #cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
@@ -197,6 +197,8 @@
#endif #endif
#endif #endif
#define SDL_GPU_VULKAN SDL_VIDEO_VULKAN
/* Enable system power support */ /* Enable system power support */
#define SDL_POWER_ANDROID 1 #define SDL_POWER_ANDROID 1
@@ -260,6 +260,8 @@
#endif #endif
#endif #endif
#define SDL_GPU_VULKAN SDL_VIDEO_VULKAN
#ifndef SDL_VIDEO_METAL #ifndef SDL_VIDEO_METAL
#if SDL_PLATFORM_SUPPORTS_METAL #if SDL_PLATFORM_SUPPORTS_METAL
#define SDL_VIDEO_METAL 1 #define SDL_VIDEO_METAL 1
@@ -268,6 +270,8 @@
#endif #endif
#endif #endif
#define SDL_GPU_METAL SDL_VIDEO_METAL
/* Enable system power support */ /* Enable system power support */
#define SDL_POWER_MACOSX 1 #define SDL_POWER_MACOSX 1
@@ -310,6 +310,12 @@ typedef unsigned int uintptr_t;
/* Enable Vulkan support */ /* Enable Vulkan support */
#define SDL_VIDEO_VULKAN 1 #define SDL_VIDEO_VULKAN 1
#define SDL_GPU_D3D11 HAVE_D3D11_H
#if !defined(SDL_GPU_D3D12)
#define SDL_GPU_D3D12 1
#endif
#define SDL_GPU_VULKAN SDL_VIDEO_VULKAN
#ifndef SDL_VIDEO_RENDER_VULKAN #ifndef SDL_VIDEO_RENDER_VULKAN
#define SDL_VIDEO_RENDER_VULKAN 1 #define SDL_VIDEO_RENDER_VULKAN 1
#endif #endif
@@ -232,6 +232,12 @@
/* Enable Vulkan support */ /* Enable Vulkan support */
#define SDL_VIDEO_VULKAN 1 #define SDL_VIDEO_VULKAN 1
#define SDL_GPU_D3D11 HAVE_D3D11_H
#if !defined(SDL_GPU_D3D12)
#define SDL_GPU_D3D12 1
#endif
#define SDL_GPU_VULKAN SDL_VIDEO_VULKAN
/* Enable system power support */ /* Enable system power support */
#define SDL_POWER_WINDOWS 1 #define SDL_POWER_WINDOWS 1
@@ -200,6 +200,10 @@
#define SDL_VIDEO_RENDER_D3D12 1 #define SDL_VIDEO_RENDER_D3D12 1
#endif #endif
#if !defined(SDL_GPU_D3D12)
#define SDL_GPU_D3D12 1
#endif
/* Enable OpenGL support */ /* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL #ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL 1 #define SDL_VIDEO_OPENGL 1
+2
View File
@@ -91,6 +91,7 @@ static const char * const SDL_category_names[] = {
"AUDIO", "AUDIO",
"VIDEO", "VIDEO",
"RENDER", "RENDER",
"GPU",
"INPUT", "INPUT",
"TEST" "TEST"
}; };
@@ -270,6 +271,7 @@ static SDL_LogPriority SDL_GetDefaultLogPriority(int category)
switch (category) { switch (category) {
case SDL_LOG_CATEGORY_APPLICATION: case SDL_LOG_CATEGORY_APPLICATION:
case SDL_LOG_CATEGORY_GPU:
return SDL_LOG_PRIORITY_INFO; return SDL_LOG_PRIORITY_INFO;
case SDL_LOG_CATEGORY_ASSERT: case SDL_LOG_CATEGORY_ASSERT:
return SDL_LOG_PRIORITY_WARN; return SDL_LOG_PRIORITY_WARN;
+10
View File
@@ -64,6 +64,16 @@ SDL_bool SDL_GetGDKDefaultUser(void *outUserHandle)
return SDL_Unsupported(); return SDL_Unsupported();
} }
SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGpu(SDL_GpuDevice *device);
void SDL_GDKSuspendGpu(SDL_GpuDevice *device)
{
}
SDL_DECLSPEC void SDLCALL SDL_GDKResumeGpu(SDL_GpuDevice *device);
void SDL_GDKResumeGpu(SDL_GpuDevice *device)
{
}
#endif #endif
#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) #if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK))
+81
View File
@@ -1060,6 +1060,87 @@ SDL3_0.0.0 {
SDL_wcsnstr; SDL_wcsnstr;
SDL_wcsstr; SDL_wcsstr;
SDL_wcstol; SDL_wcstol;
SDL_CreateGpuDevice;
SDL_CreateGpuDeviceWithProperties;
SDL_DestroyGpuDevice;
SDL_GetGpuDriver;
SDL_CreateGpuComputePipeline;
SDL_CreateGpuGraphicsPipeline;
SDL_CreateGpuSampler;
SDL_CreateGpuShader;
SDL_CreateGpuTexture;
SDL_CreateGpuBuffer;
SDL_CreateGpuTransferBuffer;
SDL_SetGpuBufferName;
SDL_SetGpuTextureName;
SDL_InsertGpuDebugLabel;
SDL_PushGpuDebugGroup;
SDL_PopGpuDebugGroup;
SDL_ReleaseGpuTexture;
SDL_ReleaseGpuSampler;
SDL_ReleaseGpuBuffer;
SDL_ReleaseGpuTransferBuffer;
SDL_ReleaseGpuComputePipeline;
SDL_ReleaseGpuShader;
SDL_ReleaseGpuGraphicsPipeline;
SDL_BeginGpuRenderPass;
SDL_BindGpuGraphicsPipeline;
SDL_SetGpuViewport;
SDL_SetGpuScissor;
SDL_BindGpuVertexBuffers;
SDL_BindGpuIndexBuffer;
SDL_BindGpuVertexSamplers;
SDL_BindGpuVertexStorageTextures;
SDL_BindGpuVertexStorageBuffers;
SDL_BindGpuFragmentSamplers;
SDL_BindGpuFragmentStorageTextures;
SDL_BindGpuFragmentStorageBuffers;
SDL_PushGpuVertexUniformData;
SDL_PushGpuFragmentUniformData;
SDL_DrawGpuIndexedPrimitives;
SDL_DrawGpuPrimitives;
SDL_DrawGpuPrimitivesIndirect;
SDL_DrawGpuIndexedPrimitivesIndirect;
SDL_EndGpuRenderPass;
SDL_BeginGpuComputePass;
SDL_BindGpuComputePipeline;
SDL_BindGpuComputeStorageTextures;
SDL_BindGpuComputeStorageBuffers;
SDL_PushGpuComputeUniformData;
SDL_DispatchGpuCompute;
SDL_DispatchGpuComputeIndirect;
SDL_EndGpuComputePass;
SDL_MapGpuTransferBuffer;
SDL_UnmapGpuTransferBuffer;
SDL_BeginGpuCopyPass;
SDL_UploadToGpuTexture;
SDL_UploadToGpuBuffer;
SDL_CopyGpuTextureToTexture;
SDL_CopyGpuBufferToBuffer;
SDL_GenerateGpuMipmaps;
SDL_DownloadFromGpuTexture;
SDL_DownloadFromGpuBuffer;
SDL_EndGpuCopyPass;
SDL_BlitGpu;
SDL_SupportsGpuSwapchainComposition;
SDL_SupportsGpuPresentMode;
SDL_ClaimGpuWindow;
SDL_UnclaimGpuWindow;
SDL_SetGpuSwapchainParameters;
SDL_GetGpuSwapchainTextureFormat;
SDL_AcquireGpuCommandBuffer;
SDL_AcquireGpuSwapchainTexture;
SDL_SubmitGpu;
SDL_SubmitGpuAndAcquireFence;
SDL_WaitGpu;
SDL_WaitGpuForFences;
SDL_QueryGpuFence;
SDL_ReleaseGpuFence;
SDL_GpuTextureFormatTexelBlockSize;
SDL_SupportsGpuTextureFormat;
SDL_SupportsGpuSampleCount;
SDL_GDKSuspendGpu;
SDL_GDKResumeGpu;
# extra symbols go here (don't modify this line) # extra symbols go here (don't modify this line)
local: *; local: *;
}; };
+81
View File
@@ -1085,3 +1085,84 @@
#define SDL_wcsnstr SDL_wcsnstr_REAL #define SDL_wcsnstr SDL_wcsnstr_REAL
#define SDL_wcsstr SDL_wcsstr_REAL #define SDL_wcsstr SDL_wcsstr_REAL
#define SDL_wcstol SDL_wcstol_REAL #define SDL_wcstol SDL_wcstol_REAL
#define SDL_CreateGpuDevice SDL_CreateGpuDevice_REAL
#define SDL_CreateGpuDeviceWithProperties SDL_CreateGpuDeviceWithProperties_REAL
#define SDL_DestroyGpuDevice SDL_DestroyGpuDevice_REAL
#define SDL_GetGpuDriver SDL_GetGpuDriver_REAL
#define SDL_CreateGpuComputePipeline SDL_CreateGpuComputePipeline_REAL
#define SDL_CreateGpuGraphicsPipeline SDL_CreateGpuGraphicsPipeline_REAL
#define SDL_CreateGpuSampler SDL_CreateGpuSampler_REAL
#define SDL_CreateGpuShader SDL_CreateGpuShader_REAL
#define SDL_CreateGpuTexture SDL_CreateGpuTexture_REAL
#define SDL_CreateGpuBuffer SDL_CreateGpuBuffer_REAL
#define SDL_CreateGpuTransferBuffer SDL_CreateGpuTransferBuffer_REAL
#define SDL_SetGpuBufferName SDL_SetGpuBufferName_REAL
#define SDL_SetGpuTextureName SDL_SetGpuTextureName_REAL
#define SDL_InsertGpuDebugLabel SDL_InsertGpuDebugLabel_REAL
#define SDL_PushGpuDebugGroup SDL_PushGpuDebugGroup_REAL
#define SDL_PopGpuDebugGroup SDL_PopGpuDebugGroup_REAL
#define SDL_ReleaseGpuTexture SDL_ReleaseGpuTexture_REAL
#define SDL_ReleaseGpuSampler SDL_ReleaseGpuSampler_REAL
#define SDL_ReleaseGpuBuffer SDL_ReleaseGpuBuffer_REAL
#define SDL_ReleaseGpuTransferBuffer SDL_ReleaseGpuTransferBuffer_REAL
#define SDL_ReleaseGpuComputePipeline SDL_ReleaseGpuComputePipeline_REAL
#define SDL_ReleaseGpuShader SDL_ReleaseGpuShader_REAL
#define SDL_ReleaseGpuGraphicsPipeline SDL_ReleaseGpuGraphicsPipeline_REAL
#define SDL_BeginGpuRenderPass SDL_BeginGpuRenderPass_REAL
#define SDL_BindGpuGraphicsPipeline SDL_BindGpuGraphicsPipeline_REAL
#define SDL_SetGpuViewport SDL_SetGpuViewport_REAL
#define SDL_SetGpuScissor SDL_SetGpuScissor_REAL
#define SDL_BindGpuVertexBuffers SDL_BindGpuVertexBuffers_REAL
#define SDL_BindGpuIndexBuffer SDL_BindGpuIndexBuffer_REAL
#define SDL_BindGpuVertexSamplers SDL_BindGpuVertexSamplers_REAL
#define SDL_BindGpuVertexStorageTextures SDL_BindGpuVertexStorageTextures_REAL
#define SDL_BindGpuVertexStorageBuffers SDL_BindGpuVertexStorageBuffers_REAL
#define SDL_BindGpuFragmentSamplers SDL_BindGpuFragmentSamplers_REAL
#define SDL_BindGpuFragmentStorageTextures SDL_BindGpuFragmentStorageTextures_REAL
#define SDL_BindGpuFragmentStorageBuffers SDL_BindGpuFragmentStorageBuffers_REAL
#define SDL_PushGpuVertexUniformData SDL_PushGpuVertexUniformData_REAL
#define SDL_PushGpuFragmentUniformData SDL_PushGpuFragmentUniformData_REAL
#define SDL_DrawGpuIndexedPrimitives SDL_DrawGpuIndexedPrimitives_REAL
#define SDL_DrawGpuPrimitives SDL_DrawGpuPrimitives_REAL
#define SDL_DrawGpuPrimitivesIndirect SDL_DrawGpuPrimitivesIndirect_REAL
#define SDL_DrawGpuIndexedPrimitivesIndirect SDL_DrawGpuIndexedPrimitivesIndirect_REAL
#define SDL_EndGpuRenderPass SDL_EndGpuRenderPass_REAL
#define SDL_BeginGpuComputePass SDL_BeginGpuComputePass_REAL
#define SDL_BindGpuComputePipeline SDL_BindGpuComputePipeline_REAL
#define SDL_BindGpuComputeStorageTextures SDL_BindGpuComputeStorageTextures_REAL
#define SDL_BindGpuComputeStorageBuffers SDL_BindGpuComputeStorageBuffers_REAL
#define SDL_PushGpuComputeUniformData SDL_PushGpuComputeUniformData_REAL
#define SDL_DispatchGpuCompute SDL_DispatchGpuCompute_REAL
#define SDL_DispatchGpuComputeIndirect SDL_DispatchGpuComputeIndirect_REAL
#define SDL_EndGpuComputePass SDL_EndGpuComputePass_REAL
#define SDL_MapGpuTransferBuffer SDL_MapGpuTransferBuffer_REAL
#define SDL_UnmapGpuTransferBuffer SDL_UnmapGpuTransferBuffer_REAL
#define SDL_BeginGpuCopyPass SDL_BeginGpuCopyPass_REAL
#define SDL_UploadToGpuTexture SDL_UploadToGpuTexture_REAL
#define SDL_UploadToGpuBuffer SDL_UploadToGpuBuffer_REAL
#define SDL_CopyGpuTextureToTexture SDL_CopyGpuTextureToTexture_REAL
#define SDL_CopyGpuBufferToBuffer SDL_CopyGpuBufferToBuffer_REAL
#define SDL_GenerateGpuMipmaps SDL_GenerateGpuMipmaps_REAL
#define SDL_DownloadFromGpuTexture SDL_DownloadFromGpuTexture_REAL
#define SDL_DownloadFromGpuBuffer SDL_DownloadFromGpuBuffer_REAL
#define SDL_EndGpuCopyPass SDL_EndGpuCopyPass_REAL
#define SDL_BlitGpu SDL_BlitGpu_REAL
#define SDL_SupportsGpuSwapchainComposition SDL_SupportsGpuSwapchainComposition_REAL
#define SDL_SupportsGpuPresentMode SDL_SupportsGpuPresentMode_REAL
#define SDL_ClaimGpuWindow SDL_ClaimGpuWindow_REAL
#define SDL_UnclaimGpuWindow SDL_UnclaimGpuWindow_REAL
#define SDL_SetGpuSwapchainParameters SDL_SetGpuSwapchainParameters_REAL
#define SDL_GetGpuSwapchainTextureFormat SDL_GetGpuSwapchainTextureFormat_REAL
#define SDL_AcquireGpuCommandBuffer SDL_AcquireGpuCommandBuffer_REAL
#define SDL_AcquireGpuSwapchainTexture SDL_AcquireGpuSwapchainTexture_REAL
#define SDL_SubmitGpu SDL_SubmitGpu_REAL
#define SDL_SubmitGpuAndAcquireFence SDL_SubmitGpuAndAcquireFence_REAL
#define SDL_WaitGpu SDL_WaitGpu_REAL
#define SDL_WaitGpuForFences SDL_WaitGpuForFences_REAL
#define SDL_QueryGpuFence SDL_QueryGpuFence_REAL
#define SDL_ReleaseGpuFence SDL_ReleaseGpuFence_REAL
#define SDL_GpuTextureFormatTexelBlockSize SDL_GpuTextureFormatTexelBlockSize_REAL
#define SDL_SupportsGpuTextureFormat SDL_SupportsGpuTextureFormat_REAL
#define SDL_SupportsGpuSampleCount SDL_SupportsGpuSampleCount_REAL
#define SDL_GDKSuspendGpu SDL_GDKSuspendGpu_REAL
#define SDL_GDKResumeGpu SDL_GDKResumeGpu_REAL
+81
View File
@@ -1091,3 +1091,84 @@ SDL_DYNAPI_PROC(size_t,SDL_wcsnlen,(const wchar_t *a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsnstr,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(wchar_t*,SDL_wcsnstr,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsstr,(const wchar_t *a, const wchar_t *b),(a,b),return) SDL_DYNAPI_PROC(wchar_t*,SDL_wcsstr,(const wchar_t *a, const wchar_t *b),(a,b),return)
SDL_DYNAPI_PROC(long,SDL_wcstol,(const wchar_t *a, wchar_t **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(long,SDL_wcstol,(const wchar_t *a, wchar_t **b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_GpuDevice*,SDL_CreateGpuDevice,(SDL_GpuShaderFormat a, SDL_bool b, SDL_bool c, const char *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_GpuDevice*,SDL_CreateGpuDeviceWithProperties,(SDL_PropertiesID a),(a),return)
SDL_DYNAPI_PROC(void,SDL_DestroyGpuDevice,(SDL_GpuDevice *a),(a),)
SDL_DYNAPI_PROC(SDL_GpuDriver,SDL_GetGpuDriver,(SDL_GpuDevice *a),(a),return)
SDL_DYNAPI_PROC(SDL_GpuComputePipeline*,SDL_CreateGpuComputePipeline,(SDL_GpuDevice *a, SDL_GpuComputePipelineCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuGraphicsPipeline*,SDL_CreateGpuGraphicsPipeline,(SDL_GpuDevice *a, SDL_GpuGraphicsPipelineCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuSampler*,SDL_CreateGpuSampler,(SDL_GpuDevice *a, SDL_GpuSamplerCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuShader*,SDL_CreateGpuShader,(SDL_GpuDevice *a, SDL_GpuShaderCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuTexture*,SDL_CreateGpuTexture,(SDL_GpuDevice *a, SDL_GpuTextureCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuBuffer*,SDL_CreateGpuBuffer,(SDL_GpuDevice *a, SDL_GpuBufferCreateInfo* b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_CreateGpuTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBufferCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_SetGpuBufferName,(SDL_GpuDevice *a, SDL_GpuBuffer *b, const char *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_SetGpuTextureName,(SDL_GpuDevice *a, SDL_GpuTexture *b, const char *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_InsertGpuDebugLabel,(SDL_GpuCommandBuffer *a, const char *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_PushGpuDebugGroup,(SDL_GpuCommandBuffer *a, const char *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_PopGpuDebugGroup,(SDL_GpuCommandBuffer *a),(a),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuTexture,(SDL_GpuDevice *a, SDL_GpuTexture *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuSampler,(SDL_GpuDevice *a, SDL_GpuSampler *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuBuffer,(SDL_GpuDevice *a, SDL_GpuBuffer *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBuffer *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuComputePipeline,(SDL_GpuDevice *a, SDL_GpuComputePipeline *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuShader,(SDL_GpuDevice *a, SDL_GpuShader *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuGraphicsPipeline,(SDL_GpuDevice *a, SDL_GpuGraphicsPipeline *b),(a,b),)
SDL_DYNAPI_PROC(SDL_GpuCommandBuffer*,SDL_AcquireGpuCommandBuffer,(SDL_GpuDevice *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_PushGpuVertexUniformData,(SDL_GpuCommandBuffer *a, Uint32 b, const void *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_PushGpuFragmentUniformData,(SDL_GpuCommandBuffer *a, Uint32 b, const void *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_PushGpuComputeUniformData,(SDL_GpuCommandBuffer *a, Uint32 b, const void *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(SDL_GpuRenderPass*,SDL_BeginGpuRenderPass,(SDL_GpuCommandBuffer *a, SDL_GpuColorAttachmentInfo *b, Uint32 c, SDL_GpuDepthStencilAttachmentInfo *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_BindGpuGraphicsPipeline,(SDL_GpuRenderPass *a, SDL_GpuGraphicsPipeline *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_SetGpuViewport,(SDL_GpuRenderPass *a, SDL_GpuViewport *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_SetGpuScissor,(SDL_GpuRenderPass *a, SDL_Rect *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_BindGpuVertexBuffers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuBufferBinding *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuIndexBuffer,(SDL_GpuRenderPass *a, SDL_GpuBufferBinding *b, SDL_GpuIndexElementSize c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_BindGpuVertexSamplers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuTextureSamplerBinding *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuVertexStorageTextures,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuTexture **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuVertexStorageBuffers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuBuffer **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuFragmentSamplers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuTextureSamplerBinding *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuFragmentStorageTextures,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuTexture **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuFragmentStorageBuffers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuBuffer **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_DrawGpuIndexedPrimitives,(SDL_GpuRenderPass *a, Uint32 b, Uint32 c, Uint32 d, Sint32 e, Uint32 f),(a,b,c,d,e,f),)
SDL_DYNAPI_PROC(void,SDL_DrawGpuPrimitives,(SDL_GpuRenderPass *a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_DrawGpuPrimitivesIndirect,(SDL_GpuRenderPass *a, SDL_GpuBuffer *b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_DrawGpuIndexedPrimitivesIndirect,(SDL_GpuRenderPass *a, SDL_GpuBuffer *b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_EndGpuRenderPass,(SDL_GpuRenderPass *a),(a),)
SDL_DYNAPI_PROC(SDL_GpuComputePass*,SDL_BeginGpuComputePass,(SDL_GpuCommandBuffer *a, SDL_GpuStorageTextureWriteOnlyBinding *b, Uint32 c, SDL_GpuStorageBufferWriteOnlyBinding *d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_BindGpuComputePipeline,(SDL_GpuComputePass *a, SDL_GpuComputePipeline *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_BindGpuComputeStorageTextures,(SDL_GpuComputePass *a, Uint32 b, SDL_GpuTexture **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_BindGpuComputeStorageBuffers,(SDL_GpuComputePass *a, Uint32 b, SDL_GpuBuffer **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_DispatchGpuCompute,(SDL_GpuComputePass *a, Uint32 b, Uint32 c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_DispatchGpuComputeIndirect,(SDL_GpuComputePass *a, SDL_GpuBuffer *b, Uint32 c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_EndGpuComputePass,(SDL_GpuComputePass *a),(a),)
SDL_DYNAPI_PROC(void*,SDL_MapGpuTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBuffer *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_UnmapGpuTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBuffer *b),(a,b),)
SDL_DYNAPI_PROC(SDL_GpuCopyPass*,SDL_BeginGpuCopyPass,(SDL_GpuCommandBuffer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_UploadToGpuTexture,(SDL_GpuCopyPass *a, SDL_GpuTextureTransferInfo *b, SDL_GpuTextureRegion *c, SDL_bool d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_UploadToGpuBuffer,(SDL_GpuCopyPass *a, SDL_GpuTransferBufferLocation *b, SDL_GpuBufferRegion *c, SDL_bool d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_CopyGpuTextureToTexture,(SDL_GpuCopyPass *a, SDL_GpuTextureLocation *b, SDL_GpuTextureLocation *c, Uint32 d, Uint32 e, Uint32 f, SDL_bool g),(a,b,c,d,e,f,g),)
SDL_DYNAPI_PROC(void,SDL_CopyGpuBufferToBuffer,(SDL_GpuCopyPass *a, SDL_GpuBufferLocation *b, SDL_GpuBufferLocation *c, Uint32 d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GenerateGpuMipmaps,(SDL_GpuCommandBuffer *a, SDL_GpuTexture *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_DownloadFromGpuTexture,(SDL_GpuCopyPass *a, SDL_GpuTextureRegion *b, SDL_GpuTextureTransferInfo *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_DownloadFromGpuBuffer,(SDL_GpuCopyPass *a, SDL_GpuBufferRegion *b, SDL_GpuTransferBufferLocation *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_EndGpuCopyPass,(SDL_GpuCopyPass *a),(a),)
SDL_DYNAPI_PROC(void,SDL_BlitGpu,(SDL_GpuCommandBuffer *a, SDL_GpuBlitRegion *b, SDL_GpuBlitRegion *c, SDL_FlipMode d, SDL_GpuFilter e, SDL_bool f),(a,b,c,d,e,f),)
SDL_DYNAPI_PROC(SDL_bool,SDL_SupportsGpuSwapchainComposition,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuSwapchainComposition c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SupportsGpuPresentMode,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuPresentMode c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClaimGpuWindow,(SDL_GpuDevice *a, SDL_Window *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_UnclaimGpuWindow,(SDL_GpuDevice *a, SDL_Window *b),(a,b),)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetGpuSwapchainParameters,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuSwapchainComposition c, SDL_GpuPresentMode d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_GpuTextureFormat,SDL_GetGpuSwapchainTextureFormat,(SDL_GpuDevice *a, SDL_Window *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuTexture*,SDL_AcquireGpuSwapchainTexture,(SDL_GpuCommandBuffer *a, SDL_Window *b, Uint32 *c, Uint32 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_SubmitGpu,(SDL_GpuCommandBuffer *a),(a),)
SDL_DYNAPI_PROC(SDL_GpuFence*,SDL_SubmitGpuAndAcquireFence,(SDL_GpuCommandBuffer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_WaitGpu,(SDL_GpuDevice *a),(a),)
SDL_DYNAPI_PROC(void,SDL_WaitGpuForFences,(SDL_GpuDevice *a, SDL_bool b, SDL_GpuFence **c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(SDL_bool,SDL_QueryGpuFence,(SDL_GpuDevice *a, SDL_GpuFence *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_ReleaseGpuFence,(SDL_GpuDevice *a, SDL_GpuFence *b),(a,b),)
SDL_DYNAPI_PROC(Uint32,SDL_GpuTextureFormatTexelBlockSize,(SDL_GpuTextureFormat a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SupportsGpuTextureFormat,(SDL_GpuDevice *a, SDL_GpuTextureFormat b, SDL_GpuTextureType c, SDL_GpuTextureUsageFlags d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SupportsGpuSampleCount,(SDL_GpuDevice *a, SDL_GpuTextureFormat b, SDL_GpuSampleCount c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_GDKSuspendGpu,(SDL_GpuDevice *a),(a),)
SDL_DYNAPI_PROC(void,SDL_GDKResumeGpu,(SDL_GpuDevice *a),(a),)
+2400
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
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
copy /b D3D11_FullscreenVert.h+D3D11_BlitFrom2D.h+D3D11_BlitFrom2DArray.h+D3D11_BlitFrom3D.h+D3D11_BlitFromCube.h D3D11_Blit.h
del D3D11_FullscreenVert.h D3D11_BlitFrom2D.h D3D11_BlitFrom2DArray.h D3D11_BlitFrom3D.h D3D11_BlitFromCube.h
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+17
View File
@@ -0,0 +1,17 @@
rem This script runs for the Windows build, but also via the _xbox variant with these vars set.
rem Make sure to default to building for Windows if they're not set.
if %DXC%.==. set DXC=dxc
if %SUFFIX%.==. set SUFFIX=.h
echo Building with %DXC%
echo Suffix %SUFFIX%
cd "%~dp0"
%DXC% -E FullscreenVert -T vs_6_0 -Fh D3D12_FullscreenVert.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
%DXC% -E BlitFrom2D -T ps_6_0 -Fh D3D12_BlitFrom2D.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
%DXC% -E BlitFrom2DArray -T ps_6_0 -Fh D3D12_BlitFrom2DArray.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
%DXC% -E BlitFrom3D -T ps_6_0 -Fh D3D12_BlitFrom3D.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
%DXC% -E BlitFromCube -T ps_6_0 -Fh D3D12_BlitFromCube.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
copy /b D3D12_FullscreenVert.h+D3D12_BlitFrom2D.h+D3D12_BlitFrom2DArray.h+D3D12_BlitFrom3D.h+D3D12_BlitFromCube.h D3D12_Blit%SUFFIX%
del D3D12_FullscreenVert.h D3D12_BlitFrom2D.h D3D12_BlitFrom2DArray.h D3D12_BlitFrom3D.h D3D12_BlitFromCube.h
+13
View File
@@ -0,0 +1,13 @@
if %2.==one. goto setxboxone
rem Xbox Series compile
set DXC="%GameDKLatest%\GXDK\bin\Scarlett\DXC.exe"
set SUFFIX=_Series.h
goto startbuild
:setxboxone
set DXC="%GameDKLatest%\GXDK\bin\XboxOne\DXC.exe"
set SUFFIX=_One.h
:startbuild
call "%~dp0\compile_shaders.bat"
+91
View File
@@ -0,0 +1,91 @@
#if D3D12
#define BlitRS \
"DescriptorTable ( Sampler(s0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
"CBV(b0, space=3, visibility = SHADER_VISIBILITY_PIXEL),"\
#define REG(reg, space) register(reg, space)
#else
#define REG(reg, space) register(reg)
#endif
struct VertexToPixel
{
float2 tex : TEXCOORD0;
float4 pos : SV_POSITION;
};
cbuffer SourceRegionBuffer : REG(b0, space3)
{
float2 UVLeftTop;
float2 UVDimensions;
uint MipLevel;
float LayerOrDepth;
};
Texture2D SourceTexture2D : REG(t0, space2);
Texture2DArray SourceTexture2DArray : REG(t0, space2);
Texture3D SourceTexture3D : REG(t0, space2);
TextureCube SourceTextureCube : REG(t0, space2);
sampler SourceSampler : REG(s0, space2);
#if D3D12
[RootSignature(BlitRS)]
#endif
VertexToPixel FullscreenVert(uint vI : SV_VERTEXID)
{
float2 inTex = float2((vI << 1) & 2, vI & 2);
VertexToPixel Out = (VertexToPixel)0;
Out.tex = inTex;
Out.pos = float4(inTex * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
return Out;
}
#if D3D12
[RootSignature(BlitRS)]
#endif
float4 BlitFrom2D(VertexToPixel input) : SV_Target0
{
float2 newCoord = UVLeftTop + UVDimensions * input.tex;
return SourceTexture2D.SampleLevel(SourceSampler, newCoord, MipLevel);
}
#if D3D12
[RootSignature(BlitRS)]
#endif
float4 BlitFrom2DArray(VertexToPixel input) : SV_Target0
{
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, (uint)LayerOrDepth);
return SourceTexture2DArray.SampleLevel(SourceSampler, newCoord, MipLevel);
}
#if D3D12
[RootSignature(BlitRS)]
#endif
float4 BlitFrom3D(VertexToPixel input) : SV_Target0
{
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, LayerOrDepth);
return SourceTexture3D.SampleLevel(SourceSampler, newCoord, MipLevel);
}
#if D3D12
[RootSignature(BlitRS)]
#endif
float4 BlitFromCube(VertexToPixel input) : SV_Target0
{
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
float3 newCoord;
float2 scaledUV = UVLeftTop + UVDimensions * input.tex;
float u = 2.0 * scaledUV.x - 1.0;
float v = 2.0 * scaledUV.y - 1.0;
switch ((uint)LayerOrDepth) {
case 0: newCoord = float3(1.0, -v, -u); break; // POSITIVE X
case 1: newCoord = float3(-1.0, -v, u); break; // NEGATIVE X
case 2: newCoord = float3(u, -1.0, -v); break; // POSITIVE Y
case 3: newCoord = float3(u, 1.0, v); break; // NEGATIVE Y
case 4: newCoord = float3(u, -v, 1.0); break; // POSITIVE Z
case 5: newCoord = float3(-u, -v, -1.0); break; // NEGATIVE Z
default: newCoord = float3(0, 0, 0); break; // silences warning
}
return SourceTextureCube.SampleLevel(SourceSampler, newCoord, MipLevel);
}
File diff suppressed because it is too large Load Diff
+85
View File
@@ -0,0 +1,85 @@
#include <metal_stdlib>
using namespace metal;
struct VertexToFragment {
float2 tex;
float4 pos [[position]];
};
struct SourceRegion {
float2 UVLeftTop;
float2 UVDimensions;
uint MipLevel;
float LayerOrDepth;
};
#if COMPILE_FullscreenVert
vertex VertexToFragment FullscreenVert(uint vI [[vertex_id]]) {
float2 inTex = float2((vI << 1) & 2, vI & 2);
VertexToFragment out;
out.tex = inTex;
out.pos = float4(inTex * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
return out;
}
#endif
#if COMPILE_BlitFrom2D
fragment float4 BlitFrom2D(
VertexToFragment input [[stage_in]],
constant SourceRegion &sourceRegion [[buffer(0)]],
texture2d<float> sourceTexture [[texture(0)]],
sampler sourceSampler [[sampler(0)]])
{
float2 newCoord = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
return sourceTexture.sample(sourceSampler, newCoord, level(sourceRegion.MipLevel));
}
#endif
#if COMPILE_BlitFrom2DArray
fragment float4 BlitFrom2DArray(
VertexToFragment input [[stage_in]],
constant SourceRegion &sourceRegion [[buffer(0)]],
texture2d_array<float> sourceTexture [[texture(0)]],
sampler sourceSampler [[sampler(0)]])
{
float2 newCoord = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
return sourceTexture.sample(sourceSampler, newCoord, (uint)sourceRegion.LayerOrDepth, level(sourceRegion.MipLevel));
}
#endif
#if COMPILE_BlitFrom3D
fragment float4 BlitFrom3D(
VertexToFragment input [[stage_in]],
constant SourceRegion &sourceRegion [[buffer(0)]],
texture3d<float> sourceTexture [[texture(0)]],
sampler sourceSampler [[sampler(0)]])
{
float2 newCoord = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
return sourceTexture.sample(sourceSampler, float3(newCoord, sourceRegion.LayerOrDepth), level(sourceRegion.MipLevel));
}
#endif
#if COMPILE_BlitFromCube
fragment float4 BlitFromCube(
VertexToFragment input [[stage_in]],
constant SourceRegion &sourceRegion [[buffer(0)]],
texturecube<float> sourceTexture [[texture(0)]],
sampler sourceSampler [[sampler(0)]])
{
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
float2 scaledUV = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
float u = 2.0 * scaledUV.x - 1.0;
float v = 2.0 * scaledUV.y - 1.0;
float3 newCoord;
switch ((uint)sourceRegion.LayerOrDepth) {
case 0: newCoord = float3(1.0, -v, -u); break; // POSITIVE X
case 1: newCoord = float3(-1.0, -v, u); break; // NEGATIVE X
case 2: newCoord = float3(u, -1.0, -v); break; // POSITIVE Y
case 3: newCoord = float3(u, 1.0, v); break; // NEGATIVE Y
case 4: newCoord = float3(u, -v, 1.0); break; // POSITIVE Z
case 5: newCoord = float3(-u, -v, -1.0); break; // NEGATIVE Z
default: newCoord = float3(0, 0, 0); break; // silences warning
}
return sourceTexture.sample(sourceSampler, newCoord, level(sourceRegion.MipLevel));
}
#endif
File diff suppressed because it is too large Load Diff
+68
View File
@@ -0,0 +1,68 @@
#!/bin/bash
set -x
set -e
cd `dirname "$0"`
shadernames=(FullscreenVert BlitFrom2D BlitFrom2DArray BlitFrom3D BlitFromCube)
generate_shaders()
{
fileplatform=$1
compileplatform=$2
sdkplatform=$3
minversion=$4
for shadername in "${shadernames[@]}"; do
xcrun -sdk $sdkplatform metal -c -std=$compileplatform-metal1.1 -m$sdkplatform-version-min=$minversion -Wall -O3 -D COMPILE_$shadername -o ./$shadername.air ./Metal_Blit.metal || exit $?
xcrun -sdk $sdkplatform metallib -o $shadername.metallib $shadername.air || exit $?
xxd -i $shadername.metallib | perl -w -p -e 's/\Aunsigned /const unsigned /;' >./${shadername}_$fileplatform.h
rm -f $shadername.air $shadername.metallib
done
}
generate_shaders macos macos macosx 10.11
generate_shaders ios ios iphoneos 8.0
generate_shaders iphonesimulator ios iphonesimulator 8.0
generate_shaders tvos ios appletvos 9.0
generate_shaders tvsimulator ios appletvsimulator 9.0
# Bundle together one mega-header
catShaders()
{
target=$1
for shadername in "${shadernames[@]}"; do
cat ${shadername}_$target.h >> Metal_Blit.h
done
}
rm -f Metal_Blit.h
echo "#if defined(SDL_PLATFORM_IOS)" >> Metal_Blit.h
echo "#if TARGET_OS_SIMULATOR" >> Metal_Blit.h
catShaders iphonesimulator
echo "#else" >> Metal_Blit.h
catShaders ios
echo "#endif" >> Metal_Blit.h
echo "#elif defined(SDL_PLATFORM_TVOS)" >> Metal_Blit.h
echo "#if TARGET_OS_SIMULATOR" >> Metal_Blit.h
catShaders tvsimulator
echo "#else" >> Metal_Blit.h
catShaders tvos
echo "#endif" >> Metal_Blit.h
echo "#else" >> Metal_Blit.h
catShaders macos
echo "#endif" >> Metal_Blit.h
# Clean up
cleanupShaders()
{
target=$1
for shadername in "${shadernames[@]}"; do
rm -f ${shadername}_$target.h
done
}
cleanupShaders iphonesimulator
cleanupShaders ios
cleanupShaders tvsimulator
cleanupShaders tvos
cleanupShaders macos
File diff suppressed because it is too large Load Diff
+176
View File
@@ -0,0 +1,176 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
* Global functions from the Vulkan Loader
*/
#ifndef VULKAN_GLOBAL_FUNCTION
#define VULKAN_GLOBAL_FUNCTION(name)
#endif
VULKAN_GLOBAL_FUNCTION(vkCreateInstance)
VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties)
VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties)
/*
* vkInstance, created by global vkCreateInstance function
*/
#ifndef VULKAN_INSTANCE_FUNCTION
#define VULKAN_INSTANCE_FUNCTION(name)
#endif
// Vulkan 1.0
VULKAN_INSTANCE_FUNCTION(vkGetDeviceProcAddr)
VULKAN_INSTANCE_FUNCTION(vkCreateDevice)
VULKAN_INSTANCE_FUNCTION(vkDestroyInstance)
VULKAN_INSTANCE_FUNCTION(vkEnumerateDeviceExtensionProperties)
VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties)
// VK_KHR_get_physical_device_properties2, needed for KHR_driver_properties
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties2KHR)
// VK_KHR_surface
VULKAN_INSTANCE_FUNCTION(vkDestroySurfaceKHR)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR)
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR)
// VK_EXT_debug_utils
VULKAN_INSTANCE_FUNCTION(vkCmdBeginDebugUtilsLabelEXT)
VULKAN_INSTANCE_FUNCTION(vkSetDebugUtilsObjectNameEXT)
VULKAN_INSTANCE_FUNCTION(vkCmdEndDebugUtilsLabelEXT)
VULKAN_INSTANCE_FUNCTION(vkCmdInsertDebugUtilsLabelEXT)
/*
* vkDevice, created by a vkInstance
*/
#ifndef VULKAN_DEVICE_FUNCTION
#define VULKAN_DEVICE_FUNCTION(name)
#endif
// Vulkan 1.0
VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers)
VULKAN_DEVICE_FUNCTION(vkAllocateDescriptorSets)
VULKAN_DEVICE_FUNCTION(vkAllocateMemory)
VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer)
VULKAN_DEVICE_FUNCTION(vkBindBufferMemory)
VULKAN_DEVICE_FUNCTION(vkBindImageMemory)
VULKAN_DEVICE_FUNCTION(vkCmdBeginRenderPass)
VULKAN_DEVICE_FUNCTION(vkCmdBindDescriptorSets)
VULKAN_DEVICE_FUNCTION(vkCmdBindIndexBuffer)
VULKAN_DEVICE_FUNCTION(vkCmdBindPipeline)
VULKAN_DEVICE_FUNCTION(vkCmdBindVertexBuffers)
VULKAN_DEVICE_FUNCTION(vkCmdBlitImage)
VULKAN_DEVICE_FUNCTION(vkCmdClearAttachments)
VULKAN_DEVICE_FUNCTION(vkCmdClearColorImage)
VULKAN_DEVICE_FUNCTION(vkCmdClearDepthStencilImage)
VULKAN_DEVICE_FUNCTION(vkCmdCopyBuffer)
VULKAN_DEVICE_FUNCTION(vkCmdCopyImage)
VULKAN_DEVICE_FUNCTION(vkCmdCopyBufferToImage)
VULKAN_DEVICE_FUNCTION(vkCmdCopyImageToBuffer)
VULKAN_DEVICE_FUNCTION(vkCmdDispatch)
VULKAN_DEVICE_FUNCTION(vkCmdDispatchIndirect)
VULKAN_DEVICE_FUNCTION(vkCmdDraw)
VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexed)
VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect)
VULKAN_DEVICE_FUNCTION(vkCmdDrawIndirect)
VULKAN_DEVICE_FUNCTION(vkCmdEndRenderPass)
VULKAN_DEVICE_FUNCTION(vkCmdPipelineBarrier)
VULKAN_DEVICE_FUNCTION(vkCmdResolveImage)
VULKAN_DEVICE_FUNCTION(vkCmdSetBlendConstants)
VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBias)
VULKAN_DEVICE_FUNCTION(vkCmdSetScissor)
VULKAN_DEVICE_FUNCTION(vkCmdSetStencilReference)
VULKAN_DEVICE_FUNCTION(vkCmdSetViewport)
VULKAN_DEVICE_FUNCTION(vkCreateBuffer)
VULKAN_DEVICE_FUNCTION(vkCreateCommandPool)
VULKAN_DEVICE_FUNCTION(vkCreateDescriptorPool)
VULKAN_DEVICE_FUNCTION(vkCreateDescriptorSetLayout)
VULKAN_DEVICE_FUNCTION(vkCreateFence)
VULKAN_DEVICE_FUNCTION(vkCreateFramebuffer)
VULKAN_DEVICE_FUNCTION(vkCreateComputePipelines)
VULKAN_DEVICE_FUNCTION(vkCreateGraphicsPipelines)
VULKAN_DEVICE_FUNCTION(vkCreateImage)
VULKAN_DEVICE_FUNCTION(vkCreateImageView)
VULKAN_DEVICE_FUNCTION(vkCreatePipelineCache)
VULKAN_DEVICE_FUNCTION(vkCreatePipelineLayout)
VULKAN_DEVICE_FUNCTION(vkCreateRenderPass)
VULKAN_DEVICE_FUNCTION(vkCreateSampler)
VULKAN_DEVICE_FUNCTION(vkCreateSemaphore)
VULKAN_DEVICE_FUNCTION(vkCreateShaderModule)
VULKAN_DEVICE_FUNCTION(vkDestroyBuffer)
VULKAN_DEVICE_FUNCTION(vkDestroyCommandPool)
VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorPool)
VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout)
VULKAN_DEVICE_FUNCTION(vkDestroyDevice)
VULKAN_DEVICE_FUNCTION(vkDestroyFence)
VULKAN_DEVICE_FUNCTION(vkDestroyFramebuffer)
VULKAN_DEVICE_FUNCTION(vkDestroyImage)
VULKAN_DEVICE_FUNCTION(vkDestroyImageView)
VULKAN_DEVICE_FUNCTION(vkDestroyPipeline)
VULKAN_DEVICE_FUNCTION(vkDestroyPipelineCache)
VULKAN_DEVICE_FUNCTION(vkDestroyPipelineLayout)
VULKAN_DEVICE_FUNCTION(vkDestroyRenderPass)
VULKAN_DEVICE_FUNCTION(vkDestroySampler)
VULKAN_DEVICE_FUNCTION(vkDestroySemaphore)
VULKAN_DEVICE_FUNCTION(vkDestroyShaderModule)
VULKAN_DEVICE_FUNCTION(vkDeviceWaitIdle)
VULKAN_DEVICE_FUNCTION(vkEndCommandBuffer)
VULKAN_DEVICE_FUNCTION(vkFreeCommandBuffers)
VULKAN_DEVICE_FUNCTION(vkFreeMemory)
VULKAN_DEVICE_FUNCTION(vkGetDeviceQueue)
VULKAN_DEVICE_FUNCTION(vkGetPipelineCacheData)
VULKAN_DEVICE_FUNCTION(vkGetFenceStatus)
VULKAN_DEVICE_FUNCTION(vkGetBufferMemoryRequirements)
VULKAN_DEVICE_FUNCTION(vkGetImageMemoryRequirements)
VULKAN_DEVICE_FUNCTION(vkMapMemory)
VULKAN_DEVICE_FUNCTION(vkQueueSubmit)
VULKAN_DEVICE_FUNCTION(vkQueueWaitIdle)
VULKAN_DEVICE_FUNCTION(vkResetCommandBuffer)
VULKAN_DEVICE_FUNCTION(vkResetCommandPool)
VULKAN_DEVICE_FUNCTION(vkResetDescriptorPool)
VULKAN_DEVICE_FUNCTION(vkResetFences)
VULKAN_DEVICE_FUNCTION(vkUnmapMemory)
VULKAN_DEVICE_FUNCTION(vkUpdateDescriptorSets)
VULKAN_DEVICE_FUNCTION(vkWaitForFences)
// VK_KHR_swapchain
VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR)
VULKAN_DEVICE_FUNCTION(vkCreateSwapchainKHR)
VULKAN_DEVICE_FUNCTION(vkDestroySwapchainKHR)
VULKAN_DEVICE_FUNCTION(vkQueuePresentKHR)
VULKAN_DEVICE_FUNCTION(vkGetSwapchainImagesKHR)
/*
* Redefine these every time you include this header!
*/
#undef VULKAN_GLOBAL_FUNCTION
#undef VULKAN_INSTANCE_FUNCTION
#undef VULKAN_DEVICE_FUNCTION
+1 -1
View File
@@ -20,7 +20,7 @@
*/ */
#include "SDL_internal.h" #include "SDL_internal.h"
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN) #if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN || SDL_VIDEO_RENDER_GPU)
// Set up for C function definitions, even when using C++ // Set up for C function definitions, even when using C++
#ifdef __cplusplus #ifdef __cplusplus
+4 -1
View File
@@ -137,7 +137,10 @@ static const SDL_RenderDriver *render_drivers[] = {
&VULKAN_RenderDriver, &VULKAN_RenderDriver,
#endif #endif
#if SDL_VIDEO_RENDER_SW #if SDL_VIDEO_RENDER_SW
&SW_RenderDriver &SW_RenderDriver,
#endif
#if SDL_VIDEO_RENDER_GPU
&GPU_RenderDriver,
#endif #endif
}; };
#endif // !SDL_RENDER_DISABLED #endif // !SDL_RENDER_DISABLED
+1
View File
@@ -324,6 +324,7 @@ extern SDL_RenderDriver PS2_RenderDriver;
extern SDL_RenderDriver PSP_RenderDriver; extern SDL_RenderDriver PSP_RenderDriver;
extern SDL_RenderDriver SW_RenderDriver; extern SDL_RenderDriver SW_RenderDriver;
extern SDL_RenderDriver VITA_GXM_RenderDriver; extern SDL_RenderDriver VITA_GXM_RenderDriver;
extern SDL_RenderDriver GPU_RenderDriver;
// Clean up any renderers at shutdown // Clean up any renderers at shutdown
extern void SDL_QuitRender(void); extern void SDL_QuitRender(void);
+74
View File
@@ -0,0 +1,74 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_gpu_util_h_
#define SDL_gpu_util_h_
#define SDL_GPU_BLENDOP_INVALID ((SDL_GpuBlendOp)0x7fffffff)
#define SDL_GPU_BLENDFACTOR_INVALID ((SDL_GpuBlendFactor)0x7fffffff)
static SDL_INLINE SDL_GpuBlendFactor GPU_ConvertBlendFactor(SDL_BlendFactor factor)
{
switch (factor) {
case SDL_BLENDFACTOR_ZERO:
return SDL_GPU_BLENDFACTOR_ZERO;
case SDL_BLENDFACTOR_ONE:
return SDL_GPU_BLENDFACTOR_ONE;
case SDL_BLENDFACTOR_SRC_COLOR:
return SDL_GPU_BLENDFACTOR_SRC_COLOR;
case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
return SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR;
case SDL_BLENDFACTOR_SRC_ALPHA:
return SDL_GPU_BLENDFACTOR_SRC_ALPHA;
case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
return SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
case SDL_BLENDFACTOR_DST_COLOR:
return SDL_GPU_BLENDFACTOR_DST_COLOR;
case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
return SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR;
case SDL_BLENDFACTOR_DST_ALPHA:
return SDL_GPU_BLENDFACTOR_DST_ALPHA;
case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
return SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA;
default:
return SDL_GPU_BLENDFACTOR_INVALID;
}
}
static SDL_INLINE SDL_GpuBlendOp GPU_ConvertBlendOperation(SDL_BlendOperation operation)
{
switch (operation) {
case SDL_BLENDOPERATION_ADD:
return SDL_GPU_BLENDOP_ADD;
case SDL_BLENDOPERATION_SUBTRACT:
return SDL_GPU_BLENDOP_SUBTRACT;
case SDL_BLENDOPERATION_REV_SUBTRACT:
return SDL_GPU_BLENDOP_REVERSE_SUBTRACT;
case SDL_BLENDOPERATION_MINIMUM:
return SDL_GPU_BLENDOP_MIN;
case SDL_BLENDOPERATION_MAXIMUM:
return SDL_GPU_BLENDOP_MAX;
default:
return SDL_GPU_BLENDOP_INVALID;
}
}
#endif // SDL_gpu_util_h
+223
View File
@@ -0,0 +1,223 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#if SDL_VIDEO_RENDER_GPU
#include "SDL_gpu_util.h"
#include "SDL_pipeline_gpu.h"
#include "../SDL_sysrender.h"
struct GPU_PipelineCacheKeyStruct
{
Uint64 blend_mode : 28;
Uint64 frag_shader : 4;
Uint64 vert_shader : 4;
Uint64 attachment_format : 6;
Uint64 primitive_type : 3;
};
typedef union GPU_PipelineCacheKey
{
struct GPU_PipelineCacheKeyStruct as_struct;
Uint64 as_uint64;
} GPU_PipelineCacheKey;
SDL_COMPILE_TIME_ASSERT(GPU_PipelineCacheKey_Size, sizeof(GPU_PipelineCacheKey) <= sizeof(Uint64));
typedef struct GPU_PipelineCacheEntry
{
GPU_PipelineCacheKey key;
SDL_GpuGraphicsPipeline *pipeline;
} GPU_PipelineCacheEntry;
static Uint32 HashPipelineCacheKey(const GPU_PipelineCacheKey *key)
{
Uint64 x = key->as_uint64;
// 64-bit uint hash function stolen from taisei (which stole it from somewhere else)
x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);
x = x ^ (x >> 31);
return (Uint32)(x & 0xffffffff);
}
static Uint32 HashPassthrough(const void *key, void *data)
{
// double-cast to silence a clang warning
return (Uint32)(uintptr_t)key;
}
static bool MatchPipelineCacheKey(const void *a, const void *b, void *data)
{
return a == b;
}
static void NukePipelineCacheEntry(const void *key, const void *value, void *data)
{
GPU_PipelineCacheEntry *entry = (GPU_PipelineCacheEntry *)value;
SDL_GpuDevice *device = data;
SDL_ReleaseGpuGraphicsPipeline(device, entry->pipeline);
SDL_free(entry);
}
bool GPU_InitPipelineCache(GPU_PipelineCache *cache, SDL_GpuDevice *device)
{
// FIXME how many buckets do we need?
cache->table = SDL_CreateHashTable(device, 32, HashPassthrough, MatchPipelineCacheKey, NukePipelineCacheEntry, true);
return (bool)cache->table;
}
void GPU_DestroyPipelineCache(GPU_PipelineCache *cache)
{
SDL_DestroyHashTable(cache->table);
}
static SDL_GpuGraphicsPipeline *MakePipeline(SDL_GpuDevice *device, GPU_Shaders *shaders, const GPU_PipelineParameters *params)
{
SDL_GpuColorAttachmentDescription ad;
SDL_zero(ad);
ad.format = params->attachment_format;
SDL_BlendMode blend = params->blend_mode;
ad.blendState.blendEnable = blend != 0;
ad.blendState.colorWriteMask = 0xF;
ad.blendState.alphaBlendOp = GPU_ConvertBlendOperation(SDL_GetBlendModeAlphaOperation(blend));
ad.blendState.dstAlphaBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstAlphaFactor(blend));
ad.blendState.srcAlphaBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcAlphaFactor(blend));
ad.blendState.colorBlendOp = GPU_ConvertBlendOperation(SDL_GetBlendModeColorOperation(blend));
ad.blendState.dstColorBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstColorFactor(blend));
ad.blendState.srcColorBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcColorFactor(blend));
SDL_GpuGraphicsPipelineCreateInfo pci;
SDL_zero(pci);
pci.attachmentInfo.hasDepthStencilAttachment = false;
pci.attachmentInfo.colorAttachmentCount = 1;
pci.attachmentInfo.colorAttachmentDescriptions = &ad;
pci.vertexShader = GPU_GetVertexShader(shaders, params->vert_shader);
pci.fragmentShader = GPU_GetFragmentShader(shaders, params->frag_shader);
pci.multisampleState.sampleCount = SDL_GPU_SAMPLECOUNT_1;
pci.multisampleState.sampleMask = 0xFFFF;
pci.primitiveType = params->primitive_type;
pci.rasterizerState.cullMode = SDL_GPU_CULLMODE_NONE;
pci.rasterizerState.fillMode = SDL_GPU_FILLMODE_FILL;
pci.rasterizerState.frontFace = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;
SDL_GpuVertexBinding bind;
SDL_zero(bind);
Uint32 num_attribs = 0;
SDL_GpuVertexAttribute attribs[4];
SDL_zero(attribs);
bool have_attr_color = false;
bool have_attr_uv = false;
switch (params->vert_shader) {
case VERT_SHADER_TRI_TEXTURE:
have_attr_uv = true;
SDL_FALLTHROUGH;
case VERT_SHADER_TRI_COLOR:
have_attr_color = true;
SDL_FALLTHROUGH;
default:
break;
}
// Position
attribs[num_attribs].location = num_attribs;
attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
attribs[num_attribs].offset = bind.stride;
bind.stride += 2 * sizeof(float);
num_attribs++;
if (have_attr_color) {
// Color
attribs[num_attribs].location = num_attribs;
attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4;
attribs[num_attribs].offset = bind.stride;
bind.stride += 4 * sizeof(float);
num_attribs++;
}
if (have_attr_uv) {
// UVs
attribs[num_attribs].location = num_attribs;
attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
attribs[num_attribs].offset = bind.stride;
bind.stride += 2 * sizeof(float);
num_attribs++;
}
pci.vertexInputState.vertexAttributeCount = num_attribs;
pci.vertexInputState.vertexAttributes = attribs;
pci.vertexInputState.vertexBindingCount = 1;
pci.vertexInputState.vertexBindings = &bind;
return SDL_CreateGpuGraphicsPipeline(device, &pci);
}
static GPU_PipelineCacheKey MakePipelineCacheKey(const GPU_PipelineParameters *params)
{
GPU_PipelineCacheKey key;
SDL_zero(key);
key.as_struct.blend_mode = params->blend_mode;
key.as_struct.frag_shader = params->frag_shader;
key.as_struct.vert_shader = params->vert_shader;
key.as_struct.attachment_format = params->attachment_format;
key.as_struct.primitive_type = params->primitive_type;
return key;
}
SDL_GpuGraphicsPipeline *GPU_GetPipeline(GPU_PipelineCache *cache, GPU_Shaders *shaders, SDL_GpuDevice *device, const GPU_PipelineParameters *params)
{
GPU_PipelineCacheKey key = MakePipelineCacheKey(params);
void *keyval = (void *)(uintptr_t)HashPipelineCacheKey(&key);
SDL_GpuGraphicsPipeline *pipeline = NULL;
void *iter = NULL;
GPU_PipelineCacheEntry *entry = NULL;
while (SDL_IterateHashTableKey(cache->table, keyval, (const void **)&entry, &iter)) {
if (entry->key.as_uint64 == key.as_uint64) {
return entry->pipeline;
}
}
pipeline = MakePipeline(device, shaders, params);
if (pipeline == NULL) {
return NULL;
}
entry = SDL_malloc(sizeof(*entry));
entry->key = key;
entry->pipeline = pipeline;
SDL_InsertIntoHashTable(cache->table, keyval, entry);
return pipeline;
}
#endif
+49
View File
@@ -0,0 +1,49 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_pipeline_gpu_h_
#define SDL_pipeline_gpu_h_
#include "SDL_internal.h"
#include "SDL_shaders_gpu.h"
#include "SDL_hashtable.h"
typedef struct GPU_PipelineParameters
{
SDL_BlendMode blend_mode;
GPU_FragmentShaderID frag_shader;
GPU_VertexShaderID vert_shader;
SDL_GpuTextureFormat attachment_format;
SDL_GpuPrimitiveType primitive_type;
} GPU_PipelineParameters;
typedef struct GPU_PipelineCache
{
SDL_HashTable *table;
} GPU_PipelineCache;
extern bool GPU_InitPipelineCache(GPU_PipelineCache *cache, SDL_GpuDevice *device);
extern void GPU_DestroyPipelineCache(GPU_PipelineCache *cache);
extern SDL_GpuGraphicsPipeline *GPU_GetPipeline(GPU_PipelineCache *cache, GPU_Shaders *shaders, SDL_GpuDevice *device, const GPU_PipelineParameters *params);
#endif // SDL_pipeline_gpu_h_
File diff suppressed because it is too large Load Diff
+241
View File
@@ -0,0 +1,241 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#if SDL_VIDEO_RENDER_GPU
#include "SDL_shaders_gpu.h"
// SDL_Gpu shader implementation
typedef struct GPU_ShaderModuleSource
{
const unsigned char *code;
unsigned int code_len;
SDL_GpuShaderFormat format;
} GPU_ShaderModuleSource;
#ifdef SDL_GPU_VULKAN
#define IF_VULKAN(...) __VA_ARGS__
#define HAVE_SPIRV_SHADERS 1
#include "shaders/spir-v.h"
#else
#define IF_VULKAN(...)
#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
#include "shaders/dxil60.h"
#else
#define IF_D3D12(...)
#define HAVE_DXIL60_SHADERS 0
#endif
#ifdef SDL_GPU_METAL
#define IF_METAL(...) __VA_ARGS__
#define HAVE_METAL_SHADERS 1
#include "shaders/metal.h"
#else
#define IF_METAL(...)
#define HAVE_METAL_SHADERS 0
#endif
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;
unsigned int num_uniform_buffers;
} GPU_ShaderSources;
#define SHADER_SPIRV(code) \
IF_VULKAN(.spirv = { code, sizeof(code), SDL_GPU_SHADERFORMAT_SPIRV }, )
#define SHADER_DXBC50(code) \
IF_D3D11(.dxbc50 = { code, sizeof(code), SDL_GPU_SHADERFORMAT_DXBC }, )
#define SHADER_DXIL60(code) \
IF_D3D12(.dxil60 = { code, sizeof(code), SDL_GPU_SHADERFORMAT_DXIL }, )
#define SHADER_METAL(code) \
IF_METAL(.msl = { code, sizeof(code), SDL_GPU_SHADERFORMAT_MSL }, )
// clang-format off
static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
[VERT_SHADER_LINEPOINT] = {
.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)
},
[VERT_SHADER_TRI_COLOR] = {
.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)
},
[VERT_SHADER_TRI_TEXTURE] = {
.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)
},
};
static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
[FRAG_SHADER_COLOR] = {
.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)
},
[FRAG_SHADER_TEXTURE_RGB] = {
.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)
},
[FRAG_SHADER_TEXTURE_RGBA] = {
.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_rgb_frag_metal)
},
};
// clang-format on
static SDL_GpuShader *CompileShader(const GPU_ShaderSources *sources, SDL_GpuDevice *device, SDL_GpuShaderStage stage)
{
const GPU_ShaderModuleSource *sms = NULL;
SDL_GpuDriver driver = SDL_GetGpuDriver(device);
switch (driver) {
// clang-format off
IF_VULKAN( case SDL_GPU_DRIVER_VULKAN: sms = &sources->spirv; break;)
IF_D3D11( case SDL_GPU_DRIVER_D3D11: sms = &sources->dxbc50; break;)
IF_D3D12( case SDL_GPU_DRIVER_D3D12: sms = &sources->dxil60; break;)
IF_METAL( case SDL_GPU_DRIVER_METAL: sms = &sources->msl; break;)
// clang-format on
default:
SDL_SetError("Unsupported GPU backend");
return NULL;
}
SDL_GpuShaderCreateInfo sci = { 0 };
sci.code = sms->code;
sci.codeSize = sms->code_len;
sci.format = sms->format;
// FIXME not sure if this is correct
sci.entryPointName = driver == SDL_GPU_DRIVER_METAL ? "main0" : "main";
sci.samplerCount = sources->num_samplers;
sci.uniformBufferCount = sources->num_uniform_buffers;
sci.stage = stage;
return SDL_CreateGpuShader(device, &sci);
}
bool GPU_InitShaders(GPU_Shaders *shaders, SDL_GpuDevice *device)
{
for (int i = 0; i < SDL_arraysize(vert_shader_sources); ++i) {
shaders->vert_shaders[i] = CompileShader(
&vert_shader_sources[i], device, SDL_GPU_SHADERSTAGE_VERTEX);
if (shaders->vert_shaders[i] == NULL) {
GPU_ReleaseShaders(shaders, device);
return false;
}
}
for (int i = 0; i < SDL_arraysize(frag_shader_sources); ++i) {
shaders->frag_shaders[i] = CompileShader(
&frag_shader_sources[i], device, SDL_GPU_SHADERSTAGE_FRAGMENT);
if (shaders->frag_shaders[i] == NULL) {
GPU_ReleaseShaders(shaders, device);
return false;
}
}
return true;
}
void GPU_ReleaseShaders(GPU_Shaders *shaders, SDL_GpuDevice *device)
{
for (int i = 0; i < SDL_arraysize(shaders->vert_shaders); ++i) {
SDL_ReleaseGpuShader(device, shaders->vert_shaders[i]);
shaders->vert_shaders[i] = NULL;
}
for (int i = 0; i < SDL_arraysize(shaders->frag_shaders); ++i) {
SDL_ReleaseGpuShader(device, shaders->frag_shaders[i]);
shaders->frag_shaders[i] = NULL;
}
}
SDL_GpuShader *GPU_GetVertexShader(GPU_Shaders *shaders, GPU_VertexShaderID id)
{
SDL_assert((unsigned int)id < SDL_arraysize(shaders->vert_shaders));
SDL_GpuShader *shader = shaders->vert_shaders[id];
SDL_assert(shader != NULL);
return shader;
}
SDL_GpuShader *GPU_GetFragmentShader(GPU_Shaders *shaders, GPU_FragmentShaderID id)
{
SDL_assert((unsigned int)id < SDL_arraysize(shaders->frag_shaders));
SDL_GpuShader *shader = shaders->frag_shaders[id];
SDL_assert(shader != NULL);
return shader;
}
void GPU_FillSupportedShaderFormats(SDL_PropertiesID props)
{
SDL_SetBooleanProperty(props, SDL_PROP_GPU_CREATEDEVICE_SHADERS_SPIRV_BOOL, HAVE_SPIRV_SHADERS);
SDL_SetBooleanProperty(props, SDL_PROP_GPU_CREATEDEVICE_SHADERS_DXBC_BOOL, HAVE_DXBC50_SHADERS);
SDL_SetBooleanProperty(props, SDL_PROP_GPU_CREATEDEVICE_SHADERS_DXIL_BOOL, HAVE_DXIL60_SHADERS);
SDL_SetBooleanProperty(props, SDL_PROP_GPU_CREATEDEVICE_SHADERS_MSL_BOOL, HAVE_METAL_SHADERS);
}
#endif // SDL_VIDEO_RENDER_GPU
+63
View File
@@ -0,0 +1,63 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_shaders_gpu_h_
#define SDL_shaders_gpu_h_
#include "SDL_internal.h"
// SDL_Gpu shader implementation
typedef enum
{
VERT_SHADER_INVALID = -1,
VERT_SHADER_LINEPOINT,
VERT_SHADER_TRI_COLOR,
VERT_SHADER_TRI_TEXTURE,
NUM_VERT_SHADERS,
} GPU_VertexShaderID;
typedef enum
{
FRAG_SHADER_INVALID = -1,
FRAG_SHADER_COLOR,
FRAG_SHADER_TEXTURE_RGB,
FRAG_SHADER_TEXTURE_RGBA,
NUM_FRAG_SHADERS,
} GPU_FragmentShaderID;
struct GPU_Shaders
{
SDL_GpuShader *vert_shaders[NUM_VERT_SHADERS];
SDL_GpuShader *frag_shaders[NUM_FRAG_SHADERS];
};
typedef struct GPU_Shaders GPU_Shaders;
void GPU_FillSupportedShaderFormats(SDL_PropertiesID props);
extern bool GPU_InitShaders(GPU_Shaders *shaders, SDL_GpuDevice *device);
extern void GPU_ReleaseShaders(GPU_Shaders *shaders, SDL_GpuDevice *device);
extern SDL_GpuShader *GPU_GetVertexShader(GPU_Shaders *shaders, GPU_VertexShaderID id);
extern SDL_GpuShader *GPU_GetFragmentShader(GPU_Shaders *shaders, GPU_FragmentShaderID id);
#endif // SDL_shaders_gpu_h_
+1
View File
@@ -0,0 +1 @@
*.h linguist-generated
+3
View File
@@ -0,0 +1,3 @@
*.hlsl
*.metal
*.spv

Some files were not shown because too many files have changed in this diff Show More