Commit Graph

104 Commits (2adbcce864cc3ee1d697f0edae2f4d6aafcbb422)

Author SHA1 Message Date
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
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
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 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
Sam Lantinga 2f7c24e4be Removed SDL_HINT_RENDER_SCALE_QUALITY
Textures now default to linear filtering, use SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST) if you want nearest pixel mode instead.
2024-02-12 09:54:33 -08:00
Zack Middleton 5af7113842 Rename property define names to have a type suffix
Renamed the following property define names to have a type suffix to
match other property names.

SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET (number)
SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET (number)
SDL_PROP_WINDOW_CREATE_WAYLAND_SCALE_TO_DISPLAY (boolean)
SDL_PROP_WINDOW_RENDERER (pointer)
SDL_PROP_WINDOW_TEXTUREDATA (pointer)
2024-02-12 09:54:11 -08:00
SDL Wiki Bot 1ec0e22bcd Sync SDL3 wiki -> header 2024-02-10 00:38:20 +00:00
Sam Lantinga 1162097135 Added SDL_RenderViewportSet() to tell whether the viewport was previously set to a specific rectangle.
Fixes https://github.com/libsdl-org/SDL/issues/9029
2024-02-09 16:37:04 -08:00
Sam Lantinga 3158342441 Use SDL_Color for SDL_RenderGeometryRaw() and add SDL_RenderGeometryRawFloat()
Eventually we can re-add a fast path for that data down to the individual renderers. Setting color scale would still require converting to float, and most hardware accelerated renderers prefer to consume colors as float, so this requires some thought and performance testing.

Fixes https://github.com/libsdl-org/SDL/issues/9009
2024-02-06 18:16:41 -08:00
SDL Wiki Bot ed86cec07f Sync SDL3 wiki -> header 2024-02-06 23:41:23 +00:00
Sam Lantinga 2039c46d2c Added support for creating an SDL texture from a CVPixelBufferRef 2024-02-06 15:40:47 -08:00
SDL Wiki Bot 451dc41427 Sync SDL3 wiki -> header 2024-02-06 10:49:24 +00:00
Sam Lantinga 30e176d6ba Added HDR display properties and related event
Also added an HDR calibration stage to testcolorspace
2024-02-06 02:48:05 -08:00
Sam Lantinga d4caef5b89 Generalize SDR white level handling into a color scale
This gives applications better control over how and when light levels are adjusted when working with HDR content and display.
2024-02-06 02:48:05 -08:00
SDL Wiki Bot a6374123c7 Sync SDL3 wiki -> header 2024-02-04 21:10:23 +00:00
Sam Lantinga 327b976bc4 SDL_COLORSPACE_JPEG is the default YUV colorspace 2024-02-04 13:09:40 -08:00
Sam Lantinga 89b9d6cbdc SDL_RenderReadPixels() now returns a surface
Fixes https://github.com/libsdl-org/SDL/issues/8977
2024-02-03 11:49:15 -08:00
SDL Wiki Bot ab571633d1 Sync SDL3 wiki -> header 2024-02-03 15:37:23 +00:00
Sam Lantinga 50a805cdd1 Use YUV colorspaces instead of a global YUV conversion mode
Fixes https://github.com/libsdl-org/SDL/issues/8669
2024-02-03 07:36:18 -08:00
SDL Wiki Bot 2819988f8b Sync SDL3 wiki -> header 2024-02-03 04:40:24 +00:00
Sam Lantinga a2c45f61bb Updated scRGB render colorspace documentation 2024-02-02 20:38:48 -08:00
SDL Wiki Bot c007c7ed55 Sync SDL3 wiki -> header 2024-02-02 21:14:23 +00:00
Sam Lantinga 9591b2cfb4 Finalized the SDL render API colorspaces
The renderer will always use the sRGB colorspace for drawing, and will default to the sRGB output colorspace. If you want blending in linear space and HDR support, you can select the scRGB output colorspace, which is supported by the direct3d11 and direct3d12
2024-02-02 13:13:53 -08:00
SDL Wiki Bot dcfb069c75 Sync SDL3 wiki -> header 2024-02-01 20:18:29 +00:00
Sam Lantinga dd28ab0489 Added SDL_SetRenderDrawColorspace() and SDL_GetRenderDrawColorspace() 2024-02-01 12:17:35 -08:00
SDL Wiki Bot d15fb9e063 Sync SDL3 wiki -> header 2024-01-30 17:49:26 +00:00
Sam Lantinga f257eb4481 Added the concept of colorspace to the SDL renderer
This allows color operations to happen in linear space between sRGB input and sRGB output. This is currently supported on the direct3d11, direct3d12 and opengl renderers.

