Commit graph

63 commits

Author SHA1 Message Date
Anonymous Maarten
46d9066a69 Fix warnings shown when making SDL_bool a typedef of bool 2024-08-22 16:03:39 +00:00
Sam Lantinga
930d83aed2 Fixed warning: implicit conversion loses integer precision: 'VkDeviceSize' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') 2024-07-29 12:01:53 -07:00
Sam Lantinga
95dd8781ce Do a full cleanup if renderer creation fails during autodetection 2024-07-27 16:46:09 -07:00
Sam Lantinga
03bb2c17ed Enable texture wrapping for SDL_RenderGeometry()
Currently wrapping is based on whether texture coordinates are outside of [0,1], but the code is structured so it's easy to add an API to set it and add additional wrapping modes if we want.

Fixes https://github.com/libsdl-org/SDL/issues/9238
Closes https://github.com/libsdl-org/SDL/pull/5369
2024-07-20 09:51:05 -07:00
Amir
5db08b86ca Fix warning for Android NDK compiler: "function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]"
https://stackoverflow.com/questions/42125/warning-error-function-declaration-isnt-a-prototype
In C int foo() and int foo(void) are different functions. int foo() accepts an arbitrary number of arguments, while int foo(void) accepts 0 arguments. In C++ they mean the same thing.
2024-07-17 14:09:11 -07:00
Sam Lantinga
9ca1792848 Renamed driverdata to internal
This was done to SDL_DisplayMode for consistency with SDL_Surface and gives it a type so we don't have to do casts in SDL code.

I considered switching to an ID and hashing the driver data, etc. but all of that involved a lot of internal code churn and this solution gives us flexibility in how we handle this in the future.

After consideration, I made this renaming global across the project, for consistency.

Fixes https://github.com/libsdl-org/SDL/issues/10198
2024-07-16 17:17:13 -07:00
Sam Lantinga
1e6119e335 VULKAN_RenderPresent() should return result code 0 on success 2024-07-13 09:27:06 -07:00
Sam Lantinga
c6b9b08e9f Fixed Android build warnings 2024-07-13 09:00:41 -07:00
captain0xff
2dcb9440f1 android: fix the vulkan renderer 2024-07-13 08:16:26 -07:00
Sam Lantinga
5bf6bc4d7d Renamed SDL_Get/SetProperty() to SDL_Get/SetPointerProperty()
This is consistent with the naming for the functions that affect other data types

Fixes https://github.com/libsdl-org/SDL/issues/10241
2024-07-12 10:41:02 -07:00
Sam Lantinga
2ba76dbe80 Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure.

The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect().

SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types.

SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value.

SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
2024-07-10 00:48:18 -07:00
Frank Praznik
44ec57626f vulkan: Don't set the opaque bit on transparent windows
If window transparency was requested via the SDL_WINDOW_TRANSPARENT flag, don't set the opaque bit on the swapchain composite alpha value. Fixes transparent windows when using the Vulkan renderer (e.g. testsprite --transparent).
2024-06-28 14:47:32 -04:00
Ryan C. Gordon
982feb7a65 vulkan: SDL_Vulkan_CreateSurface now returns the usual int (0=ok, -1=error).
Fixes #10091.
2024-06-27 15:25:10 -04:00
Sam Lantinga
ea8df46575 We don't support directly rendering to PQ swap chains
Normally this would be done by creating a PQ swap chain and a linear SRGB render target and doing blending operations in linear space and then final conversion to PQ HDR, but we're going to short-circuit all of that and just support linear SRGB output directly.
2024-06-17 17:29:33 -07:00
Sam Lantinga
a0d1445ccb Replaced SDL_GetRendererInfo() with SDL_GetRendererName()
The texture formats are available via the SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER property

Fixes https://github.com/libsdl-org/SDL/issues/9851
2024-06-03 21:10:58 -07:00
Sam Lantinga
5f1e01cce0 Added support for late swap tearing to the Vulkan renderer 2024-05-13 15:06:11 -07:00
Sam Lantinga
17520c2e6e Removed SDL_RendererFlags
The flags parameter has been removed from SDL_CreateRenderer() and SDL_RENDERER_PRESENTVSYNC has been replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during window creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation.

SDL_SetRenderVSync() now takes additional values besides 0 and 1.

The maximum texture size has been removed from SDL_RendererInfo, replaced with SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER.
2024-05-13 15:06:11 -07:00
Sam Lantinga
598b4e0a1f Removed the limit on the number of supported renderer texture formats
Fixes https://github.com/libsdl-org/SDL/issues/9056
2024-05-09 13:30:07 -07:00
Ryan C. Gordon
39c8434f5f render: Manage memory for SDL_Renderer* at higher level.
Previously, each backend would allocate and free the renderer struct. Now
the higher level does it, so the backends only manage their private resources.

This removes some boilerplate and avoids some potential accidents.
2024-04-19 00:25:59 -04:00
Sam Lantinga
5fa87e29e7 Removed SDL_RENDERER_ACCELERATED and SDL_RENDERER_SOFTWARE
These flags are unnecessary and have always been a source of confusion.
2024-04-04 13:30:49 -07:00
danginsburg
650ba8f3ec Vulkan Renderer - closes #9385. When the vertex buffer size is exceeded, make sure to wait for outstanding work before resizing it. This fixes validation errors/crash found with using Imgui SDL3 renderer on Vulkan. 2024-04-01 07:38:31 -07:00
danginsburg
fb5307c1b3 Vulkan Renderer - fix synchronization validation issues with testrendertarget and testcopyex. When a texture is destroyed, VULKAN_IssueBatch is called to make sure the texture isn't referenced in any outstanding command work. This path did not wait on the semaphore from vkAcquireNextImageKHR, which would create a hazard. 2024-03-28 07:37:49 -07:00
Sam Lantinga
33eaddc565 Cleaned up various type conversion issues
This makes sure SDL_PixelFormatEnum flows through the internal code correctly, as well as fixing a number of other minor issues.
2024-03-07 06:58:43 -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
Sylvain
cea717e5d3 Removed some uneeded 'unsigned': renderer.num_texture_format and SDL_Vulkan_GetInstanceExtensions() prototype 2024-03-05 13:31:28 -08:00
Sam Lantinga
1e0bac288b Use the hlsli extension for shader includes 2024-03-05 12:46:44 -08:00
Sam Lantinga
759ade8c90 vulkan: enable samplerYcbcrConversion when creating the device 2024-03-04 11:17:42 -08:00
Sam Lantinga
48471f7dbd Added SDL_AddVulkanRenderSemaphores() for external synchronization with SDL rendering 2024-03-04 09:29:36 -08:00
Sam Lantinga
504d8c2fc0 Fixed potential memory leak if vkCreateInstance() fails 2024-03-04 09:29:36 -08:00
Sam Lantinga
eb5a2e7e7f Fixed building with SDL_LEAN_AND_MEAN
Fixes https://github.com/libsdl-org/SDL/issues/9173
2024-03-03 09:25:02 -08:00
Sam Lantinga
2bc2840de5 vulkan: VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 is a 2-plane format 2024-03-01 20:26:52 -08:00
Sam Lantinga
2bedd7f02e Fixed pitch alignment when updating SDL_PIXELFORMAT_P010 textures 2024-03-01 20:26:52 -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
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
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
fc94c3634e Fixed signed/unsigned comparison warning 2024-02-28 09:06:21 -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
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
Sam Lantinga
81608ad077 Vulkan: fixed creating SDL_PIXELFORMAT_P010 textures 2024-02-26 15:51:13 -08:00