Commit Graph

14800 Commits (1e0bac288bcf53ee368dad510479e42320e87382)

Author SHA1 Message Date
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 f6f9468d84 Fixed warning C4701: potentially uninitialized local variable 'srcpixel' used 2024-02-01 21:24:11 -08:00
Sam Lantinga d383299779 Fixed build on older Windows SDK 2024-02-01 20:48:53 -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 d6a48e4958 Don't use the system iconv on Apple mobile platforms
Fixes https://github.com/libsdl-org/SDL/issues/8964
2024-02-01 15:53:27 -08:00
Sam Lantinga ea0853d23d Added an HDR gradient test to testcolorspace 2024-02-01 15:36:49 -08:00
Sam Lantinga dc607c666b Fixed creating HDR textures with SDL_CreateTexture() 2024-02-01 15:36:49 -08:00
SDL Wiki Bot dcfb069c75 Sync SDL3 wiki -> header 2024-02-01 20:18:29 +00:00
Sam Lantinga 7561116873 Added support for floating point texture formats 2024-02-01 12:17:35 -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 19dde63e7c Added a simple linear scale for tonemapped HDR to SDR surface conversion 2024-02-01 12:17:35 -08:00
Sam Lantinga fc35b7e121 Convert to sRGB if trying to create a texture from an HDR surface 2024-02-01 12:17:35 -08:00
Sam Lantinga c1f3c81003 Make the color primary conversion code reusable
Also added conversion from rec709 to rec2020 primaries
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 dd28ab0489 Added SDL_SetRenderDrawColorspace() and SDL_GetRenderDrawColorspace() 2024-02-01 12:17:35 -08:00
Sam Lantinga 9c8b47b726 Cache the draw color state in the software and PSP renderers
Converting the color from float is a bit expensive, so let's cache that state
2024-02-01 12:17:35 -08:00
Sam Lantinga dacfaa91b4 Make sure to round color values when converting to Uint8 2024-02-01 12:17:35 -08:00
Ozkan Sezer c00b6a8e20 SDL_kmsdrmvideo.c: clean-up includes, add clarifying note after 5ab879f 2024-02-01 11:04:10 +03:00
SDL Wiki Bot a4969e393e Sync SDL3 wiki -> header 2024-02-01 02:08:27 +00:00
Sam Lantinga 6f443e2aca Added support for the scRGB colorspace on D3D11 and D3D12 2024-01-31 18:07:00 -08:00
Sam Lantinga 12c31898c1 Update colors in SDL_RenderGeometryRaw() if we're doing interpolation in linear space
Testing: Modified testgeometry to clear the background to 0.5 and then changed the triangle color to 0.5, and verified that they were the same color when using the D3D11 renderer.
2024-01-31 11:02:45 -08:00
Sam Lantinga 77549dc91e Fixed some places using SDL_SetRenderDrawColor() instead of SDL_SetRenderDrawColorFloat() 2024-01-31 11:02:45 -08:00
Sam Lantinga 4b3c530dd1 Fixed out of bounds access
This can happen if we try to blit from a surface with an unknown pixel format
2024-01-31 09:55:52 -08:00
Sam Lantinga 3c45544a14 Added a slow blit function to handle large pixel formats and colorspace conversion 2024-01-31 09:50:46 -08:00
Sam Lantinga 49cc4c14e9 Use the default colorspace if we have to convert texture pixels 2024-01-31 09:50:46 -08:00
Sam Lantinga c1f97c8e07 Fixed testgeometry after color format change (thanks @sezero!) 2024-01-30 23:31:48 -08:00
Frank Praznik 482a27bc00 wayland: Throttle to 20hz if the frame callback never fires
Matches SDL2, and should be enough to keep most games from desyncing/timing out.

A proper fix for FIFO presentation without the frame callback mess is being worked on upstream, so this whole hack should be rendered obsolete in the near future.
2024-01-30 17:12:20 -05:00
Amun 4a759b340f Fixes in SDL_ColorSpace (SDL_pixels.h) 2024-01-30 11:16:53 -08:00
Frank Praznik 9462eec57b pipewire: Don't assert if the default capture device is a sink or vice versa
When no source devices are connected, the default source string can contain a sink name. If the default source and sink match, it will be caught as a sink device first and handled correctly, but if the default sink/source don't match, which happens when the sink is an HDMI output and the source is still an onboard audio chipset output name, an assert can result since the requested source device won't be flagged as a capture device. Rather than asserting, simply don't assign default devices that don't match the correct capabilities, as it's not an uncommon scenario and can be handled gracefully.

Additionally, if asserting is a no-op in release mode, sinks can be returned as sources and vice versa, which is incorrect.
2024-01-30 13:32:22 -05:00
SDL Wiki Bot d15fb9e063 Sync SDL3 wiki -> header 2024-01-30 17:49:26 +00: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
Francisco Javier Trujillo Mata da8fc70a83 Fixing viewport 2024-01-29 20:41:25 -08:00
Francisco Javier Trujillo Mata 851c1a5e9c Fix scissor usage 2024-01-29 20:41:25 -08:00
Francisco Javier Trujillo Mata dc35ee9d54 Fix color 2024-01-29 20:41:25 -08:00
Sam Lantinga 61a3a163db Fixed typo (thanks @Akaricchi!) 2024-01-29 18:48:41 -08:00
SDL Wiki Bot 7fbd85ad5c Sync SDL3 wiki -> header 2024-01-29 02:25:21 +00:00
Sam Lantinga 61b5c38e6e Added the initial concept of colorspace to SDL 2024-01-28 18:24:39 -08:00
Xander a3bfd5329c Fix broken mingw i686 buildscript 2024-01-28 17:29:33 -08:00
Xander 59d7dd3615 Fix broken mingw x86_64 buildscript 2024-01-28 17:29:33 -08:00
Frank Praznik fbf10afb31 wayland: Consolidate window creation logic
The fractional scale manager and viewport are both created for a surface under the same circumstances, so consolidate the logic.
2024-01-28 18:15:39 -05:00
Frank Praznik 2e96307b27 wayland: Always create a viewport for the surface, if possible
Toggling viewports on and off can cause visual anomalies such as flicker when moving windows between displays on a mixed-DPI configuration or toggling the scaled fullscreen modes. If the viewport protocol is avilable, always create a viewport for the surface, unless it is an unscaled external surface, in which case the surface should be left untouched as an application may wish to attach its own viewport or use integer scaling.

This allows for the removal of several helper functions as well.
2024-01-28 17:52:35 -05:00
Frank Praznik 94240c197d docs: Hint envvars needs to use the hint string, not the macro name 2024-01-28 15:12:03 -05:00
SDL Wiki Bot 00a8ca403e Sync SDL3 wiki -> header 2024-01-28 18:32:23 +00:00
Frank Praznik fbebbab90d wayland: Only set the explicit logical window size when using display scaling
Otherwise, the standard width/height is already in points/screen units.
2024-01-28 13:31:42 -05:00
Frank Praznik 879ba46ade wayland: Make sure the logical window size can't go to zero.
libdecor can send a size of zero as a valid value, the use of which will close the window. Make sure the minimum width/height are clamped to a minimum of 1.
2024-01-28 13:31:42 -05:00