Commit Graph
100 Commits
Author SHA1 Message Date
Sam Lantinga 6f8fbf5cea SDL_EVENT_CLIPBOARD_UPDATE isn't sent when the primary selection changes 2025-10-10 13:27:15 -07:00
Sam Lantinga 692c71a677 The dlopen note functionality is only used on UNIX platforms 2025-10-10 12:47:42 -07:00
Sam Lantinga ee622c570a Made SDL_dlopennote.h a public header 2025-10-10 12:47:42 -07:00
Sam Lantinga 1871b998cd Added SDL_EVENT_SCREEN_KEYBOARD_SHOWN and SDL_EVENT_SCREEN_KEYBOARD_HIDDEN
Fixes https://github.com/libsdl-org/SDL/issues/13049
2025-10-10 10:14:07 -07:00
Sam Lantinga 5441d33c0e testime: toggle text input with a mouse click 2025-10-10 10:14:07 -07:00
Sam Lantinga e1305ec2e2 Updated Xcode project for the switch to png test data 2025-10-10 10:14:07 -07:00
Sam Lantinga 17989940f2 Fixed SDL_BlitSurfaceTiledWithScale() with very small scale (thanks @bleeqer!) 2025-10-10 08:59:27 -07:00
Sam Lantinga 4a00aedd70 Updated .gitignore for png test data 2025-10-10 08:59:27 -07:00
Sam Lantinga 6677fad1c8 Added SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED
Fixes https://github.com/libsdl-org/SDL/issues/12785
2025-10-09 19:15:45 -07:00
Sam Lantinga d92079f2b7 testsprite: only use transparent alpha on transparent windows
Fixes https://github.com/libsdl-org/SDL/issues/14105
2025-10-09 14:32:08 -07:00
Sam Lantinga b5c9a83f65 Display error messages when evdev devices can't be opened
Fixes https://github.com/libsdl-org/SDL/issues/13141
2025-10-09 13:18:56 -07:00
Sam Lantinga 23e3cbec20 Only call clipboard callbacks with mime types they expect
Also clarified that returning NULL from a callback sends zero length data to the receiver, which should be able to handle that.

Fixes https://github.com/libsdl-org/SDL/issues/9586
2025-10-09 12:20:19 -07:00
Sam Lantinga 9cf7cdf23a Only return current clipboard data under X11
Fixes https://github.com/libsdl-org/SDL/issues/10192
2025-10-09 12:20:19 -07:00
Sam Lantinga 3c0a6c32d4 Fixed crash getting clipboard data processing clipboard events on X11
SDL_PumpEvents() was freeing the temporary memory in the clipboard event, so if the application was iterating over the mime types in the event and retrieving the clipboard data, it would crash after the first entry.
2025-10-09 12:20:19 -07:00
Sam Lantinga 0e7d5620c2 testclipboard: added support for UCS-2 and UCS-4 text
Chrome uses UCS-2 text for text/x-moz-url content
2025-10-09 12:20:19 -07:00
Sam Lantinga ec0e84fc0a testclipboard: support both BMP and PNG clipboard images 2025-10-09 12:20:19 -07:00
Sam Lantinga cf97ca1511 Fixed style 2025-10-09 12:20:19 -07:00
Sam Lantinga a6fc2c4b60 Use ndk r28 by default for 16KB page alignment 2025-10-08 21:34:19 -07:00
Sam Lantinga 5dc65f829f check_android_jni.py: make sure we're using python3 2025-10-08 21:32:30 -07:00
Sam Lantinga 9a6455a526 Disable GameInput for mouse and keyboard by default
We're going to wait for this to get more testing before enabling it by default.

Fixes https://github.com/libsdl-org/SDL/issues/13846
2025-10-08 21:22:22 -07:00
Sam Lantinga 2a92a3c9c5 Recreate the Vulkan GPU swap chain when resuming on Android
Fixes https://github.com/libsdl-org/SDL/issues/12957
2025-10-08 21:06:17 -07:00
Sam Lantinga 6f4993ddee Ignore invalid width/height in setOrientationBis() 2025-10-08 20:14:51 -07:00
Sam Lantinga 00ffddece8 Ignore VK_SUBOPTIMAL_KHR on the Android platform
This is returned whenever the device has been rotated, and can be safely ignored.