This is a good resource on blending in linear space vs sRGB space:
https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/

Also added testcolorspace to verify colorspace changes
2024-01-30 09:48:02 -08:00
Sam Lantinga 554f0625d3 Renderer colors now have floating point precision 2024-01-30 09:48:02 -08:00
SDL Wiki Bot aba3038353 Sync SDL3 wiki -> header 2024-01-27 21:01:19 +00:00
Sam Lantinga 3b55c7d1f4 Shortened SDL property names 2024-01-27 13:00:50 -08:00
SDL Wiki Bot 1885e6b2e0 Sync SDL3 wiki -> header 2024-01-27 20:47:21 +00:00
Sam Lantinga 8a4284b7df Clarified the use of SDL_RENDERER_SOFTWARE when creating a renderer
Fixes https://github.com/libsdl-org/sdlwiki/issues/458
2024-01-27 12:46:41 -08:00
SDL Wiki Bot 4d6e2d8b73 Sync SDL3 wiki -> header 2024-01-20 14:33:19 +00:00
Sam Lantinga 308906ba25 Added SDL_FlipSurface() to flip a surface vertically or horizontally
Fixes https://github.com/libsdl-org/SDL/issues/8857
2024-01-20 06:31:37 -08:00
Ryan C. Gordon 82f2c4d581
render: Renamed SDL_GetTextureRenderer to SDL_GetRendererFromTexture. 2024-01-08 14:16:16 -05:00
SDL Wiki Bot 95066ce2a0 Sync SDL3 wiki -> header 2024-01-08 19:10:31 +00:00
Ryan C. Gordon df438a3170
opengl: OpenGL renderers need to support texture target in properties.
Otherwise this has to become an awkward heuristic in sdl2-compat.
2024-01-08 14:08:35 -05:00
SDL Wiki Bot 4942027117 Sync SDL3 wiki -> header 2024-01-08 17:34:23 +00:00
Ryan C. Gordon e056f52f7d
include: Remove string literals from properties documentation.
I'm going to let the wiki bridge clean up the word wrapping for me, here. :)
2024-01-08 12:33:29 -05:00
SDL Wiki Bot e8c595af5c Sync SDL3 wiki -> header 2024-01-08 17:16:19 +00:00
Ryan C. Gordon adef35b9ec
include: Attempt to make new properties documentation wiki bridge friendly. 2024-01-08 12:14:08 -05:00
SDL Wiki Bot 4ffec098b7 Sync SDL3 wiki -> header 2024-01-08 15:18:26 +00:00
Ryan C. Gordon 9bc7cfc755
render: Added SDL_GetTextureRenderer(). 2024-01-08 10:17:38 -05:00
Sam Lantinga 7eae08cfc4 Removed SDL_GL_BindTexture() and SDL_GL_UnbindTexture()
Now that we have the OpenGL texture properties, you can directly bind them yourself.

Fixes https://github.com/libsdl-org/SDL/issues/2124
2024-01-07 20:19:19 -08:00
SDL Wiki Bot 4d5bffc323 Sync SDL3 wiki -> header 2024-01-08 01:02:25 +00:00
Sam Lantinga 1a13dae219 Added constant definitions for SDL properties
Fixes https://github.com/libsdl-org/SDL/issues/8622
2024-01-07 16:59:41 -08:00