Commit Graph

1291 Commits (0d007bbb014311542f28dd83704a649ce4eaed75)

Author SHA1 Message Date
Susko3 f8cb3c742d Change `SDL_Keycode` type to an enum 2024-03-06 12:17:53 -08:00
Sam Lantinga c07b39fa06 Fixed build 2024-03-06 09:57:39 -08:00
Sam Lantinga 860155680d SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events. 2024-03-06 09:51:15 -08:00
Sam Lantinga 9db68f97f9 Reverted SDL_Vulkan_GetInstanceExtensions() API change
This function is commonly used with Vulkan structures that use uint32_t, so we should keep the Uint32 signature.
2024-03-05 13:39:42 -08:00
Sylvain cea717e5d3 Removed some uneeded 'unsigned': renderer.num_texture_format and SDL_Vulkan_GetInstanceExtensions() prototype 2024-03-05 13:31:28 -08:00
Sam Lantinga d4f4aa745a Use C++ style comments in new code 2024-03-05 04:46:37 -08:00
Sam Lantinga fb87f8f15c testffmpeg: fixed mismatch between frame size and frame texture size
The AVHWFramesContext associated with the frame has the texture size, and the frame width and height are the displayed size and can be smaller than the texture size
2024-03-04 11:17:42 -08:00
Sam Lantinga 180dd0bb39 testffmpeg: don't free the instance extensions, we hold onto them in the context 2024-03-04 11:17:42 -08:00
Sam Lantinga 2d4105ba8b testffmpeg: only enable AV_PIX_FMT_VULKAN if we have a Vulkan renderer 2024-03-04 11:17:42 -08:00
Sam Lantinga 97f97109d1 testffmpeg: fixed Vulkan validation errors
The semaphores need to be submitted in order
2024-03-04 09:29:36 -08:00
Sam Lantinga dbec2150d0 testffmpeg: added support for Vulkan rendering 2024-03-04 09:29:36 -08:00
Robert Edmonds a4d7ff6751 testffmpeg: Use EGL_EXT_image_dma_buf_import_modifiers extension
If the `EGL_EXT_image_dma_buf_import_modifiers` extension is available, propagate the DRM format modifier from the AVDRMObjectDescriptor to eglCreateImage() on Linux. Some hardware will decode video into a non-linear DRM surface, and passing the DRM format modifier to eglCreateImage() is required in order to display something useful.

Fixes https://github.com/libsdl-org/SDL/issues/9075
2024-03-03 15:18:56 -08:00
Sam Lantinga 88dcf74588 testyuv: we no longer need to override the HDR headroom for the BT.2020 test 2024-03-02 15:06:28 -08:00
Sam Lantinga 7f9ff6277c Don't assume HDR headroom for HDR10 surfaces
Applications that support HDR will set the correct values for their content.
2024-03-02 15:02:17 -08:00
Sam Lantinga f2cd361e25 testyuv: added validation of P010 YUV format
Also added conversion between RGB and P010, using XRGB2101010 as a bridging format in PQ space
2024-03-01 20:26:52 -08:00
Sam Lantinga 47be24d225 testyuv: added --monochrome and --luminance options for interactive mode 2024-03-01 07:42:34 -08:00
Sam Lantinga 991ad27de8 testyuv: added GetColorspaceForYUVConversionMode() 2024-03-01 07:42:34 -08:00
Ryan C. Gordon 1e8b006d43 stdlib: qsort and bsearch changes.
- Always use internal qsort and bsearch implementation.
- add "_r" reentrant versions.

The reasons for always using the internal versions is that the C runtime
versions' callbacks are not mark STDCALL, so we would have add bridge
functions for them anyhow, The C runtime qsort_r/qsort_s have different
orders of arguments on different platforms, and most importantly: qsort()
isn't a stable sort, and isn't guaranteed to give the same ordering for
two objects marked as equal by the callback...as such, Visual Studio and
glibc can give different sort results for the same data set...in this
sense, having one piece of code shared on all platforms makes sense here,
for reliabillity.

bsearch does not have a standard _r version at all, and suffers from the
same SDLCALL concern. Since the code is simple and we would have to work
around the C runtime, it's easier to just go with the built-in function
and remove all the CMake C runtime tests.