Fixes https://github.com/libsdl-org/SDL/issues/12950
2025-10-08 20:02:31 -07:00
Sam Lantinga a2a60f75c7 Temporarily disabled texture binding validation
There are some advanced use cases that trip over this, so temporarily disabling the validation pending further review.

Reference: https://github.com/libsdl-org/SDL/issues/13871
2025-10-08 19:50:48 -07:00
Sam Lantinga 84b0565096 Fixed potential memory leak 2025-10-08 19:44:03 -07:00
Sam Lantinga 3316dde0c2 Improved error information when renderer creation fails
On Android, if you create a window with SDL_WINDOW_OPENGL, you can't create a Vulkan surface. The error message has been improved to reflect this, and the error is propagated back up to the application.

Also added warn level logging if the renderer couldn't be created.
2025-10-08 19:36:19 -07:00
Sam Lantinga edf5f9ec5c Properly upgrade a window to Vulkan when creating a Vulkan renderer 2025-10-08 19:17:11 -07:00
Sam Lantinga d4b684311e Added the Wooting 60HE keyboard to the controller blacklist 2025-10-08 16:06:17 -07:00
Sam Lantinga caa33cb018 Removed InvalidateRect() when moving and resizing
This was added in 2016, presumably to help address the move/resize issues on Windows, which have been since been addressed by the live-resize functionality.

Fixes https://github.com/libsdl-org/SDL/issues/14079
2025-10-08 13:32:19 -07:00
Sam Lantinga 7914bdb7ea Only call WIN_RoUninitialize() if WIN_RoInitialize() succeeded
Fixes https://github.com/libsdl-org/SDL/issues/14178
2025-10-08 13:15:48 -07:00
Sam Lantinga 8830b466d0 Improve handling of surfaces with NULL pixels
Fixes https://github.com/libsdl-org/SDL/issues/14059
2025-10-08 12:40:29 -07:00
Sam Lantinga 244ae39b30 Optimized the 16-bit -> 32-bit SSE pixel conversion
Test code:
---
int main( int argc, char *argv[] )
{
    SDL_Surface *orig = SDL_LoadPNG("testyuv.png");
    SDL_Surface *surf16 = SDL_ConvertSurface(orig, SDL_PIXELFORMAT_RGB565);
    SDL_Surface *surf32 = SDL_ConvertSurface(surf16, SDL_PIXELFORMAT_ARGB8888);

    Uint64 then = SDL_GetTicks();
    for (int i = 0; i < 100000; ++i) {
        SDL_BlitSurface(surf16, NULL, surf32, NULL);
    }
    Uint64 now = SDL_GetTicks();
    SDL_Log("Blit took %d ms\n", (int)(now - then));
    return 0;
}
---

Results on my system:
BlitNtoN: Blit took 34522 ms
Blit_RGB565_32 (3 LUT): Blit took 9316 ms
Blit_RGB565_32 (1 LUT): Blit took 5268 ms
Blit_RGB565_32_SSE41: Blit took 1619 ms
2025-10-07 16:31:14 -07:00
Sam Lantinga 168de63a7a Switched back to a single LUT for 16-bit -> 32-bit pixel conversion
This beats the previous 3-LUT version and even beats SSE on my system.

Test code:
---
int main( int argc, char *argv[] )
{
    SDL_Surface *orig = SDL_LoadPNG("testyuv.png");
    SDL_Surface *surf16 = SDL_ConvertSurface(orig, SDL_PIXELFORMAT_RGB565);
    SDL_Surface *surf32 = SDL_ConvertSurface(surf16, SDL_PIXELFORMAT_ARGB8888);

    Uint64 then = SDL_GetTicks();
    for (int i = 0; i < 100000; ++i) {
        SDL_BlitSurface(surf16, NULL, surf32, NULL);
    }
    Uint64 now = SDL_GetTicks();
    SDL_Log("Blit took %d ms\n", (int)(now - then));
    return 0;
}
---

Results on my system:
BlitNtoN: Blit took 34522 ms
Blit_RGB565_32 (3 LUT): Blit took 9316 ms
Blit_RGB565_32 (1 LUT): Blit took 5268 ms
Blit_RGB565_32_SSE41: Blit took 6399 ms
2025-10-07 16:31:14 -07:00
Sam Lantinga dbd5dd8c75 Ensure 16-bit -> 32-bit conversion is consistent between blitters
The SSE, LUT, and other blitters should have the same results for 16-bit -> 32-bit conversion
2025-10-07 16:31:14 -07:00
Sam Lantinga e9c7cfb165 Revert "Use rounded results for expanding values to 8-bits"
This reverts commit ba5be7af74.

