Commit Graph

9103 Commits (19764ffcc811a498a508fe524a986455d25cf7e1)

Author SHA1 Message Date
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 7117d545a3 Fixed crash if the controller product name is NULL
This happens when the Razer Synapse software emulates a controller with a keyboard
2024-02-28 11:43:22 -08:00
Sam Lantinga fc94c3634e Fixed signed/unsigned comparison warning 2024-02-28 09:06:21 -08:00
Sam Lantinga ba34025423 Use direct3d11 as the default renderer on Windows
The D3D12 renderer initializes but has poor performance or graphical issues on older Intel hardware.

Fixes https://github.com/libsdl-org/SDL/issues/7634
Fixes https://github.com/libsdl-org/SDL/issues/9093
2024-02-28 09:00:36 -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
Frank Praznik 945162c6d9 wayland: Small optimization for output removal function
In the case where an output is being removed, the SDL_DisplayData is already known, so no need to retrieve it from the wl_output user data.
2024-02-28 10:43:06 -05: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
Anonymous Maarten c8372e20d6 SDLTest_CommonEvent: only set done when it is finished 2024-02-28 12:57:30 +01:00
Sam Lantinga 220340e944 Remove SDL_PIXELFORMAT_P010
It's not supported by any renderer or pixel conversion path
2024-02-27 12:48:33 -08:00
Frank Praznik c259a20f96 wayland: Remove all references to destroyed outputs from windows
The removal of a wl_output may not be accompanied by leave events for the surfaces present on it. Ensure that no window continues to hold a reference to a removed output.
2024-02-27 12:18:01 -05:00
Sam Lantinga 81608ad077 Vulkan: fixed creating SDL_PIXELFORMAT_P010 textures 2024-02-26 15:51:13 -08:00
Sam Lantinga 80d2ef7384 Fixed uploading Vulkan texture with w*bpp != pitch 2024-02-26 15:18:23 -08:00
Sam Lantinga 98b1a59a95 Document the HDR tone mapping algorithm 2024-02-26 14:20:34 -08:00
danginsburg 935c197059 Fix testautomation failures (including clip rect) - closes #9145. During merging for prep'ing the final PR for the Vulkan Renderer, I misordered a memcpy that regressed several of the testautomation test. From now on, I will make sure to run testautomation on any future PRs before submitting. 2024-02-26 10:04:10 -08:00
Ryan C. Gordon e61dfe405f
android: Fixed dead URL in comment. 2024-02-26 11:28:32 -05:00
danginsburg 35026cdcba Vulkan Renderer - robustly handle running out of descriptor sets or constant buffer memory. Closes #9131. My previous implementation of descriptor set handling was naive - it attempted to do VULKAN_IssueBatch when running out of descriptor sets or constant buffer space. For one thing, this had a bug and wasn't working (causing the crash), but moreover it would have resulted in having to flush the GPU. Instead, make the descriptor pools and constant buffer mapped buffers be resizeable so that if we need more it will grow to the size that is needed.
# Conflicts:
#	src/render/vulkan/SDL_render_vulkan.c
2024-02-26 08:12:24 -08:00
David Gow f976881651 Vulkan: Don't invalidate internal state in InvalidateCachedState
The VULKAN_InvalidateCachedState() function seems to be meant to
invalidate any _cached_ state, i.e. global state of the API which may
have been modified outside the renderer.

However, at the moment, the Vulkan renderer also resets a number of
internal variables which track buffers, offsets, etc, in use. As a
result, the renderer can get into an inconsistant state and/or lose
data.

For example, if VULKAN_InvalidateCachedState() is called in between two
calls to VULKAN_UpdateVertexBuffer(), the data from the first call will
be overwritten by that from the second, as the number of the next vertex
buffer to use will be reset to 0. This can result in rendering errors,
as the same vertex data is used incorrectly for several calls.

