Commit Graph

22562 Commits

Author SHA1 Message Date
Sam Lantinga
04b2fb8046 Make sure the palette is no longer in use before freeing it in the Vulkan renderer
Fixes https://github.com/libsdl-org/SDL/issues/16283
2026-09-10 13:03:31 -07:00
Sam Lantinga
e05eb27f2c Use the surface palette directly for the texture in SDL_CreateTextureFromSurface()
This is a better fix for https://github.com/libsdl-org/SDL/issues/16227. It also allows you to create a whole set of indexed textures from surfaces that share a single palette and then modify that palette to change all textures.
2026-09-10 13:03:31 -07:00
Sam Lantinga
0f5a7cbd2c testyuv: verify the YUV surface locking path
Also implemented YUV surface locking for Vulkan
2026-09-10 13:03:31 -07:00
Sam Lantinga
3df2b1a2a7 Fixed Vulkan validation error in SDL_RenderReadPixels()
Validation Error: [ VUID-VkImageMemoryBarrier-oldLayout-01212 ] | MessageID = 0xff795e16
  vkCmdPipelineBarrier(): pImageMemoryBarriers[0].newLayout (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) is not compatible with VkImage 0x2160000000216 usage flags VK_IMAGE_USAGE_2_TRANSFER_DST_BIT_KHR|VK_IMAGE_USAGE_2_COLOR_ATTACHMENT_BIT_KHR.
  The Vulkan spec states: If layouts are not ignored, oldLayout or newLayout is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL then image must have been created with the VK_IMAGE_USAGE_TRANSFER_SRC_BIT usage flag set (https://docs.vulkan.org/spec/latest/chapters/synchronization.html#VUID-VkImageMemoryBarrier-oldLayout-01212)
2026-09-10 13:03:31 -07:00
Sam Lantinga
15c9ab245f The simple shader is only for HDR10 RGB textures
The use case for this is 2D render target overlays on HDR10 output. In this case we've already done the conversion to the output colorspace and we just want to get the pixels on the screen as fast as possible. Video frames still need YUV conversion, so they shouldn't go through this output path.
2026-09-10 13:03:31 -07:00
Sam Lantinga
21f4bc47b6 Remove SDL_HAVE_YUV checks from render drivers
This doesn't actually save much code size and complicates the drivers a fair bit.

Upside is that you'll now be able to build SDL without software YUV support and still be able to play videos with hardware acceleration enabled.
2026-09-10 13:03:31 -07:00
Brad Smith
b7606be372 fs: Use getexecpath() on OpenBSD for GetExePath(). 2026-09-10 14:13:36 -04:00
x0r
ce85ee87f6 DOS: yield audio thread even when the ring buffer has space 2026-09-10 12:01:35 -04:00
Frank Praznik
b88e540783 x11: Rescan the relative valuators on XI_DeviceChanged
XI_DeviceChanged can have a reason of XISlaveSwitch, which indicates that the valuators need to be updated for the specified device.
2026-09-10 11:53:54 -04:00
Ryan C. Gordon
d66e2d0cbd cocoa: Added SDL_HINT_MAC_USE_GCMOUSE.
Reference Issue #16241.
2026-09-10 09:51:10 -04:00
Sam Lantinga
fe2bca9748 Fixed YUV size and pitch calculations 2026-09-09 14:31:22 -07:00
Frank Praznik
9adf3ff6d3 x11: Don't suppress slave mouse buttons when lacking keyboard focus
The window may not have keyboard focus when using remote control tools, so drop the keyboard focus requirement. Tested not to regress clickthrough suppression.
2026-09-09 13:40:12 -04:00
Sam Lantinga
a55e059f84 Set the texture palette before setting pixel data
This is a better fix for https://github.com/libsdl-org/SDL/issues/16227.

The original problem was that the newly created texture didn't have any palette, so when the surface data was set, colors couldn't be mapped to pixel index values. The old fix temporarily set the texture palette to the surface palette, copied the surface data, and then set the texture palette to a copy of the surface palette. This caused Vulkan validation errors because we were deleting the original palette which was still referenced by the active command buffer. Instead, we'll create the palette that we want the texture to have to start with, then copy the surface data once that's set.
2026-09-09 10:21:23 -07:00
Sam Lantinga
8f9738372c Added SDL_PIXELFORMAT_I0FL 2026-09-09 10:21:23 -07:00
Sam Lantinga
b39f0a2f08 Rename SDL_PIXELFORMAT_P408 and SDL_PIXELFORMAT_P416 to SDL_PIXELFORMAT_I444 and SDL_PIXELFORMAT_I4FL
By convention, PNNN YUV formats are bi-planar, and SDL was using them to refer to 3 plane YUV formats.

These have been replaced with I444 and I4FL, which are the most standard FOURCC values for these that I could find.
Reference: https://github.com/videolan/vlc/blob/master/src/misc/fourcc_list.h
2026-09-09 10:21:23 -07:00
Tim Stahlhut
e33401c681 Cygwin: Use SDL_windowsdialog
Add "OR CYGWIN" to "WINDOWS" guards
Add "AND NOT CYGWIN" to "UNIX" guards

[sdl-ci-filter cygwin]
[sdl-ci-filter msys2-*]
[sdl-ci-filter msvc-*]
[sdl-ci-filter ngage]
2026-09-09 06:29:23 -07:00
Anonymous Maarten
f9abf9e843 pre-mingw-w64 MinGW toolchains don't ship with a intrin.h header 2026-09-09 03:18:41 +02:00
JustinChou
8f8ed757bc Modified points.c example from i++ to ++i for performance reasons and a good starting point for beginners to develop good habits. 2026-09-08 14:59:14 -07:00
Frank Praznik
aa5bffa6d3 wayland: Don't use a stale scaling factor
The output integer scale may not be re-sent if the display geometry changed, but the scale factor didn't. Cache and restore it on the integer path, to prevent an old value from being used, and possibly rounded to zero if the old value was less than 1.0.
2026-09-08 15:42:22 -04:00
Frank Praznik
184a070c5f Remove uses of stpcpy()
This function was only standardized in POSIX.1-2008, is not part of any ISO C standard, and is generally considered unsafe. Use SDL_strlcpy() instead.
2026-09-08 14:29:55 -04:00
Frank Praznik
f48fa604b0 x11: Clear the internal selection data when updating the clipboard
Clear the internal X11 clipboard selection data when updating the clipboard during SelectionNotify events, as it is invalid after the update. Otherwise, an out-of-date SelectionRequest can end up attempting to read the invalid data, and cause a crash.
2026-09-08 13:17:01 -04:00
Frank Praznik
84cd92d705 wayland: Avoid dereferencing a nil data offer
Pass the data device to the selection offer update functions instead of pulling it from the offer, as the offer may be nil.
2026-09-08 11:25:52 -04:00
Frank Praznik
25f4af8fcf x11: Handle XTranslateCoordinates failing during a reparenting operation
XTranslateCoordinates can generate a BadWindow error if called during a racy reparenting operation, so a non-fatal error handler is required.
2026-09-08 10:48:37 -04:00
Ethan Lee
6083940ef4 Add support for the Xbox 360 "Big Button" wireless receiver 2026-09-07 17:30:01 -04:00
muzikbike
42ad5c9955 Split System Request from Print Screen in XF86 as well 2026-09-06 09:43:02 -07:00
Frank Praznik
7e8a850246 x11: Register IM destruction/instantiation callbacks
Register callbacks to listen for IM destruction and instantiation to handle the IME shutting down and restarting during runtime.
2026-09-06 11:52:28 -04:00
Anonymous Maarten
c1ef7793c7 cmake: detect lld-link cli argument errors 2026-09-04 22:55:31 +02:00
Ryan C. Gordon
ea74d3b018 metal: Clear bogus pointer if we fail to get a new drawable.
Reference Issue #16232.
2026-09-04 15:55:40 -04:00
Sylvain
f034d594a8 Fix android build with SDK 37.2: Allow dots in platform directory names and use CMake version comparison 2026-09-04 20:00:49 +02:00
SDL Wiki Bot
d4410b9a7c Sync SDL3 wiki -> header
[ci skip]
2026-09-03 15:57:27 +00:00
muzikbike
dfcc6dee02 Change XF86 scancodes2 to match Linux
Should fix #16164
2026-09-03 07:19:33 -07:00
William Horvath
f443c429c6 d3d12: Read the fence in SubmitAndAcquireFence while submitLock is held
Once the lock is released, another thread can clean up the completed
command buffer, return it to the pool and resubmit it with a different
fence before we read d3d12CommandBuffer->inFlightFence, handing the
caller a fence it doesn't own (or NULL).
2026-09-02 13:03:04 -07:00
William Horvath
d8451e52d5 metal: Make the command buffer hold a reference to its fence
METAL_ReleaseFence cleared the fence's MTLCommandBuffer without holding
submitLock, while METAL_Submit's cleanup loop may still be polling it
through submittedCommandBuffers. It also did so before the DecRef, so
any non-final release broke later waits on a still-owned fence.
2026-09-02 13:03:04 -07:00
William Horvath
10309e3240 metal: Read the fence in SubmitAndAcquireFence while submitLock is held
Once the lock is released, another thread can clean up the completed
command buffer, return it to the pool and resubmit it with a different
fence before we read metalCommandBuffer->fence, handing the caller a
fence it doesn't own.
2026-09-02 13:03:04 -07:00
Sawkez
9dcc2e48fa implement joystick hotplugging 2026-09-02 11:52:16 -07:00
Frank Praznik
ec6790bd5e x11: Ignore BadWindow errors when handling a SelectionRequest
When handing a SelectionRequest event, XChangeProperty can generate a BadWindow error if the requesting window was already destroyed. Register an error handler to catch this, and prevent it from being fatal.
2026-09-02 12:35:41 -04:00
Ryan C. Gordon
a29eba40a4 kmsdrm: atomic path FIXME cleanup, must call CreateSurfaces.
This was a pending question from the atomic merge. Not only does this function
need to be called, it needs to be called in the SwapWindow* functions first,
like the legacy (non-atomic) path does.

Reference Issue #16136.
2026-09-02 10:35:37 -04:00
Evan Hemsley
b54c7178b9 GPU D3D12: Fix depth format sample count support check 2026-09-02 09:23:42 -04:00
Sam Lantinga
c8d08ea2df Use the surface palette when creating a texture from a surface
Fixes https://github.com/libsdl-org/SDL/issues/16227
2026-09-01 16:38:16 -07:00
Sam Lantinga
757400e044 Main callbacks should be processed even if events are already pending in SDL_WaitEvent()
Fixes https://github.com/libsdl-org/SDL/issues/15485
2026-09-01 15:36:38 -07:00
Cameron Cawley
79a4ea1c54 Improve implementation of GetClosestSupportedFormat (#15577)
* Indexed textures are now used for <8bpp surfaces and for indexed surfaces with transparency.
* If the software renderer is using RGB565 or BGR565, it now successfully detects a suitable 32-bit alpha format for converting the colour key.
* Matching pixel layouts are prioritized rather than just the number of bytes per pixel.
2026-09-01 15:14:44 -07:00
Brenton Bostick
46a942a3e3 fix typo 2026-09-01 11:23:57 -07:00
Ryan C. Gordon
22e42e6e1e aaudio: Make input preset into a hint, don't set it by default.
Fixes #16130.
Reference Issue #13402.
2026-09-01 14:03:24 -04:00
Ethan Lee
c5f07f0990 gpu: Return early when attempting to bind 0 samplers.
This is a common occurrence for vertex shaders specifically, and allows backends
to not have to handle this edge case every time.
2026-09-01 08:25:20 -04:00
SDL Wiki Bot
9e6f0180a0 Sync SDL3 wiki -> header
[ci skip]
2026-08-31 17:34:01 +00:00
Ryan C. Gordon
fd28dc9d56 PULL_REQUEST_TEMPLATE.md: "Zlib" should not be capitalized. 2026-08-31 13:27:23 -04:00
Ryan C. Gordon
83ab835bfd AGENTS.md: Updated text with latest policy revisions.
Reference Issue #15350.
2026-08-31 13:27:23 -04:00
Frank Praznik
2ec0b24b54 x11: Only position the fullscreen window if not on the target display
Entering fullscreen and moving the window can be a racy operation on some desktops, and isn't needed when the window is already on the target display, so only do it when necessary.
2026-08-31 13:08:42 -04:00
Sam Lantinga
70e9cc86dd Don't use the HIDAPI driver for the Tarantula 8K controller with stock firmware
This controller needs a firmware update before we can interpret its reports.
2026-08-31 09:35:51 -07:00
Frank Praznik
013844b003 cocoa: Convert popup window coordinates to global when adjusting the pointer offset
Fixes a regression in 958c4cbf0d
2026-08-31 11:58:59 -04:00