We actually want to use high bits and replicated low bits, to match SIMD value expansion
2025-10-06 23:14:38 -07:00
Sam Lantinga ba5be7af74 Use rounded results for expanding values to 8-bits 2025-10-06 21:28:42 -07:00
Sam Lantinga 1eb42b0dfd Added SSE accelerated RGB565 to 32-bit pixel conversions 2025-10-06 21:28:42 -07:00
Sam Lantinga e4c5b72fd7 video: Fix asserts calling SetWindowProgress{State,Value} when creating popup windows 2025-10-06 17:31:46 -07:00
Sam Lantinga 7877ed1802 Fixed permissions 2025-10-06 17:30:04 -07:00
Sam Lantinga 9f9be1425d Fixed permissions 2025-10-06 17:24:56 -07:00
Sam Lantinga 69791ccad0 Don't treat the Moonlander MK1 Keyboard as a controller
Fixes http://github.com/mgba-emu/mgba/issues/3606
2025-10-06 16:52:03 -07:00
Sam Lantinga bb0d6221c1 Use PNG files for tests and examples
These are much smaller than the previous BMP files

Fixes https://github.com/libsdl-org/SDL/issues/14159
2025-10-06 16:45:53 -07:00
Sam Lantinga 7454302cd0 Fixed 16-bit -> 32-bit blit lookup tables
The lookup tables weren't correct, e.g. 0xFFFF was being translated into 0xFFFFFFEF
2025-10-06 16:45:53 -07:00
Sam Lantinga 73334b6bb4 Added support for loading and saving PNG images using stb_image 2025-10-06 16:45:53 -07:00
Sam Lantinga 87e3250518 Add a note that OpenVR overlays assume unpremultiplied alpha by default 2025-10-06 11:58:21 -07:00
Sam Lantinga b92557c0b7 Made error message consistent between SDL_SetSurfacePalette() and SDL_SetTexturePalette() 2025-10-06 09:22:34 -07:00
Sam Lantinga 941b0a8ea4 Added support for external GPU textures to the GPU renderer 2025-10-06 07:31:00 -07:00
Sam Lantinga 134b47730b Added support for linear and pixel art scaling for palettized textures 2025-10-04 15:12:08 -07:00
Sam Lantinga d832ac5d6f SDL_RenderDebugText() is no longer blurry when scaled 2025-10-04 12:04:07 -07:00
Sam Lantinga f3815ede24 Rebuilt GPU renderer shaders 2025-10-03 19:35:45 -07:00
Sam Lantinga 49d51a0d3c Removed TEXTURETYPE_PALETTE_PIXELART
This doesn't make any sense since the pixel art algorithm uses a box filter to get an average pixel value which isn't possible with indexed textures.
2025-10-03 18:54:07 -07:00
Sam Lantinga ac2c834021 Fixed build 2025-10-03 16:04:45 -07:00
Sam Lantinga 1cda789a37 render: Default to primary display in SDL_CalculateSimulatedVSyncInterval if window is not set
- Fixes previous change to SDL_CreateRendererWithProperties which skipped SDL_CalculateSimulatedVSyncInterval if window was not set.
2025-10-03 16:00:44 -07:00
Sam Lantinga 0cab3521f1 render: Fix asserts from null window usage in SDL_CreateRendererWithProperties 2025-10-03 16:00:41 -07:00
Sam Lantinga 32668c4ddd Palettized textures will always use SDL_SCALEMODE_NEAREST.
Our algorithm for pixel art doesn't work on 8-bit images, needs further investigation.

Fixes https://github.com/libsdl-org/SDL/issues/14129
2025-10-03 14:29:47 -07:00
Sam Lantinga d333044462 Fixed destination coordinates when using scale with the software renderer
Fixes https://github.com/libsdl-org/SDL/issues/14051
2025-10-03 13:58:45 -07:00
Sam Lantinga b7b2e8bc31 Don't change the display of a window until it is mostly on the new one
Fixes https://github.com/libsdl-org/SDL/issues/12665
2025-10-03 12:38:47 -07:00
Sam Lantinga baae2a628d Store the current window display ID on the window 2025-10-03 12:38:47 -07:00
Sam Lantinga b1c2dd8433 Make sure the current resolution is in the fullscreen mode list
Custom resolutions don't enumerate normally, but make sure the current resolution is in the mode list.