By no longer resetting this 'internal' state here, those glitches
disappear. However, I haven't tested this with any applications which
mix the Vulkan renderer with their own Vulkan code (do any such
applications exist?), so this may be insufficient in case a full flush
of the renderer state  -- and possibly a wait on the appropriate fence
-- could be required.

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-26 07:54:23 -08:00
David Gow c172fb5972 Vulkan: Support 'desired' vs 'required' memory flags (Fix #9310)
When selecting a memory type, there are some property flags we need
(e.g., VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, without which we cannot
vkMapMemory), and others we'd simply prefer (e.g.,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, which may have a performance
impact, but otherwise shouldn't be required).

By specifying these separately, we can fall back to a memory type which
doesn't have everything we want, but which should still work, rather
than giving up.

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-26 07:52:12 -08:00
David Gow 1558d52a0a Vulkan: Only return memory types which are a superset of what we need
VULKAN_FindMemoryTypeIndex() tries first to get a perfectly matching
memory type, then falls back to selecting any memory type which overlaps
with the requested flags.

However, some of the flags requested are actually required, so if -- for
example -- we request a memory type with
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, but get one without it, all future
calls to vkMapMemory() will fail with:

```
vkMapMemory():  Mapping memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set. Memory has type 0 which has properties VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT. The Vulkan spec states:
memory must have been created with a memory type that reports VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT.
```

(This occurs, for instance, on the totally non-conformant hasvk driver
for Intel Haswell integrated GPUs, which otherwise works fine.)

Instead, make sure that any memory type found has a superset of the
requested flags, so it'll always be appropriate.

Of course, this makes it _less_ likely for a memory type to be found, so
it does make #9130 worse in some ways. See the next patch for details.

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-26 07:52:12 -08: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
Sam Lantinga 7a9c6c7ce9 Include SDL_PIXELFORMAT_P010 as a supported format for the metal renderer 2024-02-25 13:55:52 -08:00
Sam Lantinga d211da75ac Fixed crash if app delegate method is called when SDL isn't initialized 2024-02-25 13:38:47 -08:00
Sam Lantinga 9dbbf0a2f7 Implemented clip rect functionality for the Vulkan renderer 2024-02-25 10:13:59 -08:00
Sam Lantinga d0af01e7d4 If the viewport changes the cliprect should be updated
The clip rectangle is defined to be viewport relative, so if the viewport changes we need to update it.

Fixes https://github.com/libsdl-org/SDL/issues/9094
2024-02-25 09:37:56 -08:00
David Gow b8a52c1237 Vulkan: Make sure validation layer name is in-scope
When enabling the Vulkan validation layers, the 'validationLayerName'
variable technically went out of scope before vkCreateInstance() was
called. While most compilers won't clean up stack variables after random
'if' statements, some will, particularly when optimisation or memory
sanitizers are enabled.

This can lead to vkCreateInstance() segfaulting when
SDL_HINT_RENDER_VULKAN_DEBUG is enabled.

Instead, make the validationLayerName visible throughout the entire
VULKAN_CreateDeviceResources() function.

While we're at it, extract the validation layer name out into a
preprocessor #define, so that we are definitely using the same name in
VULKAN_ValidationLayersFound().

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-02-25 08:24:43 -08:00
Sam Lantinga 276566235c Removed SDL_ClearHints() from the public API
Fixes https://github.com/libsdl-org/SDL/issues/9129
2024-02-24 21:07:50 -08:00
Sam Lantinga a1ea706215 Added names for the newly supported pixel formats 2024-02-24 20:13:59 -08:00
Sam Lantinga f6c42406cd SDL_COLORSPACE_HDR10 is the default colorspace for SDL_PIXELFORMAT_P010 surfaces 2024-02-24 20:04:36 -08:00
Sam Lantinga 4c5584174b Fixed error: declaration shadows a local variable [-Werror,-Wshadow] 2024-02-24 20:04:36 -08:00
Sam Lantinga 2b0e7c40ef Verify that we can create pipeline state objects for the D3D12 renderer
Fixes https://github.com/libsdl-org/SDL/issues/9093
2024-02-24 19:55:10 -08:00
danginsburg 97372b56e8 Vulkan Renderer - handle dynamic resetting of vsync, requires swapchain recreation. 2024-02-23 08:42:04 -08:00
danginsburg b1431e6702 Vulkan Renderer - implement support for vsync disabled. Closes #9116. 2024-02-23 08:42:04 -08:00
Sam Lantinga b9a00aa88e Fixed building the Vulkan renderer on Windows with Visual Studio 2024-02-22 17:18:46 -08: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
Sam Lantinga 2f1f55aeb1 Updated default SDR white point and HDR headroom to better match game content 2024-02-22 14:51:23 -08:00
Sam Lantinga 1fb5b9672e Keep SDR white point and HDR headroom defaults in one place 2024-02-22 14:47:58 -08:00
Sam Lantinga aeae202207 Make sure we actually have an HDR10 texture in the HDR10 shader
Some content uses the PQ transfer function but different color primaries
2024-02-22 11:50:58 -08:00
Sam Lantinga f4dd0dbbde Added colorspace conversion from SDL_COLOR_PRIMARIES_SMPTE431 and SDL_COLOR_PRIMARIES_SMPTE432 to SDL_COLOR_PRIMARIES_BT2020 2024-02-22 11:01:03 -08:00
Anonymous Maarten 279a650fae mediafoundation: fix SDL_camera_mediafoundation MinGW compile warnings 2024-02-22 07:18:22 -05:00
Sam Lantinga 78ac14124c Fixed warning C4245: 'function': conversion from 'int' to 'DWORD', signed/unsigned mismatch 2024-02-21 22:21:06 -08:00
Sam Lantinga 0f973f3eb4 Removed SDL_RENDERCMD_SETCOLORSCALE, which ended up being a noop on all renderers 2024-02-21 19:25:49 -08:00
Sam Lantinga 54c2ba6afd Added the Chrome HDR tonemap operator
Also added support for the SDL_PIXELFORMAT_XBGR2101010 pixel format to the D3D12, D3D11, and Metal renderers.
2024-02-21 19:25:49 -08: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
Ozkan Sezer 3b7533f4a2 SDL_camera_v4l2: allow building against older kernel headers 2024-02-22 00:50:40 +03:00
Anonymous Maarten ecfbb6719f SDL_test: support SDL_INIT_CAMERA for SDL_CommonInit and SDL_CommonQuit 2024-02-21 00:49:15 +01:00
Ryan C. Gordon 26ffbe43c2
camera: turn OFF `DEBUG_CAMERA` debug logging. 2024-02-20 16:09:02 -05:00
Ryan C. Gordon 6296677bc9 camera: Fixed Android hotplug. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 6c080717f2 camera: Reset permissions to undecided when closing camera.
Otherwise, the permission-granted event will not fire when reopened.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon db8caa029b camera: Added new function with gendynapi.py. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 70b89ab70d camera: Added SDL_GetCameraDevicePosition.
Otherwise, as a property, you have to open each camera device to figure out
which ones are which.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon bdcddf4810 camera: Disconnected cameras become zombies that feed blank frames. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 2613e3da24 camera: Rewrote Android support.
This does something a little weird, in that it doesn't care what
`__ANDROID_API__` is set to, but will attempt to dlopen the system
libraries, like we do for many other platform-specific pieces of SDL.

This allows us to a) not bump the minimum required Android version, which is
extremely ancient but otherwise still working, doing the right thing on old
and new hardware in the field, and b) not require the app to link against
more libraries than it previously did before the feature was available.

