Commit graph

15 commits

Author SHA1 Message Date
Xaver Hugl
eaf7e9a3a2 core/colorspace: be more robust about edge cases
xyz -> xy and xy -> xyz conversions have divisions in them, so we need to
handle the edge cases of the divisor being zero. This can happen if an ICC
profile is invalid, or if the XYZ color space is used.
2024-08-23 10:45:46 +00:00
Xaver Hugl
f9e6ecd298 core/colorpipeline: improve optimization with differing reference luminances
This is done by
- fixing isFuzzyScalingOnly to not check the [3, 3] component, which is always 1
- making the comparison between transfer functions fuzzy, so small floating point
  errors don't prevent two practically identical functions to be optimized out
- switching manual optimizations to use addMatrix instead, which removes the
  matrix or replaces it with a multiplier

and the autotest is expanded to test transformations between color descriptions with
transfer functions and reference luminances that are just scaled versions of each
other
2024-08-19 16:39:11 +02:00
Xaver Hugl
e2c7cf2bb3 autotest/colorspaces: test identity transformations with bpc 2024-08-19 16:38:54 +02:00
Xaver Hugl
aa93f6ac55 autotests/colorspaces: add some test cases for black point compensation 2024-08-15 01:23:00 +00:00
Xaver Hugl
6f79597f13 core/colorspace: match default luminances with the Wayland protocol
It wasn't feasible to do it before, because it made SDR black far too bright, but
with black point compensation the result looks as users expect it
2024-08-15 01:23:00 +00:00
Xaver Hugl
418143a45b core/colorspace: move Colorimetry::toOther to ColorDescription
With some rendering intents we need to apply behavior based on brightness levels
or the SDR colorimetry
2024-08-12 11:46:32 +00:00
Xaver Hugl
833476a111 core/colorspace: add rendering intents
Rendering intents describe how to handle mapping between different colorspaces,
what to do with out of gamut values and what to do if the whitepoint doesn't match.
This way, clients can choose which behavior their content should get.
2024-08-12 11:46:32 +00:00
Xaver Hugl
6bd07ad6b3 backends/drm: remove the shadow buffer when possible, and reduce it to 10bpc when not
Using the custom values for min. and max. luminance in transfer functions, we can reduce the
ranges of values in the shadow buffer to be limited to [0, 1], and with that we can switch
from a floating point buffer back to a normalized format. As gamma 2.2 encoding is much more
efficient at storing color values, this also drops the buffer from 16bpc down to 10bpc.

Furthermore, this offloads the gamma 2.2 -> PQ conversion to KMS when possible, and then uses
the scanout buffer with gamma 2.2 encoding directly. This way the shadow buffer gets completely
skipped and performance and efficiency get improved a lot.

BUG: 491452
CCBUG: 477223
2024-08-09 15:18:43 +02:00
Xaver Hugl
2cbf4543fa autotests: add very basic color pipeline test
It just tests rec.709 <-> rec.2020 at 0%, 50% and 100% rec.709 luminance, to have
a very simple indicator for when something's gone really wrong while working on
color pipeline changes
2024-08-09 15:10:45 +02:00
Xaver Hugl
bea4d1064c core: add transfer function minimum and maximum luminance values
This redefines the transfer functions to have a custom luminance at encoded
value zero, and a custom luminance at encoded value 1, neither of which are
tied to the reference luminance, even for relative transfer functions.

The goal of that is that we can use a gamma 2.2 transfer function for the shadow
buffer, with the reference luminance being much lower than the maximum luminance.
For example, on an HDR screen you might have the reference luminance of 600 nits,
while the maximum luminance is 1000 nits. By representing this in gamma 2.2, we
can use a much smaller amount of bits per color to store the values than if we
used a linear transfer function. An additional benefit is that this way the values
in the buffer can be scaled by arbitrary amounts, for example to limit the range of
values to [0, 1], which can be represented in a normalized buffer
2024-08-09 15:10:45 +02:00
Xaver Hugl
706d604305 autotests: add a color pipeline test for identity transformations
If identity transformations aren't properly optimized out, we can have additional
rounding errors and reduced performance. This test ensures that doesn't happen
2024-07-09 20:10:47 +00:00
Xaver Hugl
de85867675 core: add a TransferFunction class and move transfer function functions in there
This way it's more obvious where to find them, and the class can be extended with more
functionality later, like transfer functions with parameters
2024-07-04 17:19:31 +02:00
Xaver Hugl
765cd82613 autotests/test_colorspaces: add an autotest for non-normalized primaries 2024-02-27 15:14:20 +00:00
Xaver Hugl
9c0085f5a9 colorspace: make sdr colorimetry not be about rec.2020 anymore
This was just done because of the wrong assumption that displays needed that
to show the full native gamut. That turned out to be an amdgpu bug though; with
that fixed, most of the 0-100% range is wildly oversaturated.
To make the slider more intuitive, this changes the sdr gamut wideness to instead
interpolate to the native display primaries as indicated by the EDID.
2024-01-31 13:23:03 +01:00
Xaver Hugl
6832aee3a2 autotests: add very basic ColorDescription mapping test 2023-12-22 20:25:44 +01:00