Fixes #9159.
2024-03-01 08:28:12 -05:00
Sam Lantinga 039144350c Be more precise about what we're testing in testyuv 2024-02-28 17:15:47 -08:00
Sam Lantinga b30ba1c5d4 Updated RGBtoYUV() to use the full YCbCr conversion formula 2024-02-28 16:58:39 -08:00
Sam Lantinga 353e76b40b Use the correct colorspace for yuv conversion tests 2024-02-28 10:03:18 -08:00
Sam Lantinga fb3bf1dcbd Fixed device queue initialization when render and present queue families are different 2024-02-28 08:55:56 -08:00
Anonymous Maarten 0a961915dc cmake: testffmpeg requires link to EGL library for EGL feature 2024-02-27 12:28:06 +01:00
Sam Lantinga 24e021c67e testffmpeg: refactored texture creation properties into a single function 2024-02-26 16:01:23 -08:00
Sam Lantinga ff18d7cfa0 testffmpeg: added pixel format mapping for NV12 and NV21 2024-02-26 15:52:21 -08:00
Sam Lantinga f99143f437 Don't quit testffmpeg when alt-tabbing away 2024-02-26 15:21:26 -08:00
Sam Lantinga 3a796c9722 Allow specifying the render driver in the environment for testffmpeg 2024-02-26 15:13:10 -08:00
Sam Lantinga dc9a3c83e2 Use the mastering display metadata to do proper tone mapping for HDR content 2024-02-26 14:20:34 -08:00
Sam Lantinga 141497b14f Added an automated test to verify clip rect functionality 2024-02-25 09:44:41 -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
Anonymous Maarten cbf0b1ce81 testcamera: create window and renderer through test library 2024-02-21 00:49:15 +01:00
Ryan C. Gordon f59c66a97f testcamera: Allow app to flip between a front and back camera. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon b1ed49772c camera: Replace testcamera.c with testcameraminimal.c 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 0b8617f71d test: Fixed CMake to build testcameraminimal correctly on WinRT. 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 87e7046fca camera: Public API functions should say "Format" not "Spec" to match audio. 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 cb10c80aaf camera: Reworked to operate with a driver interface, like other subsystems. 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
Sam Lantinga ed615e92b7 Updated automated test now that getting an invalid property isn't an error 2024-02-17 09:30:50 -08:00
Sam Lantinga 202886f873 Make use of the HDR light range when playing HDR video 2024-02-16 20:05:11 -08:00
Sam Lantinga cb38649490 Added SDL_PROP_DISPLAY_HDR_WHITE_LEVEL_FLOAT 2024-02-16 19:50:41 -08:00
Sam Lantinga d451fcd7a7 Fixed HDR video content being too bright on Apple platforms
This probably isn't the exact formula that we need, but it's much closer to correct.
2024-02-15 16:39:13 -08:00
Sam Lantinga c09daf8388 Removed unused variables 2024-02-15 14:11:04 -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 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 a538936821 Renamed SDL_HINT_LINUX_JOYSTICK_DEADZONES to SDL_HINT_JOYSTICK_LINUX_DEADZONES 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
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
Sam Lantinga f6b92c9b88 Re-added a simplified version of SDL_SetWindowShape()
In order to handle mouse click transparency this needs to be implemented inside SDL
2024-02-09 16:04:46 -08:00
Sam Lantinga 1143bdc351 Greatly simplified the shape example 2024-02-09 03:04:40 -08:00
Sam Lantinga 1c4c29b7ad Fixed a swap chain leak and a double-free in testffmpeg.c
Also added more debug logging to the direct3d11 renderer
2024-02-06 21:33:57 -08:00
Sam Lantinga 3158342441 Use SDL_Color for SDL_RenderGeometryRaw() and add SDL_RenderGeometryRawFloat()
Eventually we can re-add a fast path for that data down to the individual renderers. Setting color scale would still require converting to float, and most hardware accelerated renderers prefer to consume colors as float, so this requires some thought and performance testing.