The downside is that it's a little messy, but it's okay for now, I think.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 848dcf8a5f main: Fixed compiler warning on Android.
(the NDK got upset about a function with void params using a bare `()`.)
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 47313bba32 camera: SDL_GetCameraDevices should not report "no devices" like an error. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 8db2a3b27a camera: Add an optional property that reports if a camera is back or front.
This is useful for iOS and Android, so an app can find the camera it cares
about in the list of devices.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 99d1337de2 camera: Reenabled macOS/iOS support, with rewritten CoreMedia implementation. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon f8fa08d2b1 camera: Fix compiler warnings on some platforms. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 22dbc0f32f camera: Patched to compile after rebasing to latest in main. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 7191a97fe3 camera: Windows support, through the Media Foundation API! 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 3dca8a03da camera: Removed some debug logging. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 67708f9110 camera: Emscripten support!
This also adds code to deal with waiting for the user to approve camera
access, reworks testcameraminimal to use main callbacks, etc.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 2cdff93578 v4l2: Corrected SDL_UDEV_AddCallback return check after #8694. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 0b5875825e camera: framerate support. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 9ae39d52de camera: Add sources to Xcode and Visual Studio projects.
This still needs updates to actually compile on macOS/iOS, though!
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 87e7046fca camera: Public API functions should say "Format" not "Spec" to match audio. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon f87d536229 camera: Added more accurate timestamps. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon d3e6ef3cc6 camera: Massive code reworking.
- Simplified public API, simplified backend interface.
- Camera device hotplug events.
- Thread code is split up so it backends that provide own threads can use it.
- Added "dummy" backend.