Fixes https://github.com/libsdl-org/SDL/issues/11551
2025-10-02 15:19:41 -07:00
Sam Lantinga 11a66bd18c Minor cleanup in calls to getContext() 2025-10-02 10:50:10 -07:00
Sam Lantinga a864dcac25 Added support for using the GPU renderer as an offscreen renderer
SDL_CreateGPURenderer() now allows passing in an existing GPU device and passing in a NULL window to create an offscreen renderer.

Also renamed SDL_SetRenderGPUState() to SDL_SetGPURenderState().
2025-10-01 23:32:18 -07:00
Sam Lantinga 8d7cd3c6c2 Fixed line endings 2025-10-01 14:01:59 -07:00
Sam Lantinga 33c849d030 Always enable object validation when checking is explicitly enabled 2025-10-01 13:53:19 -07:00
Sam Lantinga f66e4d0a43 Enable full object validation by default
Full object validation was always done before this hint and there are a number of shipping products that relied on this, so don't change it by default.
2025-10-01 12:46:33 -07:00
Sam Lantinga 9735c45db6 Added an advanced shader for the GPU renderer
This allows us to support YUV colorspaces and HDR in the GPU renderer.

Fixes https://github.com/libsdl-org/SDL/issues/11281
Fixes https://github.com/libsdl-org/SDL/issues/11282
2025-10-01 07:17:55 -07:00
Sam Lantinga fe3b399b7e Added support for P010 pixel format in SDL_UpdateNVTexture() 2025-10-01 07:17:55 -07:00
Sam Lantinga 548063e578 Fixed pixel shader for palettized textures using pixelart scaling 2025-10-01 07:17:55 -07:00
Sam Lantinga 224b4917a3 testpalette: added a --renderer command line option 2025-10-01 07:17:55 -07:00
Sam Lantinga 8a5f9a3837 Removed validate_feature_indirect_draw_first_instance_disabled (thanks @rabbit-ecl!)
It was incorrectly checking the direct draw functions instead of checking indirect draw buffers.
2025-09-30 11:36:29 -07:00
Sam Lantinga baed512453 Fixed building tests on visionOS 2025-09-29 13:28:00 -07:00
Sam Lantinga 15f1cb4c98 Added GPU API support on visionOS
You must set SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN to false on this platform, since setDepthClipMode is not supported on Apple headsets (as of visionOS 2.3) and clipping is the default.
2025-09-29 13:28:00 -07:00
Sam Lantinga 2809ce9389 Set enable_depth_clip to true by default if SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN is false 2025-09-29 13:28:00 -07:00
Sam Lantinga f61e271e11 Generalize and validate optional GPU feature properties
Fixes https://github.com/libsdl-org/SDL/issues/13139
Fixes https://github.com/libsdl-org/SDL/issues/13138
2025-09-29 12:42:47 -07:00
Sam Lantinga 37410908c7 Fixed building on visionOS 2025-09-29 12:17:48 -07:00
Sam Lantinga 595f7b7ed9 Revert "Fixed Vulkan validation error"
This reverts commit b82b1f416f.