Fixes https://github.com/libsdl-org/SDL/issues/9009
2024-02-06 18:16:41 -08:00
Sam Lantinga 8afba41aef Added support for HDR10 video on Apple platforms 2024-02-06 15:40:47 -08:00
Sam Lantinga 2039c46d2c Added support for creating an SDL texture from a CVPixelBufferRef 2024-02-06 15:40:47 -08:00
Sam Lantinga ba074acad4 Implemented scRGB colorspace and HDR support on macOS 2024-02-06 12:29:44 -08:00
Sam Lantinga 30e176d6ba Added HDR display properties and related event
Also added an HDR calibration stage to testcolorspace
2024-02-06 02:48:05 -08:00
Sam Lantinga d4caef5b89 Generalize SDR white level handling into a color scale
This gives applications better control over how and when light levels are adjusted when working with HDR content and display.
2024-02-06 02:48:05 -08:00
Sam Lantinga e74171b1ae Added support for HDR10 video playback on direct3d11
Fixes https://github.com/libsdl-org/SDL/issues/8053
2024-02-05 09:45:39 -08:00
meyraud705 f85535b4b6 Use functions from SDL instead of libc 2024-02-05 09:01:28 -05:00
Sam Lantinga ec322bee1c Fixed testyuv help message 2024-02-04 13:09:40 -08:00
Sam Lantinga 327b976bc4 SDL_COLORSPACE_JPEG is the default YUV colorspace 2024-02-04 13:09:40 -08:00
Sam Lantinga 5b8e5f8b9f Fixed accidental changing of All to Allu in previous commit (thanks @zturtleman!) 2024-02-03 23:46:22 -08:00
Sam Lantinga c0b27ccef9 Fixed warning C4701: potentially uninitialized local variable 'drawnTextRect' used 2024-02-03 11:49:15 -08:00
Sam Lantinga 8eba5b75ca Fixed warning C4701: potentially uninitialized local variable 'rndctx' used 2024-02-03 11:49:15 -08:00
Sam Lantinga 445cb42acd Fixed warning C4244: 'function': conversion from 'int' to 'Uint16', possible loss of data 2024-02-03 11:49:15 -08:00
Sam Lantinga 45f936c788 Fixed warning C4245: 'initializing': conversion from '__int64' to 'unsigned __int64', signed/unsigned mismatch 2024-02-03 11:49:15 -08:00
Sam Lantinga 74e85e3a51 Fixed warning C4706: assignment within conditional expression 2024-02-03 11:49:15 -08:00
Sam Lantinga c3e3ad6140 Fixed build warnings 2024-02-03 11:49:15 -08:00
Sam Lantinga c02aaebccc Fixed warning C4245: 'initializing': conversion from 'int' to 'Uint32', signed/unsigned mismatch 2024-02-03 11:49:15 -08:00
Sam Lantinga ff5fdf9f53 Fixed warning C4244: 'initializing': conversion from 'int' to 'const Uint8', possible loss of data 2024-02-03 11:49:15 -08:00
Sam Lantinga 9989f92eee Fixed warning C4245: 'initializing': conversion from 'int' to 'SDL_AudioDeviceID', signed/unsigned mismatch 2024-02-03 11:49:15 -08:00
Sam Lantinga 89b9d6cbdc SDL_RenderReadPixels() now returns a surface
Fixes https://github.com/libsdl-org/SDL/issues/8977
2024-02-03 11:49:15 -08:00
Sam Lantinga 50a805cdd1 Use YUV colorspaces instead of a global YUV conversion mode
Fixes https://github.com/libsdl-org/SDL/issues/8669
2024-02-03 07:36:18 -08:00
Sam Lantinga f9c57e16b0 Don't test 10-bit pixel format conversion
We either need to explicitly test using the sRGB colorspace or update the tests for HDR10 color conversion. We'll just disable them for now, as these formats aren't commonly used in games.
2024-02-02 18:24:15 -08:00
Sam Lantinga b8fe96fa81 Fixed build warning 2024-02-02 18:24:05 -08:00
Sam Lantinga 5d48f9a63a Added SDL_CopyProperties() 2024-02-02 15:09:12 -08:00
Sam Lantinga 9591b2cfb4 Finalized the SDL render API colorspaces
The renderer will always use the sRGB colorspace for drawing, and will default to the sRGB output colorspace. If you want blending in linear space and HDR support, you can select the scRGB output colorspace, which is supported by the direct3d11 and direct3d12
2024-02-02 13:13:53 -08:00
Simon McVittie 7c089f4e57 testautomation_math: Fix misleading log output
These originally checked for expected ± EPSILON as logged, but since
commit 880c6939 they check for expected ± max_err, where max_err may
need to be greater than EPSILON for very large expected results like
the ones in exp_regularCases().

Also, EPSILON is so small that the default precision of the %f format
(6 decimal places) would never actually have shown its effect, so log
it in scientific notation instead.

Fixes: 880c6939 "testautomation_math: do relative comparison + more precise correct trigonometric values"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-02 07:44:04 -08:00
Simon McVittie b66dba2a9d test: Don't accept results that are much less than expected
While looking at the other tests in this file, I noticed that instead
of checking for a result in the range of expected ± FLT_EPSILON as I
would have expected, these tests would accept any result strictly less
than expected + FLT_EPSILON, for example a wrong result that is very
large and negative. This is presumably not what was intended, so add
the SDL_fabs() that I assume was meant to be here.