Note that CoreMedia (Apple) and Android backends need to be updated, as does
the testcamera app (testcameraminimal works).
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 3d2d5d18f3 pixels: Packed-pixel YUV formats can legit report bits-per-pixel.
This makes the existing SDL_SoftStretch code work with them, at least for
nearest-neighbor scaling; otherwise, it'll mangle the data trying to scale
it as 8bpp data without warning.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 8e1758260c surface: Fixed a typo in a comment. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon cb10c80aaf camera: Reworked to operate with a driver interface, like other subsystems. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 2ad44bd162 camera: Made a pass over all the sources, cleaning up for SDL3 style, etc. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 7ae955ce68 camera: Renamed everything from "video capture" to "camera", wired to CMake. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon f49ce4a15d camera: Renamed "video_capture" files to "camera" and moved to own subdir. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 4d000ae3bd
audio: Change references to `streams[i]` to previously-calculated `stream`.
Reference PR #9096.
2024-02-20 15:30:01 -05:00
Mathieu Eyraud 751917cb6f Fix null pointer dereference in SDL_BindAudioStreams() 2024-02-20 15:14:07 -05:00
Frank Praznik 8b6eae2d4f cmake: Split and store the libdecor version as individual parts
It is becoming necessary to enable additional features as libdecor continues to evolve, and checking against a single base version will no longer be adequate. Libdecor doesn't provide versioning defines in its headers, so split the version string into parts to allow for discrete version detection and feature enablement at build time.
2024-02-20 11:28:02 -05:00
Sam Lantinga 8073f4aa1d Pass the real error from D3D12_CreatePipelineState() back to the application 2024-02-20 06:24:20 -08:00
Sam Lantinga 376ef4e418 Fixed the WGI driver picking up Xbox controllers handled by RAWINPUT
The WGI driver will see them first, but the RAWINPUT driver has higher priority, so we'll defer to that when it's available.

Fixes https://github.com/libsdl-org/SDL/issues/9091
2024-02-20 06:20:32 -08:00
Ozkan Sezer cb3a1a82d5 SDL_memcpy.c, SDL_memmove.c, SDL_memset.c: don't use gcc builtins if !HAVE_LIBC
__builtin_memcpy, as well as __builtin_memset and __builtin_memmove, needn't be
inlined but emitted as a libc call, leading to infinitely recursive calls.

Fixes https://github.com/libsdl-org/SDL/issues/9090
2024-02-20 01:23:18 +03:00
Sam Lantinga bb4ec5250f Added support for non-gamepad controllers to the GameInput driver 2024-02-17 22:32:44 -08:00
Sam Lantinga f63f99bd2d Setup to handle the guide button once we get an updated GameInput SDK 2024-02-17 21:55:10 -08:00
Sam Lantinga ae8a910781 Added infrastructure for reporting GameInput touchpads
PlayStation controllers don't seem to report touch info, so we'll need to figure out how to interpret the touch data once it's available.
2024-02-17 21:21:54 -08:00
Sam Lantinga ae4aa25082 Get the real GameInput device name if possible 2024-02-17 20:12:46 -08:00
Sam Lantinga 419aebebda Added infrastructure for reporting GameInput sensors
IGameInputReading::GetMotionState() isn't implemented yet, so we'll need to figure out how to interpret the motion data once it's available.
2024-02-17 20:12:46 -08:00
Sam Lantinga 85ac0381b7 IGameInputDevice::GetDeviceInfo() can never return a null pointer
The IGameInputDevice instance can't be internally instantiated without it, so it's always guaranteed to be present.
2024-02-17 20:12:14 -08:00
Sam Lantinga fbe4153214 The HIDAPI driver takes precedence over the GameInput driver
The HIDAPI driver has more functionality for supported controllers.
2024-02-17 19:13:04 -08:00
Sam Lantinga 4a59b17de2 Added infrastructure for querying battery status for GameInput 2024-02-17 19:09:29 -08:00
Sam Lantinga fd9a4eff9f Updated GameInput device info to match other joystick drivers 2024-02-17 17:52:48 -08:00
Sam Lantinga 8f0f14c312 Added automatic gamepad mapping for the GameInput driver 2024-02-17 17:42:32 -08:00
Sam Lantinga eb9a7d97f9 The GameInput driver handles Xbox controllers
Don't let the raw input driver handle them when GameInput is active
2024-02-17 17:42:23 -08:00
Sam Lantinga 698b7deaa2 Removed GAMEINPUT_JoystickEffectDataType_HapticFeedback
This refers to the HID Simple Haptics spec, which is currently only implemented by the Surface Dial accessory and WMR game controllers, which aren't currently exposed by the GameInput API.

