2265 Commits

Author SHA1 Message Date
Susko3
ce44eff3d2 Use SDL_WindowFlags in public headers 2024-03-06 15:08:12 -08:00
Susko3
4f58d18373 Typedef SDL_WindowFlags
Window flags were previously an enum with the same name.
See ebd7f9adbdc0975f6c7584738609028abb3cce6e.
2024-03-06 15:08:12 -08:00
Susko3
424616e032 Use SDL_PixelFormatEnum as type 2024-03-06 15:02:13 -08:00
Susko3
f8cb3c742d Change SDL_Keycode type to an enum 2024-03-06 12:17:53 -08:00
Susko3
f8844d387c Use specific types in SDL_touch.h
Missed when picking 7ff34249c753122a2ba67e78aa6e9f9b56aa4a65 from https://github.com/libsdl-org/SDL/pull/9191.
2024-03-06 10:35:20 -08:00
SDL Wiki Bot
2d0cd90171 Sync SDL3 wiki -> header 2024-03-06 17:52:26 +00:00
Sam Lantinga
860155680d SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events. 2024-03-06 09:51:15 -08:00
Sam Lantinga
95fbbc6f07 Fixed accidental use of tabs 2024-03-05 16:55:26 -08:00
Susko3
e268cdbec6
Use specific types in public headers (#9205)
Uses specific typedef'd types instead of generic integral types where applicable.
2024-03-05 16:52:15 -08:00
Sam Lantinga
db24560387 Additional colorspace clarification
Note that SDL_MATRIX_COEFFICIENTS_BT470BG is functionally equivalent to SDL_MATRIX_COEFFICIENTS_BT601
2024-03-05 16:47:36 -08:00
Sam Lantinga
b3858ec5f7 BT2020_CL is very different from BT2020_NCL, and not currently supported 2024-03-05 15:49:17 -08:00
Sam Lantinga
9db68f97f9 Reverted SDL_Vulkan_GetInstanceExtensions() API change
This function is commonly used with Vulkan structures that use uint32_t, so we should keep the Uint32 signature.
2024-03-05 13:39:42 -08:00
SDL Wiki Bot
0b4a195f4b Sync SDL3 wiki -> header 2024-03-05 21:32:25 +00:00
Sylvain
cea717e5d3 Removed some uneeded 'unsigned': renderer.num_texture_format and SDL_Vulkan_GetInstanceExtensions() prototype 2024-03-05 13:31:28 -08:00
SDL Wiki Bot
ffef13e1e1 Sync SDL3 wiki -> header 2024-03-04 17:30:25 +00:00
Sam Lantinga
48471f7dbd Added SDL_AddVulkanRenderSemaphores() for external synchronization with SDL rendering 2024-03-04 09:29:36 -08:00
Sam Lantinga
2c85052966 Removed unused headers from SDL_rect.h
Fixes https://github.com/libsdl-org/SDL/issues/8966
2024-03-03 11:33:59 -08:00
Susko3
86d36a2dc2 Add missing include 2024-03-03 09:37:59 -08:00
Nour Fouad
e524e545f2 Add vulkan to SDL_HINT_RENDER_DRIVER 2024-03-02 15:17:09 -08:00
SDL Wiki Bot
27389716ac Sync SDL3 wiki -> header 2024-03-02 23:05:24 +00:00
Sam Lantinga
7f9ff6277c Don't assume HDR headroom for HDR10 surfaces
Applications that support HDR will set the correct values for their content.
2024-03-02 15:02:17 -08:00
SDL Wiki Bot
8c015cd3b6 Sync SDL3 wiki -> header 2024-03-02 18:02:26 +00:00
Sam Lantinga
8d023f9869 Updated documentation for new property parameters 2024-03-02 09:56:29 -08:00
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
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
SDL Wiki Bot
68588b232c Sync SDL3 wiki -> header 2024-02-28 15:13:26 +00:00
Sam Lantinga
614630df69 Allow using an external Vulkan device with the vulkan renderer 2024-02-28 07:12:15 -08: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
Semphriss
84aaf63bd3 Fix typo in SDL_filesystem.h 2024-02-27 08:58:45 -08:00
SDL Wiki Bot
fbe7301aba Sync SDL3 wiki -> header 2024-02-25 23:55:23 +00: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
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
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
SDL Wiki Bot
2132ba8985 Sync SDL3 wiki -> header 2024-02-22 03:26:22 +00:00
Sam Lantinga
54c2ba6afd Added the Chrome HDR tonemap operator
Also added support for the SDL_PIXELFORMAT_XBGR2101010 pixel format to the D3D12, D3D11, and Metal renderers.
2024-02-21 19:25:49 -08:00
Sam Lantinga
4ba6aeee9d A second take on HDR support with an SDR white point and HDR headroom
This better reflects how HDR content is actually used, e.g. most content is in the SDR range, with specular highlights and bright details beyond the SDR range, in the HDR headroom.

This more closely matches how HDR is handled on Apple platforms, as EDR.

This also greatly simplifies application code which no longer has to think about color scaling. SDR content is rendered at the appropriate brightness automatically, and HDR content is scaled to the correct range for the display HDR headroom.
2024-02-21 19:25:49 -08:00
SDL Wiki Bot
31fe061ab5 Sync SDL3 wiki -> header 2024-02-20 20:57:27 +00:00
Ryan C. Gordon
70b89ab70d camera: Added SDL_GetCameraDevicePosition.
Otherwise, as a property, you have to open each camera device to figure out
which ones are which.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon
2613e3da24 camera: Rewrote Android support.
This does something a little weird, in that it doesn't care what
`__ANDROID_API__` is set to, but will attempt to dlopen the system
libraries, like we do for many other platform-specific pieces of SDL.

This allows us to a) not bump the minimum required Android version, which is
extremely ancient but otherwise still working, doing the right thing on old
and new hardware in the field, and b) not require the app to link against
more libraries than it previously did before the feature was available.

The downside is that it's a little messy, but it's okay for now, I think.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon
8db2a3b27a camera: Add an optional property that reports if a camera is back or front.
This is useful for iOS and Android, so an app can find the camera it cares
about in the list of devices.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon
99d1337de2 camera: Reenabled macOS/iOS support, with rewritten CoreMedia implementation. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon
22dbc0f32f camera: Patched to compile after rebasing to latest in main. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon
7191a97fe3 camera: Windows support, through the Media Foundation API! 2024-02-20 15:56:26 -05:00
Ryan C. Gordon
67708f9110 camera: Emscripten support!
This also adds code to deal with waiting for the user to approve camera
access, reworks testcameraminimal to use main callbacks, etc.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon
182f707284 include: Fixed doxygen comments on new camera APIs. 2024-02-20 15:56:26 -05:00