Commit Graph

10759 Commits

Author SHA1 Message Date
Sam Lantinga afee27a530 Make sure stdio handles are in blocking mode
Standard I/O doesn't work well with non-blocking handles, so make sure any pipes are in blocking mode before launching child processes.

Fixes https://github.com/libsdl-org/SDL/issues/10998
2024-10-14 22:10:49 -07:00
Sam Lantinga bb764e3106 Added support for full range BT.709 YUV conversion
Also added simple colorspace testing to testyuv.
2024-10-14 20:36:46 -07:00
Zack Middleton edb28e79b5 Make SDL_LoadBMP() use true instead of 1 2024-10-14 20:07:03 -07:00
Zack Middleton 51dc978785 Don't overwrite the SDL_IOFromFile() error in SDL_LoadFile() 2024-10-14 20:07:03 -07:00
Zack Middleton fb43dc3097 Set error for NULL SDL_IOStream in SDL_LoadWAV_IO() 2024-10-14 20:07:03 -07:00
cosmonaut 00bb81de76 GPU: Allow size queries on depth formats 2024-10-14 14:28:21 -07:00
cosmonaut 57f2577c65 GPU Vulkan: Fix depth-only framebuffer leak 2024-10-14 10:19:07 -07:00
Ozkan Sezer 9fac4b9f5f SDL_windowsmodes.c: Fix MSVC builds against SDKs older than 10.0.17134.0
workaround the missing DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL enum value
and DISPLAYCONFIG_SDR_WHITE_LEVEL struct.

