Commit Graph

278 Commits

Author SHA1 Message Date
Ethan Lee
0b2073d143 gpu: Remove dead code in the Vulkan device ranking system.
This block was a sloppy way of trying to avoid prioritizing lavapipe over another device, but truthfully the only way to guarantee avoiding CPU drivers is to add a property to allow apps to require hardware acceleration.
2025-11-10 18:16:54 -05:00
Ethan Lee
1b79ba9ab6 gpu: Separate device suitability from device rank when enumerating Vulkan devices.
This makes it a bit clearer what the "minimum" is vs. the "best", which should be two separate queries.
2025-11-10 18:16:54 -05:00
Ethan Lee
6976b57988 gpu: Move device ranking to the bottom of IsDeviceSuitable.
This prevents devices without presentation/graphics support from getting ranked.
2025-11-10 18:16:54 -05:00
Ethan Lee
799c6aa629 gpu: Move device ranking to a standalone function.
This allows us to treat Dozen as an "other" driver, rather than blacklisting it outright.
2025-11-10 18:16:54 -05:00
Ethan Lee
0cc2b026e7 gpu: Check for MSFT_layered_driver, skip layered drivers during enumeration 2025-11-10 18:16:54 -05:00
Chris Genova
6a01d6e7d3 D3D12 GPU: Prevent reading out of bounds when uploading textures.
When the upload needs realignment, a new buffer is created to do the
upload, and the source data is copied to the new buffer. This commit
fixes the issue where the memcopy can read off the end of the source
buffer since it is reading based on destination pitch instead of source
pitch.
2025-11-07 17:47:51 -08:00
Sam Lantinga
4db63e323e Save a copy of the D3D12 semantic string
Fixes https://github.com/libsdl-org/SDL/issues/14383
2025-11-02 16:16:20 -08:00
Katelyn Gadd
9479ac039c If VULKAN_Submit fails during VULKAN_INTERNAL_CreateTexture, destroy the texture and return NULL 2025-10-20 16:24:20 -07:00
Eddy Jansson
aaee09d6ed Don't do NULL-checks before SDL_free()
Replaces the pattern

  if (ptr) {
    SDL_free(ptr);
  }

with

  SDL_free(ptr);