Fixes: 474c8d00 "testautomation: don't do float equality tests"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-02 07:44:04 -08:00
Anonymous Maarten f1f9e27128 testautomation_math: do relative comparison + more precise correct trigonometric values
If the magnitude of the expected result is small, then we can safely
assume that the actual calculated result matches it to 10 decimal
places.

However, if the magnitude is very large, as it is for some of our exp()
tests, then 10 decimal places represents an unrealistically high level
of precision, for example 24 decimal digits for the test that is
expected to return approximately 6.6e14. IEEE 754 floating point only
has a precision of about 16 decimal digits, causing test failure on
x86 compilers that use an i387 80-bit extended-precision register for
the result and therefore get a slightly different answer.

To avoid this, scale the required precision with the magnitude of the
expected result, so that we accept a maximum error of either 10 decimal
places or 1 part in 1e10, whichever is greater.

[smcv: Added longer commit message explaining why we need this]
(cherry picked from commit 880c69392ae10c726fc97f17b6e5e2173f70b62f)
2024-02-02 07:44:04 -08:00
Simon McVittie babca704e0 testautomation: Don't expect exp to yield exact floating point results
In the Steam Runtime 1 'scout' environment, when compiling for i386
using the default gcc-4.6, Exp(34.125) matches the desired value to the
precision shown in the log (6 decimal places) but is not an exact match
for the desired value.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-02 07:44:04 -08:00
Sam Lantinga d04fea8b87 Even more miscellaneous gamepad buttons! 2024-02-01 20:34:05 -08:00
Sam Lantinga cb70e972e3 Added miscellaneous gamepad buttons for additional macro buttons on some controllers 2024-02-01 20:15:01 -08:00
Sam Lantinga ea0853d23d Added an HDR gradient test to testcolorspace 2024-02-01 15:36:49 -08:00
Sam Lantinga 90597aeaef HDR10 colorspace isn't currently supported
You can't do blending directly in PQ space, which means you have to create a scene render target in linear space and use shaders to convert PQ texture data to linear, etc. All of this is out of scope for the SDL 2D renderer at the moment.
2024-02-01 12:17:35 -08:00
Sam Lantinga 496ed01bdb Detect blending in HDR10 colorspace 2024-02-01 12:17:35 -08:00
Sam Lantinga 6f443e2aca Added support for the scRGB colorspace on D3D11 and D3D12 2024-01-31 18:07:00 -08:00
Sam Lantinga c1f97c8e07 Fixed testgeometry after color format change (thanks @sezero!) 2024-01-30 23:31:48 -08:00
Sam Lantinga f257eb4481 Added the concept of colorspace to the SDL renderer
This allows color operations to happen in linear space between sRGB input and sRGB output. This is currently supported on the direct3d11, direct3d12 and opengl renderers.

This is a good resource on blending in linear space vs sRGB space:
https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/

Also added testcolorspace to verify colorspace changes
2024-01-30 09:48:02 -08:00
Sam Lantinga 554f0625d3 Renderer colors now have floating point precision 2024-01-30 09:48:02 -08:00
Frank Praznik 344ec60f8f tests: Fix window centering test with Wayland display scaling mode
The usable fullscreen bounds need to be queried after window creation, as Wayland can send different usable bounds depending on the focused window's scaling mode.
2024-01-28 13:31:42 -05:00
Sam Lantinga 9f7eb6c4c1 Fixed testautomation log callback calling convention 2024-01-27 22:44:13 -08:00
Sam Lantinga 12bdb2b4d0 Added the environment variable SDL_LOGGING to control default log output 2024-01-27 19:30:22 -08:00
Sam Lantinga f66fe7e221 Replaced SDL_GetJoystickCaps() with joystick properties
Fixes https://github.com/libsdl-org/SDL/issues/8927
2024-01-27 15:11:52 -08:00
Sam Lantinga 3b55c7d1f4 Shortened SDL property names 2024-01-27 13:00:50 -08:00
Sam Lantinga 5ddd97062e Added test code to validate SDL_WaitEventTimeout()
You can enable this by defining TEST_WAITEVENTTIMEOUT
2024-01-25 06:29:15 -08:00
Ozkan Sezer 205c417f74 testgles2.c, testgles2_sdf.c: adjust for new SDL_PLATFORM_WINDOWS meaning. 2024-01-24 21:20:50 +03:00