Fixes: https://github.com/libsdl-org/SDL/issues/11193
Closes:  https://github.com/libsdl-org/SDL/pull/11205
2024-10-14 09:04:25 -07:00
Sam Lantinga f9d490045b Fixed uikit crash when GLES is disabled
Fixes https://github.com/libsdl-org/SDL/issues/11208
2024-10-14 08:58:02 -07:00
Ryan C. Gordon c20918b0fb render: Add SDL_RenderDebugText().
Fixes #11201.
2024-10-14 02:45:33 -04:00
Sam Lantinga 1cc85c912b Check return value of SDL_small_alloc()
Fixes https://github.com/libsdl-org/SDL/issues/8959
2024-10-13 14:07:26 -07:00
Sam Lantinga d7be7fc168 Fixed Cohen-Sutherland out code computation for float line intersection
Fixes https://github.com/libsdl-org/SDL/issues/10866
2024-10-13 13:04:59 -07:00
Sam Lantinga a8ca024495 Added SDL_GetDefaultLogOutputFunction()
Fixes https://github.com/libsdl-org/SDL/issues/10603
Closes https://github.com/libsdl-org/SDL/pull/11106
2024-10-13 12:14:46 -07:00
Sam Lantinga b766c824bd Don't overwrite the SDL_IOFromFile() error in SDL_LoadBMP()
Fixes https://github.com/libsdl-org/SDL/issues/11188
2024-10-13 09:37:44 -07:00
Sam Lantinga a567786762 Added SDL_SetErrorV() 2024-10-13 09:26:25 -07:00
capehill 1a1e2e9892 Set size parameter in SDL_GetClipboardData()
Update size value in case where platform uses GetClipboardText().
This should fix clipboard_testClipboardDataFunctions on those platforms.
2024-10-13 08:59:50 -07:00
Evan Hemsley 82598e5ca9
GPU Vulkan: Fix frame counter timing (#11189) 2024-10-12 22:02:22 -07:00
Anonymous Maarten b641c2a0db Refactor gendynapi.py with the final goal to make it re-usable 2024-10-13 02:52:56 +02:00
Anonymous Maarten 173c168ff4 Default functions are already declared by the first SDL_dynapi_procs.h include 2024-10-13 02:52:56 +02:00
Cameron Cawley fd9e57b71e 3DS: Support simple message boxes 2024-10-12 16:07:52 -07:00
Rusty Moyher 7556c44796
SDL3: Fixed Cocoa_GL_CreateContext() not returning a context on success (#11181) 2024-10-12 14:01:21 -07:00
Cameron Cawley fec006a4f9 Allow for more fine tuning of Duff's device routines 2024-10-12 11:16:46 -07:00
Cameron Cawley aebb64efa1 Remove leftover ARM SIMD code 2024-10-12 11:13:37 -07:00
Daniel Gibson 9a81892447 Old env vars as fallback for SDL_VIDEO_DRIVER + SDL_AUDIO_DRIVER #11115
especially SDL_VIDEODRIVER is commonly used to use the native Wayland
backend, so I think it's a good idea to keep supporting the old name
instead of forcing users to find out that they now have to add an
underscore..
Not sure how popular SDL_AUDIODRIVER is, but with all the audio backends
that exist on Linux alone I'm sure some people use it to work around
sound issues.

Note: Doing this in the SDL_hints implementation instead of the
call-sites of SDL_GetHint(SDL_HINT_VIDEO_DRIVER) etc ensures that
1. Hint priorities work (env var overriding hint set by application with normal
   priority, but not when application used SDL_HINT_OVERRIDE)
2. SDL_ResetHint() (called by user code) respects the fallback
   environment variable
2024-10-12 08:47:02 -07:00
Cameron Cawley 3e57d996fe Reduce the size of the SDL_blit_0 alpha code 2024-10-12 08:29:11 -07:00
rhett-lee 22566506d0 SDL3: opengles2 render not support window with transparent flag on Linux/X11 (#11167) 2024-10-11 21:59:56 -07:00
Sam Lantinga c6c195ff88 Always use WaitForSingleObjectEx() as a fallback in SDL_SYS_DelayNS()
That logic isn't specific to the Visual Studio build environment. Also switched it to use CreateEvent(), which works back to Windows XP.
2024-10-11 21:18:31 -07:00
Sam Lantinga c5904d8710 Improved implementation of SDL_DelayPrecise() (thanks @nightmareci!)
Fixes https://github.com/libsdl-org/SDL/issues/10592
2024-10-11 21:18:31 -07:00
Sam Lantinga 25251a9405 Fixed warning C4723: potential divide by 0 2024-10-11 19:31:22 -07:00
Sam Lantinga 3cd7e22e8b Fixed converting full range YUV to RGB
Updated from https://kdashg.github.io/misc/colors/from-coeffs.html

I'm not sure where the other formulas came from, but they weren't mathematically correct and resulted in slightly incorrect colors.
2024-10-11 18:12:05 -07:00
Evan Hemsley 6ea4a66451
GPU: Add SDL_CalculateGPUTextureFormatSize (#11146)
---------

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2024-10-10 16:34:38 -07:00
Caleb Cornett 3db10a6b2c
GPU: ASTC block size fixes (#11157) 2024-10-10 15:40:21 -07:00
Ryan C. Gordon 90a3a2359b thread: Rewrote generic Condition Variables.
This replaces the internal mutex with a semaphore, so we're only using a
single synchronization primitive to implement this, and cleans up some logic
around wait timeouts.

This now matches the logic of the originally cited work, from BeOS.

Fixes #3639.

(I think.)
2024-10-10 15:03:53 -04:00
Sam Lantinga 73b995fbad Don't assume OpenGL on Android
This prevents Vulkan from initializing by default.

Fixes https://github.com/libsdl-org/SDL/issues/10279
2024-10-10 10:53:31 -07:00
Ozkan Sezer 7ff819141d libm/e_exp.c: fix gcc warning on 32 bit:
src/libm/e_exp.c:105: warning: integer constant is too large for 'long' type
2024-10-10 18:23:20 +03:00
Sam Lantinga 4b7c5f561b Fixed warning: ‘new_item.probe_len’ may be used uninitialized in this function 2024-10-10 08:06:18 -07:00
Sam Lantinga c8f5f6d47a Added SDL_DelayPrecise()
SDL_DelayNS() now passes through to the high precision OS delay function, and SDL_DelayPrecise() tries to busy wait to get as close as possible to the desired wait time.

Fixes https://github.com/libsdl-org/SDL/issues/11141
2024-10-10 08:06:18 -07:00
David Gow 9c322386bf gpu: vulkan: Fix an uninitialised structure in SDL_BlitGPUTexture()
The SDL_GPUColorTargetInfo structure needs to be zeroed, as otherwise we
can end up trying to create a resolve_texture which doesn't exist,
causing a rather difficult-to-debug segfault when calling
SDL_BlitGPUTexture() with a load op of SDL_GPU_LOADOP_CLEAR.
2024-10-10 07:16:02 -07:00
Evan Hemsley da5a1585cd
GPU: Avoid calling SDL_GetWindowSizeInPixels when possible (#11139) 2024-10-09 18:59:07 -07:00
Sam Lantinga 9023a199dd Fixed crash in RLE colorkey blitting
Fixes Maelstrom running over sdl2-compat with SDL3
2024-10-09 12:11:21 -07:00
Sam Lantinga f946f87f30 Don't rely on event.buttonMask being set in touchesEnded
Fixes https://github.com/libsdl-org/SDL/issues/11131
2024-10-09 11:35:39 -07:00
Sam Lantinga ee9b6204cf Updated to version 3.1.5 for development
We should bump the version immediately before and after release so the release version corresponds to a fixed snapshot of code.
2024-10-09 11:02:01 -07:00
Sam Lantinga f8eac30276 Added SDL_StepBackUTF8() 2024-10-09 09:49:10 -07:00
Sam Lantinga 1f08a03794 Switched drag-n-drop logging to trace level
The logging is extremely verbose and covers the entire data exchange process, which is more suited to the trace level.
2024-10-09 07:35:21 -07:00
Daniel Ludwig 5b6342a00d Default SDL_HINT_JOYSTICK_GAMEINPUT to "1" on GDK platforms 2024-10-09 07:30:13 -07:00
Daniel Ludwig acb18e05b5 GPU: fix swapchain buffer size not set on Xbox 2024-10-09 07:30:13 -07:00
Sam Lantinga ff834f7733 Removed the restrict keyword
It doesn't compile with older Visual Studio and I verified on godbolt.org that the way it was used here doesn't impact code generation at all.
2024-10-08 20:48:13 -07:00
Delta 8e6ead2f7b
[GPU] Added ASTC texture format support (#11116) 2024-10-08 18:45:04 -04:00
Ryan C. Gordon 02434cd293
emscripten: Fixes for data addresses above 2gb
This includes both wasm64 and wasm32 when addressing more than 2gb of memory.

Fixes: #9052

(Manually cherry-picked from 3deb07ea395373204462130c1e062bc1f71fe060.)
2024-10-08 17:41:18 -04:00
Ryan C. Gordon cba77834f2
init: Log '<unspecified>' not '(null)' if the app name isn't set.
Reference PR #11103.
2024-10-08 14:30:55 -04:00
Simon McVittie fb8244d6d9 init: Also log the SDL revision here
This includes the version number, unless the developer is doing
something strange with git tags.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-08 14:29:02 -04:00
Simon McVittie c24f7d2453 Log app ID as SYSTEM/INFO during initialization
This is not shown by default, but will be shown when using
SDL_LOGGING=system=info or higher, where it will hopefully nudge app
authors towards initializing this information.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-08 14:29:02 -04:00
Sam Lantinga e7ee92e822 Switched drag-n-drop logging to trace level
The logging is extremely verbose and covers the entire data exchange process, which is more suited to the trace level.
2024-10-08 10:56:27 -07:00
Sam Lantinga 2000ccb541 Allow linear interpolation of the font textures
With the recent changes to logical presentation, this is necessary for the font to look good when scaled.

Fixes https://github.com/libsdl-org/SDL/issues/11123
2024-10-07 21:43:57 -07:00
Sam Lantinga 4627283eca Allow building both Cocoa and dummy dialog implementations
This allows us to remove platformFilters from the Xcode project, which is not supported in Xcode 12.
2024-10-07 18:01:39 -07:00
Sam Lantinga 81b48de3f5 Fixed VID/PID list parsing of SDL_HINT_GAMECONTROLLER_SENSOR_FUSION
Fixes https://github.com/libsdl-org/SDL/issues/11118
2024-10-07 16:14:57 -07:00
Sam Lantinga 5db64300b8 Fixed SDL_GetStringInteger() for values starting with '0' and '1' (thanks @DanielGibson!) 2024-10-07 15:53:38 -07:00
Sam Lantinga 7da728a642 Added support for wired XBox controllers on macOS 15.0 Sequoia
Fixes https://github.com/libsdl-org/SDL/issues/11002
2024-10-07 15:44:42 -07:00
Ryan C. Gordon aa534c3ac3
core: Fixed incorrect comment in core/windows/SDL_windows.h. 2024-10-07 16:55:30 -04:00
rabbit-ecl 6ae5666acf
Check for VK_SUBOPTIMAL_KHR also in vkQueuePresentKHR (#11113)
This is already handled for vkAcquireNextImageKHR.
2024-10-07 13:01:10 -07:00
Sam Lantinga 06bd214af6 Fixed warnings building on Android 2024-10-07 11:11:27 -07:00
Sam Lantinga 65539bc4f7 Make sure trackpad state is updated when button presses are delivered
Fixes https://github.com/libsdl-org/SDL/issues/11085
2024-10-06 14:28:06 -07:00
Sam Lantinga 03b259893a Fixed return value of SDL_AddGamepadMapping()
Fixes https://github.com/libsdl-org/SDL/issues/11095
2024-10-06 14:20:30 -07:00
Jan Sedivy c2b98e21ba macOS: Add hint for smooth SDL_EVENT_MOUSE_WHEEL values 2024-10-06 12:36:42 -07:00
Frank Praznik 2fa8acb084 x11: Refresh the global cursor coordinates when confining the pointer
XGrabPointer can warp the cursor into the window when confining, so set the flag to refresh the global coordinates when queried.
2024-10-06 14:48:24 -04:00
David Fort e00b1fdd67 clipboard: include mime types in SDL_ClipboarUpdate
This patch modifies the clipboard handling so that when we receive an external
clipboard update, the suppported mime types are included in the SDL_ClipboarUpdate
event. The patch also introduces the owner field that allows to know if the update
is because we own the clipboard (internal update) or if it was an external update.
2024-10-05 18:19:10 -07:00
bubbleguuum 2880b40e33 fix pipewire prototype 2024-10-05 18:16:12 -07:00
zshoals 1ca45c5891 Fix typo: DiretMedia->DirectMedia 2024-10-05 00:08:01 -04:00
Sam Lantinga 00385951a1 Use file descriptor I/O for process pipes
Use low level non-blocking I/O for process pipe streams. This may fix issues with data not getting through the pipe occasionally.

Related: https://github.com/libsdl-org/SDL/issues/11006
2024-10-04 12:24:17 -07:00
Sam Lantinga 6c64c62114 Rename SDL_BUTTON() to SDL_BUTTON_MASK()
Fixes https://github.com/libsdl-org/SDL/issues/11056
2024-10-04 09:13:59 -07:00
Sam Lantinga fe2880fcda Rename SDL_SetThreadPriority() to SDL_SetCurrentThreadPriority()
Fixes https://github.com/libsdl-org/SDL/issues/11055
2024-10-04 08:57:03 -07:00
Daniel Ludwig 69196ab30d Change evasive library handle to `SDL_SharedObject*` 2024-10-04 05:18:40 -04:00
Ryan C. Gordon 3a6a3ab64f
gpu: Fix memory leak in Vulkan backend. 2024-10-04 04:46:28 -04:00
Sam Lantinga 43e7ce7dfc Updated to version 3.1.3 for the preview release 2024-10-03 23:01:55 -07:00
Ryan C. Gordon 9a5d5a2839 video: Improve the EGL attribute callbacks.
Now it has access to information it needs and it's clear who is reponsible
for memory management.

Fixes #11039.
2024-10-03 22:52:52 -07:00
Petar Popovic d4143e02d1 Always set checked_monotonic_time when calling CheckMonotonicTime() 2024-10-03 17:11:34 -07:00
Petar Popovic 020fb6889c Removed unnecessary const-qualifiers in src and test files 2024-10-03 17:39:08 -04:00
Petar Popovic b8e8dcaa9a Add void to openbsd function prototypes 2024-10-03 13:55:21 -07:00
Petar Popovic 0e909d2785 Removed redundant condition in src/events/SDL_pen.c 2024-10-03 13:42:18 -07:00
Ryan C. Gordon 191f3ecbbc render: Restore previous policy for converting window/render coordinates.
Before this commit, it would adjust for the logical presentation settings.
Now, it works as it did before the logical presentation render target was
removed: it takes current viewport and scale into account, as well.

Fixes #10978.
2024-10-03 16:31:56 -04:00
Petar Popovic 3246df8bd3 Remove redundant SDL_Vulkan_GetResultString() declaration 2024-10-03 13:29:53 -07:00
Ethan Lee a0de6c4abf Add properties to SDL_IOStreams returned by IOFromMem 2024-10-02 22:09:09 -07:00
Petar Popovic f4cea5e019 Removed const qualifiers from SDL_CreateHashTable() parameter types 2024-10-02 16:29:49 -07:00
Ryan C. Gordon d287feaddf
render: Remove non-pointer args' const qualifiers on SDL_RenderTextureRotated.
Reference Issue #11032.
2024-10-02 15:31:20 -04:00
Ryan C. Gordon 8b4f5f09c1
dynapi: It's a Python script now, not a perl script.
Fixes #11032.
2024-10-02 15:27:47 -04:00
Sam Lantinga 47450425fd Allow iterating just the keys or values in a hashtable 2024-10-02 10:20:00 -07:00
Sam Lantinga d5fe6dd627 Don't use const for non-pointer API parameters 2024-10-02 09:17:31 -04:00
Sam Lantinga eced9f58a9 Added a userdata parameter for EGL attribute callbacks
Fixes https://github.com/libsdl-org/SDL/issues/11013
2024-10-01 11:45:19 -07:00
Sam Lantinga 4fa92d233d Include stdbool.h when using Visual Studio 2017+
Also cleaned up some incorrect return values from bool functions.
2024-10-01 09:57:59 -07:00
Sam Lantinga 3b3c4a79b6 Don't close file descriptors already handled by AddFileDescriptorCloseActions()
Fixes https://github.com/libsdl-org/SDL/issues/10997
2024-10-01 09:32:14 -07:00
Anthony 5f5379dc99
Add `SDL_IsTV()` (#11004)
Moved SDL_IsAndroidTV() out of public API, to match SDL_IsAndroidTablet().

Added SDL_IsTV(), to mirror existing SDL_IsTablet().
2024-10-01 09:20:00 -07:00
Ryan C. Gordon 0b5e01a305 loadso: library handles are now `SDL_SharedObject*` instead of `void*`.
Improved the SDL_loadso.h documentation a little, too.

Fixes #11009.
2024-10-01 12:16:10 -04:00
Sam Lantinga 3234a3b902 Simplified internal SDL_Surface structure 2024-10-01 08:10:04 -07:00
Sam Lantinga 1f3a0d12e6 Made texture size and format public in the API
Also added refcount to textures so they can be retained by application code.
2024-10-01 08:10:04 -07:00
Ryan C. Gordon 5136b30652
render: SDL_ConvertEventToRenderCoordinates() now handles pen events.
Reference Issue #10863.
2024-10-01 10:30:36 -04:00
Ozkan Sezer 13c5d1092f hidapi: update hid_write() for windows from mainstream.
Returns bytes_written if WriteFile returns synchronously
Relevant mainstream discussions:
	https://github.com/libusb/hidapi/pull/697
	https://github.com/libusb/hidapi/issues/695
2024-09-30 19:49:44 -07:00
cosmonaut 3eab599977 just force the barrier on UpdateTexture actually 2024-09-30 19:47:27 -07:00
cosmonaut e17741a6cb Render GPU: Only cycle on update if entire texture is replaced 2024-09-30 19:47:27 -07:00
Sam Lantinga 45ad763de5 Disable backface culling and use a constant rectangle winding order.
This makes it so we don't have to surface the rectangle winding order for applications that want to use the raw geometry API.
2024-09-30 19:12:02 -07:00
cosmonaut fa14b53273 GPU Vulkan: Clear up some swapchain edge cases 2024-09-30 15:10:27 -07:00
David Fort 818d7d892a x11: store all atoms in a specific struct 2024-09-30 11:13:08 -07:00
David Fort 801870c8cf video: cache some more atoms under X11
This patch adds the caching of some atoms used by the clipboard.
2024-09-30 11:13:08 -07:00
Evan Hemsley afdf325fb4
GPU: Add swapchain dimension out params (#11003) 2024-09-30 10:23:19 -07:00
Anonymous Maarten b3388d5753 Haiku does not have fdatasync, but has fsync
https://dev.haiku-os.org/ticket/17378
2024-09-30 15:10:03 +02:00
Sam Lantinga 0b64520997 hashtable: fixed unused-parameter warnings
These show up with -Wextra when dropped into other projects.
2024-09-29 23:56:43 -07:00
Ryan C. Gordon 1787d6ca5c main: SDL_AppQuit() now reports the result value.
Fixes #10994.
2024-09-29 23:24:04 -04:00
Ryan C. Gordon 6a7f8b74f1
filesystem: SDL_GlobDirectory shouldn't strip final '/' if the path is "/".
This is common on Emscripten, where the base directory is "/".
2024-09-29 23:09:04 -04:00
Anonymous Maarten f6055432c8 Fix null-pointer dereference on failing SDL_SYS_CreateProcess 2024-09-30 03:03:33 +02:00
Anonymous Maarten e9bfa5bf6a Mitigate BatBadBut vulnerability 2024-09-30 03:03:33 +02:00
RT2 06e122103c Fix window opacity update 2024-09-29 14:08:09 -07:00
Sam Lantinga c84d825241 Added SDL_HashPointer() and SDL_KeyMatchPointer() 2024-09-29 10:59:18 -07:00
Frank Praznik d0c9c008e1
wayland: Use high-DPI system cursors on non-DPI aware windows
Using an unscaled buffer just results in the compositor scaling up the low-res cursor image for output, resulting in it appearing blurry. Always use the scaled cursor to ensure that it appears sharp and matches the native system look.
2024-09-29 13:27:46 -04:00
Ozkan Sezer 5f304b3a47 Fix builed error after commit 0e45b824e3 due to -Wunused-variable 2024-09-29 15:40:02 +03:00
Sam Lantinga 0e45b824e3 renderer: always update the output pixel size at startup
Fixes https://github.com/libsdl-org/SDL/issues/10990
2024-09-29 05:22:28 -07:00
Sam Lantinga 2825a682f0 Fixed build errors 2024-09-29 04:42:19 -07:00
Andrei Alexeyev ba7b346e52 hashtable: reimplement as open-addressed robin hood hashtable
This is mostly ported from Taisei Project
2024-09-29 04:11:14 -07:00
Evan Hemsley fc242abbd2
GPU: recreate swapchain on window pixel size change event (#10985) 2024-09-28 18:09:56 -07:00
Evan Hemsley 66f6b40c92
Render GPU: Don't call GetWindowSizeInPixels during RenderPreset (#10984) 2024-09-28 18:01:16 -07:00
Sam Lantinga a923771978 Added SDL_murmur3_32() 2024-09-28 17:19:01 -07:00
Sam Lantinga 039148fb0e Updated check for stdbool.h
If you're building in a C99 or newer environment, we'll automatically include stdbool.h.

If you're building in a C89 or C90 environment, we'll assume that stdbool.h isn't available and define bool as an unsigned char. If you have a working stdbool.h and want SDL to use it, you can either include stdbool.h before SDL headers, or define SDL_INCLUDE_STDBOOL_H in your project.

Closes https://github.com/libsdl-org/SDL/pull/10980
2024-09-28 16:55:09 -07:00
Frank Praznik 7ca0e9ede1
wayland: Scale the pointer destination size relative to the theme size
This better matches compositor behavior and avoids slight size jumps when the cursor enters and leaves the window.
2024-09-28 14:32:10 -04:00
Frank Praznik d2094bd0a2
wayland: Don't query the cursor info with DBus if the cursor shape protocol is present
If the cursor shape protocol is supported, the compositor will handle cursor themes and sizes automatically, so querying the properties with DBus serves no purpose as the values are never used.
2024-09-28 12:18:58 -04:00
Ryan C. Gordon 7d21a49c9c filesystem: SDL_EnumerateDirectoryCallback uses an enum now, not an int.
Fixes #10955.
2024-09-28 01:33:40 -04:00
Ryan C. Gordon 55bd9f5311 iostream: flush() should attempt to sync file data to physical media. 2024-09-27 20:20:51 -04:00
Ethan Lee 0852307b58 gpu: Check Vulkan device features for IsDeviceSuitable 2024-09-27 19:58:30 -04:00
cosmonaut fb165a542b GPU Vulkan: add resolve info to framebuffer and render pass lookups 2024-09-27 15:57:57 -07:00
Ryan C. Gordon 4a296f1bde filesystem: Fixed memory leak on Windows. 2024-09-27 18:54:18 -04:00
Ryan C. Gordon 428f2f35be filesystem: SDL_CreateDirectory should make parent directories.
Fixes #10502.
2024-09-27 18:54:18 -04:00
Ryan C. Gordon 94030131de filesystem: Windows SDL_SYS_CreateDirectory should succeed if dir exists. 2024-09-27 18:54:18 -04:00
Sam Lantinga 3f446d8fb5 Minor cleanup 2024-09-27 14:10:46 -07:00
Ozkan Sezer 1088ea55fa SDL_gpu_d3d11.c: define D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD for old toolchains 2024-09-27 23:55:02 +03:00
cosmonaut de40d6bae0 GPU Metal: Set texture to NULL even if AcquireSwapchainTexture fails 2024-09-27 13:49:26 -07:00
David Fort f32e96f5e2 clipboard: add SDL_ClipboardMimeTypes
This function allows to retrieve the available mime types without doing any
synthesizing.
2024-09-27 13:38:40 -07:00
cosmonaut eedd2039f9 GPU: 32-bit component texture formats 2024-09-27 16:26:43 -04:00
Evan Hemsley 05d0656bd6
GPU: Simultaneous compute pass read-write (#10965) 2024-09-27 12:49:37 -07:00
Sam Lantinga d39acc6d1e Fixed warning C4702: unreachable code 2024-09-27 11:19:54 -07:00
Caleb Cornett 5ff6e8d522
GPU: Add enable_depth_clip to RasterizerState (#10964) 2024-09-27 11:18:54 -05:00
Daniel Ludwig e98cf3c870 Fix Xbox builds 2024-09-27 08:10:03 -07:00
Evan Hemsley be401dd1e3
GPU: More robust error reporting (#10958)
---------

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
2024-09-27 00:30:18 -07:00
Sam Lantinga 48e213b4cd Fixed SDL_ShouldQuit() returning false during status transitions
We should wait for the state to stabilize before SDL_ShouldQuit() returns.

For example:
Thread A initializes and increments a use refcount
Thread B skips initializing and increments the use refcount
Thread B starts cleaning up and checks the use refcount
Thread A starts cleaning up, returns because SDL_ShouldQuit() returns false (not initialized), not touching the use refcount
Thread B returns because the use refcount isn't zero

Now we have the state where the refcount is greater than one and both thread A and B have attempted to cleanup.

With this change:
Thread A initializes and increments a use refcount
Thread B skips initializing and increments the use refcount
Thread B starts cleaning up and decrements and checks the use refcount
Thread A starts cleaning up, waits for thread B
Thread B returns because the use refcount isn't zero
Thread A continues and decrements and checks the use refcount, and finishes cleaning up because it has reached 0.
2024-09-26 18:08:58 -07:00
Ryan C. Gordon d8c76d2f34
filesystem: POSIX SDL_SYS_CopyFile shouldn't use a temp file.
Fixes #10957.
2024-09-26 19:34:34 -04:00
Ryan C. Gordon f267ec7681
filesystem: Improve docs, make some promises about overwrites and file caches.
Note that SDL_FlushIO() doesn't make promises about file data sync but that
is intended to be changed in the IOStream code in a later commit.

Fixes #10886.
2024-09-26 19:29:03 -04:00
Sam Lantinga 125e592844 Added SDL_ShouldInit() and SDL_ShouldQuit()
These are handy functions to support thread-safe initialization and shutdown.
2024-09-26 16:26:12 -07:00
Ryan C. Gordon 38f971bac5
filesystem: SDL_SYS_EnumerateDirectory() now returns bool. 2024-09-26 16:35:15 -04:00
Frank Praznik 671a33c2f7 wayland: Raise all touches on a cancel event 2024-09-26 14:45:10 -04:00
Petar Popovic 457d0edeaf Remove some extra semicolons 2024-09-26 20:01:56 +03:00
Sam Lantinga 345d9bfe19 A zero source rect is valid for blitting
A zero sized source rect draws pixels sourced from a 0x0 region on the source surface.

Fixes https://github.com/libsdl-org/SDL/issues/8580
2024-09-25 22:36:55 -07:00
Sam Lantinga 1aea43846e Don't use BlitARGBto555PixelAlpha() for SDL_PIXELFORMAT_ARGB1555
This didn't properly take into account destination alpha.

Fixes https://github.com/libsdl-org/SDL/issues/8401
2024-09-25 21:54:05 -07:00
Sam Lantinga d9a7da4fac Optimized SDL_HasEvent() and SDL_HasEvents()
Also document the counting behavior of SDL_PEEKEVENT.

Fixes https://github.com/libsdl-org/SDL/issues/6209
2024-09-25 21:20:00 -07:00
Ryan C. Gordon 3abb213083
opengl: Fixed SDL_RENDERCMD_SETDRAWCOLOR code checking the wrong variable. 2024-09-25 23:14:32 -04:00
Ryan C. Gordon 961cd51611
opengl: Removed a FIXME (this is documented as not-thread-safe now. 2024-09-25 23:14:32 -04:00
Anonymous Maarten 76f28ea120 Fix stdlib usage 2024-09-25 23:59:35 +02:00
Ryan C. Gordon 4c48ff51f8 render: SDL_RenderPresent now behaves when a render target is currently set.
It'll temporarily unbind it, draw letterboxing if necessary, present, and
then rebind the previous render target.
2024-09-25 16:26:36 -04:00
Ryan C. Gordon 7a6a0becb8 render: Fixed a FIXME for SDL_SetRenderViewport with a negative size. 2024-09-25 16:26:36 -04:00
Ryan C. Gordon 54459def69 render: Remove the logical presentation render target.
Now we render directly to the window, scaling as appropriate. This fixes some
concerns the render target introduced, like the quality of the final scaled
output, how to step outside of the logical size temporarily to draw some
things sharply at the native resolution, and loss of sub-pixel precision.

Fixes #8736.
2024-09-25 16:26:36 -04:00
Ryan C. Gordon bf7a48cdcc render/gpu: Change some memcpy calls to SDL_memcpy. 2024-09-25 16:26:36 -04:00
cosmonaut 925e47a077 GPU: Fix backwards LogError and SetError calls 2024-09-25 12:47:40 -07:00
cosmonaut 557c6dfb18 GPU: call SDL_SetError where appropriate 2024-09-25 10:47:14 -07:00
Cameron Gutman 6ec8b1a173 Throttle tickle reports to PS4/PS5 controllers
UpdateDevice() can be called at an arbitrary rate, so we need to
pace ourselves to avoid filling up the rumble queue with these.
2024-09-25 07:20:35 -07:00
Anthony 53bf2baac3 Change JNI calls to comply with recent Boolean changes
Android OpenURL and Toast methods return Booleans now, so let's use the correct interface.
2024-09-24 14:45:24 -07:00
Frank Praznik ad3a4c677b
wayland: Clean up cursor scaling
Handle named and custom cursor scaling in a cleaner manner, and account for edge cases where named cursor sizes may not exactly match the required size.
2024-09-24 11:46:56 -04:00
Cameron Gutman 57418475ce kmsdrm: Keep fd around if we can drop master
Modern kernels (v5.8+) allow non-root usage of drmDropMaster(), so
we can hold on to our fd after dropping master on it. This fixes
populating drm_fd in the KMSDRM SysWMinfo when using Vulkan.

Also add a missing error check for open() while we're here
2024-09-24 12:55:02 +03:00
Cameron Gutman 13f88df190 kmsdrm: Fix KMSDRM_Vulkan_CreateSurface() return value 2024-09-23 23:33:15 -05:00
Cameron Gutman 8f55f48337 kmsdrm: Move property initialization a bit further down
KMSDRM_GBMInit() must be called first to set drm_fd and gbm_dev.
2024-09-23 23:00:14 -05:00
Petar Popovic 004ac40226 Fix warning: no function prototype 2024-09-23 10:03:18 -07:00
Ethan Lee 4a3faf20ac gpu: Replace high-level logs with SetError 2024-09-23 10:57:10 -04:00
mausimus 0685b96469 GPU: fix build when SDL_GPU_DISABLED is set 2024-09-23 08:09:17 -04:00
Caleb Cornett 97d1056e16
GPU: MSAA fixes (#10917) 2024-09-21 17:38:10 -05:00
Evan Hemsley 89c6bc5f50
Prefer Vulkan even on Windows (#10912) 2024-09-20 13:42:15 -07:00
Evan Hemsley 980b4ff6db
GPU: Vulkan descriptor management rewrite (#10910) 2024-09-20 12:55:39 -07:00
Frank Praznik fcb8a2c016
wayland: Fix animated cursor timing
Adjust the frame timing so it will still advance if the frame callback fires faster than the frame duration.
2024-09-20 14:19:28 -04:00
Sam Lantinga ea2e2e451d Better fix for initializing Android environment variables 2024-09-20 11:09:48 -07:00
Sam Lantinga 095fb5f522 Fixed infinite recursion at startup on Android 2024-09-20 10:56:02 -07:00
T3hD0gg 594edb6bd2 Add Thrustmaster TMX VID & PID to wheel device list. 2024-09-18 22:19:54 -07:00
Sam Lantinga 34c6011360 Fixed Windows build 2024-09-18 14:55:51 -07:00
Sam Lantinga d29a0e3f31 Fixed warning: no previous prototype for function 2024-09-18 14:34:14 -07:00
Sam Lantinga 398dff7c25 Added support for the HORI licensed Steam Controller 2024-09-18 14:08:32 -07:00
Sam Lantinga 481203c074 Fixed Xcode warnings 2024-09-18 13:20:53 -07:00
Sam Lantinga 95c3ee77c1 Removed testing code 2024-09-18 11:12:06 -07:00
Simon McVittie 23f855a970 render: Integrate fix-shaders.sh into build-shaders.sh
By writing the fxc and dxc output to a temporary file and then
converting that temporary file to the desired filename, we avoid
the incompatible semantics of sed -i on GNU systems (sed -i does not
create a backup filename, and does not take an argument unless it is
"bundled") and macOS (sed -i requires an argument, possibly empty).

Resolves: https://github.com/libsdl-org/SDL/issues/10878
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-18 10:38:59 -07:00
Sam Lantinga d658ef6627 Don't guess about the size of an int, assert it! 2024-09-18 10:37:11 -07:00
Sam Lantinga a90ad3b0e2 Removed SDL_bool in favor of plain bool
We require stdbool.h in the build environment, so we might as well use the plain bool type.

If your environment doesn't have stdbool.h, this simple replacement will suffice:
typedef signed char bool;
2024-09-18 08:32:30 -07:00
Sam Lantinga 407ccadfd7 Added copyright header to edid.h 2024-09-18 08:18:26 -07:00
Sam Lantinga bd04459cde Fix typos (thanks @qndel!)
Fix typos in comments and in one case in a returned error ("insuffient -> insufficient" fb273eb)
codespell src/ *.cpp *.h *.hpp --ignore-words-list unknwn,thid,algebric,statics,pixelX,pEvents,caf,ptd,parms,pEvent,parm,TextureRS,TE,HDA,LOD,datas,UE,xwindows,IIF
cd src; git checkout \
    events/imKStoUCS.* \
    hidapi \
    joystick/controller_type.c \
    joystick/controller_type.h \
    joystick/hidapi/steam/controller_constants.h \
    joystick/hidapi/steam/controller_structs.h \
    libm \
    stdlib/SDL_malloc.c \
    stdlib/SDL_qsort.c \
    stdlib/SDL_strtokr.c \
    video/khronos \
    video/x11/edid.h \
    video/x11/edid-parse.c \
    video/x11/xsettings-client.* \
    video/yuv2rgb
2024-09-18 08:18:26 -07:00
Sam Lantinga 03ae792df3 Fixed the recording field in audio device events
Fixes https://github.com/libsdl-org/SDL/issues/10885
2024-09-17 11:36:55 -07:00
Sam Lantinga c68e9e157c Fixed typo 2024-09-17 10:59:28 -07:00
Sam Lantinga bc9780299c Don't define backends if SDL_GPU_DISABLED is set 2024-09-17 09:40:29 -07:00
Sam Lantinga 807b8a9d4d Allow initializing hints and properties from any thread 2024-09-17 08:53:27 -07:00
Sam Lantinga d0edf68774 Added Uint32 versions of the atomic functions 2024-09-17 08:53:27 -07:00
Sam Lantinga 8d223b3037 Renamed atomic functions to match SDL 3.0 naming convention
This will also allow us to cleanly add atomic operations for other types in the future.
2024-09-17 08:53:27 -07:00
Sam Lantinga f3e419596b Removed SDL_INIT_TIMER
This is no longer necessary before calling SDL_AddTimer()
2024-09-17 08:53:27 -07:00
Sam Lantinga 9275c533ca Added thread-safe initialization/cleanup support
Also went through and removed inappropriate uses of spinlocks.

Fixes https://github.com/libsdl-org/SDL/issues/10872
2024-09-17 08:53:27 -07:00
Sam Lantinga 7edd43c276 Don't define render_drivers if SDL_RENDER_DISABLED is set
Fixes https://github.com/libsdl-org/SDL/issues/10861
2024-09-17 08:46:05 -07:00
Sam Lantinga 98cd8b34a7 Close the other file descriptors after redirection has taken place
Fixes https://github.com/libsdl-org/SDL/issues/10868
2024-09-17 07:46:48 -07:00
Simon McVittie 4b3058d58d render: Don't try to rebuild D3D11, D3D12, Metal shaders without spirv-cross
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-17 07:43:37 -07:00
Simon McVittie 13500bbf50 render: Fix detection of fxc, dxc in build-shaders.sh
We want `$USE_FXC` to default to the result of evaluating the variable
`$HAVE_FXC`, not the literal string `HAVE_FXC`, and the same for dxc.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-17 07:43:37 -07:00
Green Sky 11129761e7 v4l2: return success if the device is ready 2024-09-17 07:41:43 -07:00
Simon McVittie ab9c68d9ff pipewire: Always destroy hotplug loop during deinitialization
We always need to destroy the hotplug loop and its associated resources
(if created) before we can deinitialize and unload the Pipewire library.

In the happy path where everything worked correctly, this means we will
call hotplug_loop_destroy() twice (once from PIPEWIRE_DeinitializeStart()
and a second time from PIPEWIRE_Deinitialize()), but that's OK, because
it's idempotent and so will do nothing the second time.

In error-handling code paths, this avoids needing to remember to call
hotplug_loop_destroy() explicitly, which should make it easier to avoid
bugs like #10787.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-09-17 07:35:42 -07:00
Sam Lantinga 231ea07617 Added SDL_LogTrace() 2024-09-17 02:04:54 -07:00
Sam Lantinga 6180da00e1 Skip a lock/unlock when logging known categories 2024-09-17 02:04:54 -07:00
Caleb Cornett c499f79fe9 GPU: Fix multisample texture usage validation 2024-09-16 17:55:27 -05:00
Sam Lantinga 1bbc897e48 Updated documentation for bool return type
Also updated the test CRC functions to return bool.
2024-09-16 13:12:15 -07:00
Sam Lantinga dc639956ba Improve logging performance and make log priorities thread-safe
Fixes https://github.com/libsdl-org/SDL/issues/9679
2024-09-16 13:09:17 -07:00
Caleb Cornett 9416917353
GPU: Rework MSAA (#10859) 2024-09-16 12:19:09 -05:00
Sam Lantinga 0f85fdefc8 Fixed warning: "SDL_VIDEO_RENDER_D3D12" is not defined, evaluates to 0 2024-09-16 07:40:00 -07:00
Caleb Cornett 4f722d372a
GPU: Metal vertex buffer indices should grow upward (#10837) 2024-09-15 20:17:43 -05:00
Sam Lantinga 5b5b1a8926 Fixed cleaning up dependent subsystems if initialization fails 2024-09-15 11:40:31 -07:00
Sam Lantinga 97d40b9218 Removed SDL_CleanupEnvironment() 2024-09-15 10:00:21 -07:00
Sam Lantinga 28b94c4758 Re-added SDL_getenv() as a thread-safe getenv() implementation 2024-09-15 09:37:04 -07:00
Sam Lantinga 718845a33d Fixed warning C4701: potentially uninitialized local variable 'startup_info' used 2024-09-15 09:21:04 -07:00
Sam Lantinga 19243092c6 Renamed SDL_GpuGraphicsPipelineTargetInfo to SDL_GPUGraphicsPipelineTargetInfo
Fixes https://github.com/libsdl-org/SDL/issues/10855
2024-09-15 07:46:26 -07:00
Sam Lantinga 604d0c519e If posix_spawn() is available, so is sigaction 2024-09-14 22:54:18 -07:00
Sam Lantinga ec5d280c90 Make sure we ignore SIGPIPE so we don't crash if we write when the pipe is closed 2024-09-14 22:15:18 -07:00
Sam Lantinga 34b2f4ffca Use non-blocking pipes for process I/O on Windows
Fixes https://github.com/libsdl-org/SDL/issues/10846
2024-09-14 21:16:35 -07:00
Anonymous Maarten dd07cc8991 SDL_Process: WAIT_TIMEOUT means the process has not exited yet 2024-09-14 21:16:29 -07:00
Carl Åstholm 1f3fd65c4c cpuinfo: Rename SDL_GetCPUCount to SDL_GetNumLogicalCPUCores
This was the only API that broke the "GetNumThings" convention
used elsewhere, so renaming it helps with consistency.
Adding "logical cores" to the name also makes it a bit
more immediately obvious what the count actually represents.
2024-09-14 19:33:30 -07:00
Sam Lantinga dcb2a8c2fe Use CreateProcessW() to handle non-ASCII file paths and arguments 2024-09-14 12:27:22 -07:00
Sam Lantinga e97f636590 SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER is an SDL_Environment pointer 2024-09-14 12:27:22 -07:00
Sam Lantinga 56fc4b790c Reduce strcmp() calls in hashtable lookup 2024-09-14 11:46:40 -07:00
Sam Lantinga e673479449 Removed SDL_WriteProcess()
This had the unfortunate side-effect of blocking if you tried to write too much. Instead you can use SDL_GetProcessInput() and handle SDL_IO_STATUS_NOT_READY as needed.

Fixes https://github.com/libsdl-org/SDL/issues/10834
2024-09-14 11:15:50 -07:00
Ozkan Sezer a833ee2e63 SDL_gpu.c: fixed build when SDL_GPU_DISABLED is defined. 2024-09-14 20:40:56 +03:00
ritalat f6f49de134 Add convenience functions to get process IOStreams 2024-09-14 10:33:29 -07:00
Sam Lantinga 7ff015ceae Close file descriptors not used by the child process 2024-09-14 10:29:02 -07:00
Sam Lantinga fed0149172 Switched wayland messageboxes to use the new process API 2024-09-14 10:29:02 -07:00
Sam Lantinga aa7357a14d SDL_CreateEnvironment() fills the environment with a non-zero parameter 2024-09-14 10:29:02 -07:00
Sam Lantinga 76c469910e Added SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN 2024-09-14 10:29:02 -07:00
Sam Lantinga 44c6cfda05 Switched zenity dialogs to use the new process API 2024-09-14 10:29:02 -07:00
Semphriss 27862907c6 Update src/process/windows/SDL_windowsprocess.c
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
2024-09-13 22:15:56 -07:00
Semphriss 82b33a7d3f Update src/process/windows/SDL_windowsprocess.c
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
2024-09-13 22:15:56 -07:00
Semphris 3cf54675bb Windows process: escape backslashes before quotes 2024-09-13 22:15:56 -07:00
Sam Lantinga 90e01040c5 Added thread-safe environment functions
Also marked the existing functions as unsafe, as they can cause crashes if used in multi-threaded applications.

As a bonus, since the new functions are hashtable based, hint environment lookups are much faster.
2024-09-13 22:14:54 -07:00
Ethan Lee 16ff7503b7 gpu: Update GPU support queries to better match naming conventions 2024-09-13 23:08:44 -04:00
Semphris 9eea8234e6 Add SDL_Process subsystem 2024-09-13 15:19:32 -07:00
Sam Lantinga 6c83491116 Added SDL_FlushIO()
Also added SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER and refactored the internal API to be able to create SDL_IOStream objects from native file handles.
2024-09-13 15:19:32 -07:00
Carl Åstholm eb199176e6 stdlib: Conditionally undef some SDL_strtox tests
Some test cases have implementation-defined results,
so we should only test these when we know SDL's own
implementations of the functions are used.
2024-09-13 12:30:58 -07:00
Carl Åstholm 59ec034412 stdlib: Use macros to define SDL_strtox tests 2024-09-13 12:30:58 -07:00
Carl Åstholm 8092e35287 stdlib: Improve SDL_strtod
- Handle leading whitespace
- Handle positive sign
- Parse integer part as unsigned long long
- Handle signed zero (this also applies to printf)
2024-09-13 12:30:58 -07:00
Carl Åstholm 56a48763cd stdlib: Bring SDL_wcstol in line with SDL_strtol 2024-09-13 12:30:58 -07:00
Carl Åstholm 61bc856b04 stdlib: Use new parser for scanf %p specifier 2024-09-13 12:30:58 -07:00
Carl Åstholm e109aa09aa stdlib: Rewrite SDL_strto(ll?|ul) impl 2024-09-13 12:30:58 -07:00
Carl Åstholm fb82772fb3 stdlib: Rewrite SDL_strtoull impl 2024-09-13 12:30:58 -07:00
Carl Åstholm 88d3cb4f90 Remove unnecessary include from SDL_pen_c.h 2024-09-13 12:30:58 -07:00
Carl Åstholm fd53b3e112 stdlib: Rewrite SDL_wcstol impl
SDL_wcstol should now fully adhere to the libc spec.
2024-09-13 12:30:58 -07:00
Anonymous Maarten ee65176eec SDL_test: add SDLTest_LogEscapedString 2024-09-13 20:52:32 +02:00
Anonymous Maarten 6a305e1532 SDL_test: fix SDLTest_CommonQuit with NULL state 2024-09-13 20:52:32 +02:00
Ethan Lee 0160e9eac6 gpu: Add SDL_QueryGPUSupport 2024-09-13 13:42:07 -04:00
Ethan Lee 96e147b2b9 gpu: Rework driver name queries, add GetGPUShaderFormats 2024-09-13 12:29:40 -04:00
Frank Praznik 6d92de5d3a
wayland: Ensure that a NULL internal structure isn't dereferenced when destroying a window
In some cases, such as when recreating a window during renderer initialization, a failure can leave the window in a state where the internal structure has already been freed, but the higher level window object needs to be destroyed separately. Check that the internal handle is valid before attempting to access any data during destruction.

Allows for graceful failure instead of a crash during cleanup if renderer creation fails.
2024-09-13 11:38:48 -04:00
Frank Praznik 9d9721cd4c
wayland: Fix some incorrect buffer scale calculations
Use doubles and apply an offset to account for rounding errors due to Wayland scale increments being in units of 1/120. This fixes the backbuffer size calculations with certain combinations of size/scale values, and future-proofs the Wayland backend, as 32-bit floats become increasingly error-prone with larger dimensions and/or scale factors.

The conversion formula is now point->pixel->point round trip safe as well.
2024-09-13 11:18:12 -04:00
Caleb Cornett 94436a938d GPU: Remove unused and incorrect D16 format checks from Vulkan driver 2024-09-13 10:16:02 -05:00