2025-10-20 00:13:09 -07:00
TheSniperFan
cbcb145eb4 Fix debug mode being set too late
-Early error messages were always being skipped
2025-10-18 08:04:11 -07:00
Ethan Lee
2135ecdfcc gpu: Vulkan on private platforms cannot make use of oldSwapchain, destroy the full swapchain on resize 2025-10-16 15:18:07 -04:00
Evan Hemsley
20206b8e66 GPU: Correctly recycle D3D12 descriptor heaps (#14234) 2025-10-13 13:00:00 -07:00
cosmonaut
b067dfa345 GPU: Validate that buffer size is at least 4 bytes 2025-10-13 11:04:59 -07:00
Edu Garcia
c74b406a4c Fix SDL GPU D3D12 Descriptor Heap leak
When descriptor leaks overflow, the D3D12 SDL GPU renderer fetches more from the pool, but never returns them, which eventually causes an "out of memory" crash.
2025-10-09 08:45:18 -07:00
Sam Lantinga
2a92a3c9c5 Recreate the Vulkan GPU swap chain when resuming on Android
Fixes https://github.com/libsdl-org/SDL/issues/12957
2025-10-08 21:06:17 -07:00
Sam Lantinga
00ffddece8 Ignore VK_SUBOPTIMAL_KHR on the Android platform
This is returned whenever the device has been rotated, and can be safely ignored.

Fixes https://github.com/libsdl-org/SDL/issues/12950
2025-10-08 20:02:31 -07:00
Sam Lantinga
a2a60f75c7 Temporarily disabled texture binding validation
There are some advanced use cases that trip over this, so temporarily disabling the validation pending further review.

Reference: https://github.com/libsdl-org/SDL/issues/13871
2025-10-08 19:50:48 -07:00
HTuanPhong
2638537f92 Fix vulkan gpu resize lag on windows 2025-10-04 15:22:28 -07:00
Mathieu Eyraud
86da08b0be Zero-initialize SDL_GPUDevice 2025-10-01 07:22:17 -07:00
Sam Lantinga
8a5f9a3837 Removed validate_feature_indirect_draw_first_instance_disabled (thanks @rabbit-ecl!)
It was incorrectly checking the direct draw functions instead of checking indirect draw buffers.
2025-09-30 11:36:29 -07:00
Sam Lantinga
15f1cb4c98 Added GPU API support on visionOS
You must set SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN to false on this platform, since setDepthClipMode is not supported on Apple headsets (as of visionOS 2.3) and clipping is the default.
2025-09-29 13:28:00 -07:00
Sam Lantinga
2809ce9389 Set enable_depth_clip to true by default if SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN is false 2025-09-29 13:28:00 -07:00
Sam Lantinga
f61e271e11 Generalize and validate optional GPU feature properties
Fixes https://github.com/libsdl-org/SDL/issues/13139
Fixes https://github.com/libsdl-org/SDL/issues/13138
2025-09-29 12:42:47 -07:00
Sam Lantinga
595f7b7ed9 Revert "Fixed Vulkan validation error"
This reverts commit b82b1f416f.

The renderer should not be enabling depth clamping.
2025-09-29 06:08:27 -07:00
Sam Lantinga
b82b1f416f Fixed Vulkan validation error
VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782(ERROR / SPEC): msgNum: -316906200 - Validation Error: [ VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782 ] | MessageID = 0xed1c6528 | vkCreateGraphicsPipelines(): pCreateInfos[0].pRasterizationState->depthClampEnable is VK_TRUE, but the depthClamp feature was not enabled. The Vulkan spec states: If the depthClamp feature is not enabled, depthClampEnable must be VK_FALSE (https://vulkan.lunarg.com/doc/view/1.3.268.0/windows/1.3-extensions/vkspec.html#VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782)
2025-09-28 22:10:06 -07:00
Victor Ilyushchenko
a34d31322c Fix Metal 3D texture upload stride calculation
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
2025-09-28 07:32:17 -07:00
Sam Lantinga
25b2d2c821 Use new parameter validation macro 2025-09-18 20:58:32 -07:00
ManifoldFR
8bc4e029bd gpu/vulkan : fix clear value indexing 2025-09-16 08:45:35 -07:00
cosmonaut
9603360b7e GPU: Allow rendering into depth texture layers and levels 2025-09-13 07:11:43 -07:00
Evan Hemsley
fe314a1b8a GPU: Bump MAX_COLOR_TARGET_BINDINGS to 8 (#13937) 2025-09-12 13:04:18 -07:00
Sam Lantinga
035eed351c Added SDL_GetPixelFormatFromGPUTextureFormat() and SDL_GetGPUTextureFormatFromPixelFormat()
Fixes https://github.com/libsdl-org/SDL/issues/13899
2025-09-10 12:08:04 -07:00
nightmareci
2f5bc17ea6 Fix support for Windows XP and up (#13904) 2025-09-08 13:00:26 -07:00
Ethan Lee
cbe4970946 gpu: Add D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN property 2025-09-08 11:19:20 -07:00
Luis Caceres
03d0c2ad74 gpu/vulkan: Move dereference after null check 2025-09-08 12:19:53 -04:00
Ethan Lee
689049f8ec gpu: VK_KHR_get_physical_device_properties2 can be optional 2025-09-02 09:53:01 -07:00
Jordan Saunders
265236d952 Fix two uninitialized variables
Found when running in valgrind looking at another issue.

- RenderPass' depth_stencil_target
    Tripped in SDL_BindGPUFragmentSamplers when not binding a DS target

- VulkanCommandBuffer's swapchainRequested
    Tripped in VULKAN_Submit for the end transition barrier when
    creating an image. The field is only reset when reused, not on first
    use
2025-08-30 06:05:22 -07:00
Jaan Soulier
0bbdd86b86 Fix device suitability checks in Vulkan GPU backend to always adhere to priority arrays 2025-08-27 05:15:24 -07:00
Ethan Lee
0fcaf47658 gpu: D3D12 only requires feature level 11_0 with Resource Binding Tier 2.
We previously thought this wasn't possible because constant buffer offsets and
partial updates were unavailable, but we were reading the wrong table - this is
only the case for D3D11...

https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro

... while 12 doesn't list this feature at all:

https://learn.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels

We double checked and Jesse Natalie confirmed that this feature is required for
D3D12 even for 11_0 drivers. (Thanks Jesse!)

Additionally, D3D12 requires that UAVs are accessible from all shader stages,
meaning Tier 2 is enough to support the number of UAVs we need. Tier 1 could be
a property to lower the requirements, but that can be done later.
2025-08-22 15:46:05 -04:00
Wilson Jallet
03b14f5211 GPU: Fix Vulkan indexing error for resolve attachment refs (#13768) 2025-08-19 12:10:55 -07:00
suleyth
bad7075de8 Only add VRAM to deviceRank if asking for a high performance device, and if the device already meets all the requirements. 2025-08-17 23:17:37 -04:00
suleyth
618f85fafe Make deviceRank an Uint64 to avoid potential overflow issues in case of future GPUs with huge VRAM 2025-08-17 23:17:37 -04:00
suleyth
c5b79e5f1b Pick dedicated GPU with highest VRAM 2025-08-17 23:17:37 -04:00
Beyley Cardellio
e699f3dca1 GPU: Hold submit lock before waiting for device idle 2025-08-10 07:21:55 -07:00
cosmonaut
fe6b2161bf GPU: Fix uninitialized value in Vulkan command buffer structure 2025-08-07 13:42:03 -07:00
Frank Praznik
42463569d5 GPU: Vulkan backend flags command buffer for cleanup when swapchain is requested
When skipping presentation due to the window being hidden, presentDataCount is not incremented on the command buffer, and subsequently the submitted command buffers will not be cleaned up as long as the window is hidden. This results in a lag spike when showing the window due to all previously submitted command buffers suddenly being cleaned up at once, and lag at shutdown due to an equivalent number of fences needing to be destroyed.

Instead of relying on presentDataCount to determine whether a command buffer should be cleaned up, use a flag, which is set under the appropriate circumstances.
2025-08-02 09:24:02 -07:00
cosmonaut
c5edf4bd5b GPU: Bail out of aquiring Vulkan swapchain if window is hidden 2025-07-31 16:02:58 -07:00
Cheney Wang
d8ac51859e GPU: Fix wrong Vulkan swapchain size when retrying acquire 2025-07-30 15:34:56 -07:00
Evan Hemsley
07af4b237b GPU: Fix incorrect block size when D3D12 uniform buffer is rotated (#13469) 2025-07-29 15:34:08 -07:00
Petar Popovic
f27dbb22f0 Fix two use-after-free warnings 2025-07-29 12:29:19 -07:00
Petar Popovic
6a5af95364 SDL_gpu.c: Fixed deref-before-check warning 2025-07-26 12:08:23 -07:00