Commit Graph

14753 Commits (f2cd361e255d52be073c46b519055c70c4724fcf)

Author SHA1 Message Date
Sam Lantinga f2cd361e25 testyuv: added validation of P010 YUV format
Also added conversion between RGB and P010, using XRGB2101010 as a bridging format in PQ space
2024-03-01 20:26:52 -08:00
Sam Lantinga 47be24d225 testyuv: added --monochrome and --luminance options for interactive mode 2024-03-01 07:42:34 -08:00
Sam Lantinga 991ad27de8 testyuv: added GetColorspaceForYUVConversionMode() 2024-03-01 07:42:34 -08:00
danginsburg 812e04fb11 Vulkan Renderer - fix validation error with VkSemaphore reused before signaling. Have one semaphore per-submit rather than using the same one. 2024-03-01 06:09:22 -08:00
Ryan C. Gordon 1e8b006d43 stdlib: qsort and bsearch changes.
- Always use internal qsort and bsearch implementation.
- add "_r" reentrant versions.

The reasons for always using the internal versions is that the C runtime
versions' callbacks are not mark STDCALL, so we would have add bridge
functions for them anyhow, The C runtime qsort_r/qsort_s have different
orders of arguments on different platforms, and most importantly: qsort()
isn't a stable sort, and isn't guaranteed to give the same ordering for
two objects marked as equal by the callback...as such, Visual Studio and
glibc can give different sort results for the same data set...in this
sense, having one piece of code shared on all platforms makes sense here,
for reliabillity.

bsearch does not have a standard _r version at all, and suffers from the
same SDLCALL concern. Since the code is simple and we would have to work
around the C runtime, it's easier to just go with the built-in function
and remove all the CMake C runtime tests.

Fixes #9159.
2024-03-01 08:28:12 -05:00
Sam Lantinga af58ed978e Fixed the documentation for SDL_GetGamepadMappings() 2024-03-01 01:55:56 -08:00
SDL Wiki Bot 7ff9be7398 Sync SDL3 wiki -> header 2024-03-01 01:39:28 +00:00
Sam Lantinga 0454e1fdb4 Vulkan: added support for wrapping existing textures 2024-02-29 17:38:10 -08:00
Sam Lantinga 2adbcce864 Vulkan: wait for all queues to be idle before destroying the device 2024-02-29 14:12:09 -08:00
danginsburg 0115027116 Vulkan Renderer - fix validation errors:
* Make sure to always write pointSize in VS (fixes validation error in testsprite)
* Fix validation error from acquiring swapchain semaphore more than once
* Fix validation error from using incorrect framebuffer size in testautomation

Now passes testautomation with validation.
2024-02-29 10:59:47 -08:00
Sam Lantinga 0c6a1b636e Vulkan: added handling for SDL_MATRIX_COEFFICIENTS_UNSPECIFIED 2024-02-28 19:18:37 -08:00
Sam Lantinga 4017e1370d Vulkan: cleaned up error handling 2024-02-28 19:11:33 -08:00
Sam Lantinga 59bbfc1fdd Vulkan: only advertise YUV formats if the VK_KHR_sampler_ycbcr_conversion extension is available
Also check to see if it's available when given an external Vulkan device
2024-02-28 19:04:00 -08:00
Sam Lantinga bf853823a2 Removed unused YCbCr_matrix from Vulkan shaders 2024-02-28 18:38:06 -08:00
Sam Lantinga 039144350c Be more precise about what we're testing in testyuv 2024-02-28 17:15:47 -08:00
Sam Lantinga b30ba1c5d4 Updated RGBtoYUV() to use the full YCbCr conversion formula 2024-02-28 16:58:39 -08:00
Sam Lantinga 4513c32bb3 The ycbcrModel should be based on the transfer matrix, not the color primaries 2024-02-28 16:58:39 -08:00
Sam Lantinga a241cca9e6 Fixed warning C4090: 'function': different 'const' qualifiers 2024-02-28 11:45:24 -08:00
Sam Lantinga 7117d545a3 Fixed crash if the controller product name is NULL
This happens when the Razer Synapse software emulates a controller with a keyboard
2024-02-28 11:43:22 -08:00
Sam Lantinga 353e76b40b Use the correct colorspace for yuv conversion tests 2024-02-28 10:03:18 -08:00
Sam Lantinga fc94c3634e Fixed signed/unsigned comparison warning 2024-02-28 09:06:21 -08:00
Sam Lantinga ba34025423 Use direct3d11 as the default renderer on Windows
The D3D12 renderer initializes but has poor performance or graphical issues on older Intel hardware.

Fixes https://github.com/libsdl-org/SDL/issues/7634
Fixes https://github.com/libsdl-org/SDL/issues/9093
2024-02-28 09:00:36 -08:00
Dan Ginsburg ad036d43e9
Vulkan Renderer - implement YcBcCr using VK_KHR_sampler_ycbcr_conversion. (#9169)
* Vulkan Renderer - implement YcBcCr using VK_KHR_sampler_ycbcr_conversion.  This simplifies the shader code and will also allow support for additional formats that we don't yet support (such as SDL_PIXELFORMAT_P010 for ffmpeg). The renderer now queries for VK_KHR_sampler_ycbcr_conversion and dependent extensions and will enable it if it's present. It reimplements YUV/NV12 texture support using this extension (these formats are no longer supported if the extension is not present). For each YUV/NV12 texture, a VkSamplerYcbcrConversion object is created from SDL_Colorspace parameters.  This is passed to the VkImageView and also an additional sampler is created for Ycbcr.  Instead of using 1-3 textures, the shaders now all use 1 texture with a combined image sampler (required by the extension).  Further, when using Ycbcr, a separate descriptor set layout is baked with the Ycbcr sampler as an immutable sampler.  The code to copy the images now copies to the individual image planes.  The swizzling between formats is handled in the VkSamplerYcbcrConversion object.
2024-02-28 08:57:09 -08:00
Sam Lantinga fb3bf1dcbd Fixed device queue initialization when render and present queue families are different 2024-02-28 08:55:56 -08:00
Frank Praznik 945162c6d9 wayland: Small optimization for output removal function
In the case where an output is being removed, the SDL_DisplayData is already known, so no need to retrieve it from the wl_output user data.
2024-02-28 10:43:06 -05:00
SDL Wiki Bot 68588b232c Sync SDL3 wiki -> header 2024-02-28 15:13:26 +00:00
Sam Lantinga e142bb1b0c The extension strings are const and don't need to be duplicated 2024-02-28 07:12:15 -08:00
Sam Lantinga 0997bdd292 Fixed SDL_calloc() calls (should be count, size) 2024-02-28 07:12:15 -08:00
Sam Lantinga 614630df69 Allow using an external Vulkan device with the vulkan renderer 2024-02-28 07:12:15 -08:00
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