The renderer should not be enabling depth clamping.
2025-09-29 06:08:27 -07:00
Sam Lantinga b65590159b Each application palette corresponds to one hardware palette
When the application modifies the palette, any textures that use it will automatically be updated.
2025-09-28 22:10:06 -07:00
Sam Lantinga 5d311635cf Added Vulkan support for palettized textures 2025-09-28 22:10:06 -07:00
Sam Lantinga e2fe23ddab Added hardware accelerated support for palettized textures
Supported backends: direct3d, direct3d11, direct3d12, gpu, metal, opengl, opengles2
2025-09-28 22:10:06 -07:00
Sam Lantinga b82b1f416f Fixed Vulkan validation error
VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782(ERROR / SPEC): msgNum: -316906200 - Validation Error: [ VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782 ] | MessageID = 0xed1c6528 | vkCreateGraphicsPipelines(): pCreateInfos[0].pRasterizationState->depthClampEnable is VK_TRUE, but the depthClamp feature was not enabled. The Vulkan spec states: If the depthClamp feature is not enabled, depthClampEnable must be VK_FALSE (https://vulkan.lunarg.com/doc/view/1.3.268.0/windows/1.3-extensions/vkspec.html#VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782)
2025-09-28 22:10:06 -07:00
Sam Lantinga 524ba0a4ad Reduce the size of the D3D12 vertex shader constants
This is needed to add more fragment shader constants in the future as we're already at our 64 size limit
2025-09-28 22:10:06 -07:00
Sam Lantinga 5622eef5a8 Fixed memory leak if requested renderer isn't available 2025-09-28 22:10:06 -07:00
Sam Lantinga 2a01e12d34 Simplify palette code
Each texture gets its own palette, the palette is updated when it is rendered if necessary, rendering is flushed if a texture render is already queued up.

Trying to share palettes and handle the different cases of queued rendering and changing palettes in the middle of the frame ends up being very complicated, so we'll keep it simple for now.
2025-09-28 22:10:06 -07:00
Sam Lantinga 7dcc09986d Test changing the palette for a single texture 2025-09-28 22:10:06 -07:00
Sam Lantinga 264b436dba Fixed changing palettes while rendering is in flight 2025-09-28 22:10:06 -07:00
Sam Lantinga 0b4b254a53 Added support for textures with palettes
Closes https://github.com/libsdl-org/SDL/pull/6192
2025-09-28 22:10:06 -07:00
Sam Lantinga da84d78796 Fixed unknown frees being reported when SDL is built without allocation counts 2025-09-27 23:47:09 -07:00
Sam Lantinga 1d2a482dde testgpurender_effects: use the grayscale algorithm from BT.709 2025-09-26 10:27:10 -07:00
Sam Lantinga 1f73c19a73 Added stub SDL_TimeToDateTime() for N-Gage
Fixes https://github.com/libsdl-org/SDL/issues/14047
2025-09-26 09:37:04 -07:00
Sam Lantinga c39d772a07 Added a workaround for fullscreen mouse position on macOS 26 2025-09-25 15:10:08 -07:00
Sam Lantinga b2188b325d Fixed HIDAPI controller disconnect reading on multiple threads
If multiple threads are calling SDL_UpdateJoysticks(), then an overlapped read can be initiated on one thread (read_pending set to true) and GetOverlappedResult() called on another thread. This results in ERROR_OPERATION_ABORTED. This is harmless so we shouldn't return an error in this case, we'll just retry the read on the next call.

Fixes https://github.com/libsdl-org/SDL/issues/14033
2025-09-25 10:36:14 -07:00
Sam Lantinga 33a74c7548 Fixed typo 2025-09-25 07:31:07 -07:00
Sam Lantinga 0a50058f7a Use the real window position on macOS
On newer MacBooks, the fullscreen window might be placed below the camera notch, so use the actual window position

Fixes https://github.com/libsdl-org/SDL/issues/10441
2025-09-23 22:57:21 -07:00
Sam Lantinga fe8c080713 testime: allow enabling/disabling text input on individual windows 2025-09-23 09:59:11 -07:00
Sam Lantinga 221d1f12ea Use an empty bitmap for the blank cursor on macOS
Some macOS installations seem to have trouble decoding the GIF we were using

Fixes https://github.com/libsdl-org/SDL/issues/14012
2025-09-22 19:14:38 -07:00
Sam Lantinga 6f3ef22d19 Fixed build warning 2025-09-22 11:27:23 -07:00
Sam Lantinga cece47c64d Fixed iOS build 2025-09-22 11:27:07 -07:00
Sam Lantinga 137b0b2bee The default swap interval on EGL is 1, according to the spec
Fixes https://github.com/libsdl-org/SDL/issues/14014
2025-09-22 10:23:08 -07:00
Sam Lantinga 8a67a8a319 testautomation: fixed video tests on iOS 2025-09-22 10:09:30 -07:00
Sam Lantinga 5d9b9673b9 testautomation: use SDL functions for iostream test setup
This fixes the IOStream tests on iOS, since the current directory isn't writable
2025-09-22 10:09:30 -07:00
Sam Lantinga 9f9952d53a Fixed filesystem operations on iOS
Full paths are used as-is, relative paths are prepended with a writable path, SDL_GetPrefPath("", ""), since the current directory isn't writable.
2025-09-22 10:09:30 -07:00