Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support color management protocols #8715

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Support color management protocols #8715

wants to merge 6 commits into from

Conversation

UjinT34
Copy link
Contributor

@UjinT34 UjinT34 commented Dec 14, 2024

Describe your PR, what does it fix/add?

Add support for color management protocols xx-color-management-v4 and frog-color-management-v1. Will only store and pass color management properties. The actual CM should be implemented by someone else with means to verify that it works as expected. Passing hdr metadata without processing should be enough for fullscreen gaming.

experimental:wide_color_gamut sets the colorspace to BT2020_RGB. Might not be needed.
experimental:xx_color_management_v4 enables both protocols. Requires restart.
experimental:hdr forces hdr in desktop mode. Will look weird without proper CM.

Works only with correctly parsed EDID CTA-861 block. Will not work with hdr data from DisplayID blocks.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Mostly copied code from other protocols. Might mess with pointers, have some redundant stuff and miss some bits.
Tested only the frog protocol. Most of the clients support both or frog only and will choose frog by default.

Is it ready for merging, or does it need work?

Ready. Requires hyprwm/aquamarine#112

  • xx-color-management-v4
  • frog-color-management-v1
  • send hdr metadata

@vaxerski
Copy link
Member

ref #4933

@vaxerski
Copy link
Member

I'd also mark this as draft

@UjinT34
Copy link
Contributor Author

UjinT34 commented Dec 15, 2024

Frog CM can be tested. Most of the gaming stuff https://wiki.archlinux.org/title/KDE#HDR should work the same. I use https://github.com/Zamundaaa/VK_hdr_layer

Will only work with successfully parsed EDID and fullscreen applications.

@vaxerski
Copy link
Member

idek how to test it or how to spot the difference. Only piece of equipment I have with hdr is my laptop

@UjinT34
Copy link
Contributor Author

UjinT34 commented Dec 15, 2024

AQ_TRACE=1 HYPRLAND_TRACE=1 and believe what logs say %)
Without the support hdr setting in games is not available. With incorrect support enabling hdr will result in obviously wrong colors (undersaturated/oversaturated/too dim/too bright). The tricky part is to spot slightly wrong colors. I guess some colorimetry equipment might be needed.
Laptop might not work hyprwm/aquamarine#116. Mine doesn't.

@vaxerski
Copy link
Member

well then I can't test. My monitors are old, garbage TN panels. No HDR here.

@abihf
Copy link

abihf commented Dec 16, 2024

Nice work @UjinT34

I tried mpv and Silent Hill 2, they seem work. But I need to manually set experimental:hdr=true . Also my second monitor isn't back to sdr after I disable the option.

I will try to compare the color with KDE later.

EDIT: I was wrong, I don't need to enable desktop hdr.

@TKasperczyk
Copy link

TKasperczyk commented Dec 18, 2024

I confirmed it's working in MPV using the following demo: https://4kmedia.org/lg-new-york-hdr-uhd-4k-demo/

Log samples:

[TRACE] ColorManagement supportsBT2020 true, supportsPQ true
[TRACE] ColorManagement primaries 0.677734375,0.3134765625 0.283203125,0.6484375 0.1484375,0.068359375 0.3125,0.3291015625
[TRACE] ColorManagement max avg 417.7095, min 0.12436535, max 417.7095, brightness 0.5
[LOG] [AQ] drm: Modesetting DP-2 with 2560x1440@143.91Hz
[TRACE] [AQ] drm: Committed a buffer, updating state
[TRACE] [AQ] drm: CDRMFB: buffer has drmfb attachment with fb 5c85274f8e20
[TRACE] [AQ] Connector blob id 115: clock 592000, 2560x1440, vrefresh 144, name: 2560x1440
[ERR] [AQ] atomic drm: setting hdr min 622, max 209, avg 209, content 209, primaries 33887,15674 14160,32422 7422,3418 33887,15625

I tested the video simultaneously in Hyprland and i3, switching between them to compare on the same monitor (AG322QC4). With hyprshade disabled, there was a subtle but noticeable difference - the colors were more vivid on Hyprland. To verify, I relaunched it from the main branch and performed the same comparison. This time, I observed no difference compared to i3, confirming that the changes made to aquamarine and hyprland were successful. Well done @UjinT34 !
Enabling experimental:hdr caused color distortion, as expected, so I kept it disabled.
GPU: GTX1080 with nvidia-dkms 565.77-2.

Regarding the last log entry in the sample, was AQ_LOG_ERROR used for debugging purposes? Relevant code part

@UjinT34 UjinT34 changed the title WIP Support color management protocols Support color management protocols Dec 18, 2024
@UjinT34
Copy link
Contributor Author

UjinT34 commented Dec 18, 2024

Regarding the last log entry in the sample, was AQ_LOG_ERROR used for debugging purposes? Relevant code part

Fixed it

RESOURCE->self = RESOURCE;
m_currentPreferred = RESOURCE;

m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UjinT34 g_pCompositor was not declared in this scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants