Commit Graph

14774 Commits (c1da39a245768a3867cd4377e855980e1f1bc42a)

Author SHA1 Message Date
Anonymous Maarten e03746b25f cmake: add -Wl,-rpath,${libdir} to Libs section of pc file for Apple platforms 2024-02-28 12:58:02 +01:00
Anonymous Maarten c8372e20d6 SDLTest_CommonEvent: only set done when it is finished 2024-02-28 12:57:30 +01:00
Sam Lantinga 220340e944 Remove SDL_PIXELFORMAT_P010
It's not supported by any renderer or pixel conversion path
2024-02-27 12:48:33 -08:00
Frank Praznik c259a20f96 wayland: Remove all references to destroyed outputs from windows
The removal of a wl_output may not be accompanied by leave events for the surfaces present on it. Ensure that no window continues to hold a reference to a removed output.
2024-02-27 12:18:01 -05:00
Semphriss 84aaf63bd3 Fix typo in SDL_filesystem.h 2024-02-27 08:58:45 -08:00
Anonymous Maarten 0a961915dc cmake: testffmpeg requires link to EGL library for EGL feature 2024-02-27 12:28:06 +01:00
Sam Lantinga 24e021c67e testffmpeg: refactored texture creation properties into a single function 2024-02-26 16:01:23 -08:00
Sam Lantinga ff18d7cfa0 testffmpeg: added pixel format mapping for NV12 and NV21 2024-02-26 15:52:21 -08:00
Sam Lantinga 81608ad077 Vulkan: fixed creating SDL_PIXELFORMAT_P010 textures 2024-02-26 15:51:13 -08:00
Sam Lantinga f99143f437 Don't quit testffmpeg when alt-tabbing away 2024-02-26 15:21:26 -08:00
Sam Lantinga 80d2ef7384 Fixed uploading Vulkan texture with w*bpp != pitch 2024-02-26 15:18:23 -08:00
Sam Lantinga 3a796c9722 Allow specifying the render driver in the environment for testffmpeg 2024-02-26 15:13:10 -08:00
Sam Lantinga dc9a3c83e2 Use the mastering display metadata to do proper tone mapping for HDR content 2024-02-26 14:20:34 -08:00
Sam Lantinga 98b1a59a95 Document the HDR tone mapping algorithm 2024-02-26 14:20:34 -08:00
Anonymous Maarten 1f536a1e77 cmake: fix SDL_RENDER_VULKAN reporting
Also fix an error when configuring with `-DSDL_VULKAN=ON
-DSDL_RENDER_VULKAN=FALSE`: the vulkan renderer is now correctly
disabled.
2024-02-26 20:37:10 +01:00
danginsburg 935c197059 Fix testautomation failures (including clip rect) - closes #9145. During merging for prep'ing the final PR for the Vulkan Renderer, I misordered a memcpy that regressed several of the testautomation test. From now on, I will make sure to run testautomation on any future PRs before submitting. 2024-02-26 10:04:10 -08:00
Ryan C. Gordon e61dfe405f
android: Fixed dead URL in comment. 2024-02-26 11:28:32 -05:00
danginsburg 35026cdcba Vulkan Renderer - robustly handle running out of descriptor sets or constant buffer memory. Closes #9131. My previous implementation of descriptor set handling was naive - it attempted to do VULKAN_IssueBatch when running out of descriptor sets or constant buffer space. For one thing, this had a bug and wasn't working (causing the crash), but moreover it would have resulted in having to flush the GPU. Instead, make the descriptor pools and constant buffer mapped buffers be resizeable so that if we need more it will grow to the size that is needed.
# Conflicts:
#	src/render/vulkan/SDL_render_vulkan.c
2024-02-26 08:12:24 -08:00
David Gow f976881651 Vulkan: Don't invalidate internal state in InvalidateCachedState
The VULKAN_InvalidateCachedState() function seems to be meant to
invalidate any _cached_ state, i.e. global state of the API which may
have been modified outside the renderer.

However, at the moment, the Vulkan renderer also resets a number of
internal variables which track buffers, offsets, etc, in use. As a
result, the renderer can get into an inconsistant state and/or lose
data.

For example, if VULKAN_InvalidateCachedState() is called in between two
calls to VULKAN_UpdateVertexBuffer(), the data from the first call will
be overwritten by that from the second, as the number of the next vertex
buffer to use will be reset to 0. This can result in rendering errors,
as the same vertex data is used incorrectly for several calls.

By no longer resetting this 'internal' state here, those glitches
disappear. However, I haven't tested this with any applications which
mix the Vulkan renderer with their own Vulkan code (do any such
applications exist?), so this may be insufficient in case a full flush
of the renderer state  -- and possibly a wait on the appropriate fence
-- could be required.

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-26 07:54:23 -08:00
David Gow c172fb5972 Vulkan: Support 'desired' vs 'required' memory flags (Fix #9310)
When selecting a memory type, there are some property flags we need
(e.g., VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, without which we cannot
vkMapMemory), and others we'd simply prefer (e.g.,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, which may have a performance
impact, but otherwise shouldn't be required).

By specifying these separately, we can fall back to a memory type which
doesn't have everything we want, but which should still work, rather
than giving up.

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-26 07:52:12 -08:00
David Gow 1558d52a0a Vulkan: Only return memory types which are a superset of what we need
VULKAN_FindMemoryTypeIndex() tries first to get a perfectly matching
memory type, then falls back to selecting any memory type which overlaps
with the requested flags.

However, some of the flags requested are actually required, so if -- for
example -- we request a memory type with
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, but get one without it, all future
calls to vkMapMemory() will fail with:

```
vkMapMemory():  Mapping memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set. Memory has type 0 which has properties VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT. The Vulkan spec states:
memory must have been created with a memory type that reports VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT.
```

(This occurs, for instance, on the totally non-conformant hasvk driver
for Intel Haswell integrated GPUs, which otherwise works fine.)

Instead, make sure that any memory type found has a superset of the
requested flags, so it'll always be appropriate.

Of course, this makes it _less_ likely for a memory type to be found, so
it does make #9130 worse in some ways. See the next patch for details.

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-26 07:52:12 -08:00
SDL Wiki Bot fbe7301aba Sync SDL3 wiki -> header 2024-02-25 23:55:23 +00:00
Sam Lantinga e223e1d498 Added SDL_camera.h to the public Framework headers 2024-02-25 15:54:34 -08:00
Sam Lantinga be51b7acea Use the maximum potential headroom if EDR content isn't currently being displayed.
Also document that the HDR properties can change dynamically at runtime.
2024-02-25 15:54:34 -08:00
SDL Wiki Bot e0dadba6f5 Sync SDL3 wiki -> header 2024-02-25 22:26:23 +00:00
Anonymous Maarten e6d9251ecb docs: improve CMake documentation for Apple 2024-02-25 23:25:11 +01:00
Sam Lantinga 7a9c6c7ce9 Include SDL_PIXELFORMAT_P010 as a supported format for the metal renderer 2024-02-25 13:55:52 -08:00
Sam Lantinga d211da75ac Fixed crash if app delegate method is called when SDL isn't initialized 2024-02-25 13:38:47 -08:00
Sam Lantinga 9dbbf0a2f7 Implemented clip rect functionality for the Vulkan renderer 2024-02-25 10:13:59 -08:00
Sam Lantinga 141497b14f Added an automated test to verify clip rect functionality 2024-02-25 09:44:41 -08:00
Sam Lantinga d0af01e7d4 If the viewport changes the cliprect should be updated
The clip rectangle is defined to be viewport relative, so if the viewport changes we need to update it.

Fixes https://github.com/libsdl-org/SDL/issues/9094
2024-02-25 09:37:56 -08:00
Sam Lantinga 1cae52bbac Added JNI native methods to proguard-rules.pro (thanks @AntTheAlchemist!)
Fixes https://github.com/libsdl-org/SDL/issues/3563
2024-02-25 08:40:47 -08:00
David Gow b8a52c1237 Vulkan: Make sure validation layer name is in-scope
When enabling the Vulkan validation layers, the 'validationLayerName'
variable technically went out of scope before vkCreateInstance() was
called. While most compilers won't clean up stack variables after random
'if' statements, some will, particularly when optimisation or memory
sanitizers are enabled.

This can lead to vkCreateInstance() segfaulting when
SDL_HINT_RENDER_VULKAN_DEBUG is enabled.

Instead, make the validationLayerName visible throughout the entire
VULKAN_CreateDeviceResources() function.

While we're at it, extract the validation layer name out into a
preprocessor #define, so that we are definitely using the same name in
VULKAN_ValidationLayersFound().

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-25 08:24:43 -08:00
Sam Lantinga 276566235c Removed SDL_ClearHints() from the public API
Fixes https://github.com/libsdl-org/SDL/issues/9129
2024-02-24 21:07:50 -08:00
Sam Lantinga a1ea706215 Added names for the newly supported pixel formats 2024-02-24 20:13:59 -08:00
Sam Lantinga f6c42406cd SDL_COLORSPACE_HDR10 is the default colorspace for SDL_PIXELFORMAT_P010 surfaces 2024-02-24 20:04:36 -08:00
Sam Lantinga 4c5584174b Fixed error: declaration shadows a local variable [-Werror,-Wshadow] 2024-02-24 20:04:36 -08:00
Sam Lantinga 2b0e7c40ef Verify that we can create pipeline state objects for the D3D12 renderer
Fixes https://github.com/libsdl-org/SDL/issues/9093
2024-02-24 19:55:10 -08:00
Anonymous Maarten 5593ddb6a7 cmake: X11 is for Video, not Audio 2024-02-24 17:31:48 +01:00
scribam 38d24778ed ci: update deprecated node.js 16 actions 2024-02-23 21:53:40 +01:00
scribam cbe330befd ci: bump cross-platform-actions/action version to v0.23.0 2024-02-23 23:20:14 +03:00
danginsburg 97372b56e8 Vulkan Renderer - handle dynamic resetting of vsync, requires swapchain recreation. 2024-02-23 08:42:04 -08:00
danginsburg b1431e6702 Vulkan Renderer - implement support for vsync disabled. Closes #9116. 2024-02-23 08:42:04 -08:00
Sam Lantinga b9a00aa88e Fixed building the Vulkan renderer on Windows with Visual Studio 2024-02-22 17:18:46 -08:00
SDL Wiki Bot dfd8073a8f Sync SDL3 wiki -> header 2024-02-22 22:59:24 +00:00
Dan Ginsburg cab20117e6
Vulkan Renderer (#9114)
This pull request adds an implementation of a Vulkan Render backend to SDL.  I have so far tested this primarily on Windows, but also smoke tested on Linux and macOS (MoltenVK).  I have not tried it yet on Android, but it should be usable there as well (sans any bugs I missed).  This began as a port of the SDL Direct3D12 Renderer, which is the closest thing to Vulkan as existed in the SDL codebase. The shaders are more or less identical (with the only differences being in descriptor bindings vs root descriptors).  The shaders are built using the HLSL frontend of glslang.

Everything in the code is pure Vulkan 1.0 (no extensions), with the exception of HDR support which requires the Vulkan instance extension `VK_EXT_swapchain_colorspace`.  The code could have been simplified considerably if I used dynamic rendering, push descriptors, extended dynamic state, and other modern Vulkan-isms, but I felt it was more important to make the code as vanilla Vulkan as possible so that it would run on any Vulkan implementation.

The main differences with the Direct3D12 renderer are:
* Having to manage renderpasses for performing clears.  There is likely some optimization that would still remain for more efficient use of TBDR hardware where there might be some unnecessary load/stores, but it does attempt to do clears using renderpasses.
* Constant buffer data couldn't be directly updated in the command buffer since I didn't want to rely on push descriptors, so there is a persistently mapped buffer with increasing offset per swapchain image where CB data gets written.
* Many more resources are dependent on the swapchain resizing due to i.e. Vulkan requiring the VkFramebuffer to reference the VkImageView of the swapchain, so there is a bit more code around handling that than was necessary in D3D12.
* For NV12/NV21 textures, rather than there being plane data in the texture itself, the UV data is placed in a separate `VkImage`/`VkImageView`.

I've verified that `testcolorspace` works with both sRGB and HDR linear.  I've tested `testoverlay` works with the various YUV/NV12/NV21 formats.  I've tested `testsprite`.  I've checked that window resizing and swapchain out-of-date handling when minimizing are working.  I've run through `testautomation` with the render tests.  I also have run several of the tests with Vulkan validation and synchronization validation.  Surely I will have missed some things, but I think it's in a good state to be merged and build out from here.
2024-02-22 14:58:11 -08:00
Sam Lantinga 2f1f55aeb1 Updated default SDR white point and HDR headroom to better match game content 2024-02-22 14:51:23 -08:00
Sam Lantinga 1fb5b9672e Keep SDR white point and HDR headroom defaults in one place 2024-02-22 14:47:58 -08:00
Sam Lantinga aeae202207 Make sure we actually have an HDR10 texture in the HDR10 shader
Some content uses the PQ transfer function but different color primaries
2024-02-22 11:50:58 -08:00
Sam Lantinga f4dd0dbbde Added colorspace conversion from SDL_COLOR_PRIMARIES_SMPTE431 and SDL_COLOR_PRIMARIES_SMPTE432 to SDL_COLOR_PRIMARIES_BT2020 2024-02-22 11:01:03 -08:00