We can add support for other effects in the future, but for now we don't need this or the SDL_gameinputjoystick_c.h header.
2024-02-17 16:33:45 -08:00
Sam Lantinga f35ede7281 Generalized the idea of joystick driver priority
Joystick drivers are sorted by priority in the driver list, and higher priority drivers report whether they are handling a device when lower priority drivers want to add it to their device list.

This has been handled ad-hoc with the Windows and HIDAPI drivers, but this formalizes the idea and makes sure that GameInput has the highest priority of the Windows drivers.
2024-02-17 16:06:07 -08:00
Robert Edmonds 7f33464bed opengles2: Call glClearColor() with r,g,b,a, not r,g,g,a 2024-02-17 14:11:59 -08:00
Sam Lantinga fee140bdfe Added the option for GameInput support to the Win32 SDL build
GameInput is designed to be used by Win32 C applications, so no need to restrict it to the GDK build.
2024-02-17 14:07:42 -08:00
Nikita Krapivin 534f753e20 GameInput backend for SDL (Gamepad-only for now) 2024-02-17 11:33:51 -08:00
Sam Lantinga dc7baa415e Show the window after creating the renderer
This hides any window recreation that might need to be done by the OpenGL renderers
2024-02-17 09:21:30 -08:00
Sam Lantinga ff01d0b568 Fixed building without HAVE_LIBC on Windows
Fixes https://github.com/libsdl-org/SDL/issues/9064
2024-02-17 08:12:10 -08:00
Sam Lantinga 8ce786d2b6 Property query functions don't set an error if they return the default value
You can call SDL_HasProperty() if you want to check to see if a property exists.

Fixes https://github.com/libsdl-org/SDL/issues/9067
2024-02-17 07:59:04 -08:00
Sam Lantinga cb38649490 Added SDL_PROP_DISPLAY_HDR_WHITE_LEVEL_FLOAT 2024-02-16 19:50:41 -08:00
Ryan C. Gordon 6472e36264
x11: Minor cleanup in new mouse cursor selection code.
- Move legacy name choice to a separate function, so we can `return` a
  string in one line instead of assign a variable and `break` for each item.
- Have the case statement cover SDL_NUM_SYSTEM_CURSORS, and not `default`, so
  compiler will (maybe) warn us if an enum value is added but not included
  here.
- Only choose a legacy name if necessary.

(cherry picked from commit df00a7dd4c3deb03839e799187a3c75fc4e8854b)
2024-02-16 08:44:29 -05:00
Simon McVittie b986bc8be9 emscripten, wayland, x11: Share the table of CSS cursor names
As suggested in #8939.

This results in some minor changes for emscripten and x11. Both
previously mapped SIZEALL to "move", but "move" is not guaranteed to be
a four-pointed arrow: according to the CSS spec, it's actually intended
to be a drag-and-drop cursor, analogous to "alias" and "copy".
Map it to "all-scroll" instead, as in Wayland: while this is *also* not
semantically guaranteed to be a four-pointed arrow, it is at least
*suggested* to make it a four-pointed arrow.

Also, emscripten was previously using two-pointed arrows for resizing
(BOTTOMLEFT mapped to "nesw-resize", and so on). This commit changes
it to use the more specific "sw-resize" and so on, which might be
single-directional.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-16 07:52:43 -05:00
Simon McVittie 7dbd6669c3 wayland: Move calls to WAYLAND_wl_cursor_theme_get_cursor out of the switch
This will make it easier to potentially share the switch statement
between X11 and Wayland.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-16 07:52:43 -05:00
Simon McVittie 40a6c1c0a7 wayland: Use CSS/freedesktop cursor name "default" as a fallback
The "left_ptr" name is an X11 thing, and there's no guarantee that
Wayland cursor themes contain it. In particular, GNOME's Adwaita theme
as of version 46.beta only contains the CSS/freedesktop names.

