Add JPEG XL screenshot capture to gamescope #2068
Open
+283
−79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a JPEG XL encoder and an option to select the image format used in screenshot capture.
The user can choose between AVIF (default) and JXL via the --screenshot-format parameter.
A JXL decoder was recently included into chromium and will land in stable in a few weeks.
Mozilla is working on including the same JXL decoder into Firefox.
Windows, macOS and Linux all have support for JXL.
JXL allows for the same HDR capture as AVIF, while being faster to encode and offering greater density.
I have previously compared AVIF to JXL in #1525.
In gamescope JXL encode at effort 2 is 2-4 times faster than AVIF.
At this effort it results in smaller filesizes and is still faster than AVIF, which uses AVIF_SPEED_FASTEST.
Theoretically, since JXL is faster and denser than PNG as well, JXL would be able to replace both entirely in gamescope at some point in the future.
Similar to AVIF, the JXL will always be 10 bit and lossless.
JXL also supports higher bit depths than AVIF, making scRGB 16 bit float capture theoretically possible.
A small selection of games I've compared AVIF and JXL in (1920x1080):
Deep Rock Galactic
Factorio
Holocure
To get the encode time I measured from start of the encoder to after the file is written. This code is still included at the moment, but can be removed.
The comments can be removed later, I just added them to explain some of the new code.