To test, either move one of the known cursors out of the way, or edit
the switch statement above to use a wrong name for one of them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-16 07:52:43 -05:00
Simon McVittie 791646535a wayland: Reference CSS cursor name vocabulary
The freedesktop.org cursor spec recommends the same names as CSS, and
GNOME is treating the CSS vocabulary as canonical.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-16 07:52:43 -05:00
Ryan C. Gordon cb9565354c
x11: Use XcursorLibraryLoadCursor to load system cursors when available.
Apparently this is necessary on the latest Gnome to get properly themed
cursors, vs ancient X11 standard cursors, as Gnome has dropped the old
theme names that XCreateFontCursor eventually expected to find.

Fixes #8939.
2024-02-16 02:08:37 -05:00
Ozkan Sezer 6efe5f30ed don't let SDL_render.c:render_drivers[] have an empty initializer list. 2024-02-15 20:55:04 +03:00
Ozkan Sezer aae2d22852 Check the SDL_VIDEO_RENDER_??? macros with #if instead of #ifdef
Allows users to disable them by defining them as 0.

Closes https://github.com/libsdl-org/SDL/issues/8996

(manual port of https://github.com/libsdl-org/SDL/pull/9063 to SDL3.0)
2024-02-15 20:55:02 +03:00
Ryan C. Gordon 8ddddd36cd
audio: Deal with race conditions against default device changes.
This catches the case where we obtain a logical device while the default is
changing in another thread, so you accidentally end up with the previous
default physical device locked and returned from ObtainLogicalAudioDevice.
2024-02-15 14:13:26 -05:00
Frank Praznik 4eae38580f cocoa: Remove resize hack when changing the window backing scale
Zeroing the window width and height was necessary in SDL2 to short-circuit the resize event deduplication code when the window backing scale changed, but not the logical size. This is no longer necessary in SDL3, as it will explicitly check for scale changes on resize events and dispatch pixel size/scale changed events as appropriate, even if the window's logical size hasn't changed.
2024-02-14 17:33:06 -05:00
Frank Praznik f9ba0e1dbd wayland: Don't store wl_output pointers in mode driver data
They aren't used for anything, and cause problems if the video core tries to free them.
2024-02-14 10:42:15 -05:00
Ryan C. Gordon 5e1d9d19a4
audio: Don't use SDL_BindAudioStream inside SDL_OpenAudioDeviceStream().
It has a lot of complex validation and locking we want to avoid here.
2024-02-13 15:23:27 -05:00
Sam Lantinga 5e6ae85b63 Update the draggable state when the hit test callback changes
Fixes https://github.com/libsdl-org/SDL/issues/7617
2024-02-13 09:26:39 -08:00
Ryan C. Gordon bc984f78bf android: Remove blocking permission request code. Async only in SDL3!
(this actually still blocks at our internal points of usage, though, for
replacement at a later time.)
2024-02-13 12:06:51 -05:00
Ryan C. Gordon af61cfd5e0 android: Added SDL_AndroidRequestPermissionAsync. 2024-02-13 12:06:51 -05:00
Frank Praznik 310f21bf84 video: Ensure that all references to a destroyed fullscreen window are removed
Windowing systems that receive fullscreen state changes asynchronously may not receive a configure event notifying SDL that the window has left fullscreen when the window is being destroyed. Ensure that no display holds a reference to a destroyed fullscreen window.
2024-02-13 09:56:07 -05:00
Sam Lantinga f2695856d6 Use SDL string functions 2024-02-12 19:51:48 -08:00
Sam Lantinga 725c79f3ac Fixed building with SDL_LEAN_AND_MEAN
Fixes https://github.com/libsdl-org/SDL/issues/9054
2024-02-12 19:34:10 -08:00
Sam Lantinga 814a94c349 Fixed error: unused variable 'axes' [-Werror,-Wunused-variable] 2024-02-12 11:18:11 -08:00
Sam Lantinga f4d97bdb14 Update mouse transparency when the window shape changes
Fixes github.com/libsdl-org/SDL/issues/7617
2024-02-12 10:49:45 -08:00
Sam Lantinga 42cdbf6b21 Explicitly retain and release NSObjects in C structures
Fixes https://github.com/libsdl-org/SDL/issues/9021
Fixes https://github.com/libsdl-org/SDL/issues/9042
2024-02-12 10:20:06 -08:00
Sam Lantinga dca2721b91 Removed SDL_HINT_VIDEO_EXTERNAL_CONTEXT
This is replaced with SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT in SDL_CreateWindowWithProperties()
2024-02-12 09:54:33 -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
Sam Lantinga 20051f805f Removed SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4
Replaced with SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, defaulting to SDL_TRUE
2024-02-12 09:54:33 -08:00
Sam Lantinga 7cb1ca60ec Removed SDL_HINT_RENDER_OPENGL_SHADERS
Shaders are always used if they are available.
2024-02-12 09:54:33 -08:00
Sam Lantinga 9920e062d5 Removed SDL_HINT_THREAD_STACK_SIZE
The stack size can be specified using SDL_CreateThreadWithStackSize()
2024-02-12 09:54:33 -08:00
Sam Lantinga 9e505252c0 Renamed SDL_HINT_PS2_DYNAMIC_VSYNC SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC 2024-02-12 09:54:33 -08:00
Sam Lantinga a538936821 Renamed SDL_HINT_LINUX_JOYSTICK_DEADZONES to SDL_HINT_JOYSTICK_LINUX_DEADZONES 2024-02-12 09:54:33 -08:00
Sam Lantinga 980c379a0b Renamed SDL_HINT_LINUX_JOYSTICK_CLASSIC to SDL_HINT_JOYSTICK_LINUX_CLASSIC 2024-02-12 09:54:33 -08:00
Sam Lantinga 1f7936d545 Renamed SDL_HINT_LINUX_HAT_DEADZONES to SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES 2024-02-12 09:54:33 -08:00
Sam Lantinga 39cfb437ed Renamed SDL_HINT_LINUX_DIGITAL_HATS to SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS 2024-02-12 09:54:33 -08:00
Sam Lantinga b557c15bcf Renamed SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE to SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE 2024-02-12 09:54:33 -08:00
Sam Lantinga 4f628b5b62 Renamed SDL_HINT_GDK_TEXTINPUT_DEFAULT to SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT 2024-02-12 09:54:33 -08:00
Sam Lantinga fd5d761128 Renamed SDL_HINT_DIRECTINPUT_ENABLED to SDL_HINT_JOYSTICK_DIRECTINPUT 2024-02-12 09:54:33 -08:00
Sam Lantinga a5da7d0dd5 Renamed SDL_HINT_ALLOW_TOPMOST to SDL_HINT_WINDOW_ALLOW_TOPMOST 2024-02-12 09:54:33 -08:00
Sam Lantinga 9ce7fe2848 Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK
Sensors are a first-class object in SDL and we haven't gotten any feedback that this feature is useful these days.

Closes https://github.com/libsdl-org/SDL/pull/7879
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
Sam Lantinga cacac6cc34 Updated structure and field names for consistency
Type names are camel case and field names are snake case except for fields ending in id, which are capitalized.

Fixes https://github.com/libsdl-org/SDL/issues/6955
2024-02-11 08:27:56 -08:00
Ozkan Sezer 97d6e58a19 mark SDL_CleanupWindowTextureData as SDLCALL. 2024-02-11 18:55:40 +03:00
Ozkan Sezer ee5289ef09 mark SDL_ClipboardTextCallback as SDLCALL 2024-02-11 18:55:40 +03:00
Ozkan Sezer 168322f358 SDL_properties.c: mark CleanupFreeableProperty and CleanupSurface as SDLCALL 2024-02-11 17:29:20 +03:00
Sam Lantinga bba2a5d360 Added SDL_SetFreeableProperty() for internal use 2024-02-10 08:04:27 -08:00
Hans-Kristian Arntzen 69f2bd151e Fix broken use of MsgWaitForMultipleObjects.
- Timeout < 0 was not handled properly
- Return value for success is WAIT_OBJECT_0 + nCount, not positive value
2024-02-10 06:55:51 -08:00
Chris Collins 0f81598e9f Wayland: Avoid SEGV if a modifier notification comes before the keymap 2024-02-10 10:39:57 +01:00