-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[windows] Identify SDR WCG screens as non HDR-capable #24689
Conversation
2b1236e
to
e3facc4
Compare
Freshened up the code, renamed a variable for clarity. Doc from MS hasn't improved in the meantime. In https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ne-wingdi-displayconfig_device_info_type there are additional values that I didn't notice before They seem interesting but the Windows 11 SDK 10.0.22621.0 bundled with Visual Studio doesn't have them or the structs they need to work. Not sure where to get a more recent SDK? An alternative is to change Kodi to call WinRT. Not sure what it takes and consequences. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved but I think this will cause regressions that you will have to take care of later.
For same reason we should not backport.
The safe way is the WinRT API, but do you have an idea what it would take? |
e3facc4
to
eb8b969
Compare
Pushed some changes using the WinRT API, made possible by a couple interop methods added in Win11 22H2 to retrieve a DisplayInformation object for a Win32 monitor or window. I had limited access to a Win11 system and could check that the IsAdvancedColorKindAvailable() API works to detect screens capable of HDR even with HDR off in Windows (Intel GPU). I don't know what happens on Xbox or UWP on Win11 though, it would help a lot if you could give it a try. Either IsAdvancedColorKindAvailable() works or we still need the original detection code based on DisplayManager(), that I kept around for now. Also tested on Win8 and Win10 and it doesn't prevent Kodi from starting and the usual Win32 path is followed successfully. |
59be259
to
4c07577
Compare
Windows build bot failure is likely due to a requirement for a more recent Windows SDK (PR builds fine locally with Windows 11 SDK 10.0.22621.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only initial review, not tested yet...
e863c49
to
c41a156
Compare
Tested on Xbox Series S and confirmed this code is working to detect HDR off but supported: // TODO: Combine with desktop case if works for Xbox
if (colorInfo.IsAdvancedColorKindAvailable(AdvancedColorKind::HighDynamicRange))
return HDR_STATUS::HDR_OFF;
else
return HDR_STATUS::HDR_UNSUPPORTED; This is very good a allows use same HDR detection code for x64 desktop (Windows 11 only) and Xbox EDIT: maybe detection code based on DisplayManager() can be moved for clarity to a separated method similar to GetWindowsHDRStatusWin32, maybe "GetWindowsHDRStatusUWP" or similar and only used in case of UWP but not in Xbox. This is only legacy case with no public usage because even .msix can be installed on Windows desktop is not available from MS Store. Then from main Call:
|
Added a commit to address yesterday's comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested also on Intel NUC with Windows 11 23H2 and no issues found.
Pushed a commit with requested changes and small refactor of advanced color kind logging. |
612fe4b
to
aabcffd
Compare
Squashed all commits except the SDK version requirement bump. |
Windows SDK also should be increased here:
and:
Commit with SDK bump should come first to not have intermediate broken state if someone builds commits one to one. |
Win 11 22621 (22H2) supports WCG screens and also has some interop functions with Win32 to use the new WinRT API for the detection. Unify the Win11 desktop and Xbox paths, kept the older code for older desktop and UWP desktop. The older code can also be used as fallback in case the new method doesn't work.
aabcffd
to
bfe89ee
Compare
Thanks for finding the cmake SDK version check, my text search missed it. |
Description
(description modified since first version of the PR, which attempted to do the same thing but using poorly documented Win32 API and educated guesses)
Starting with Windows 11 22H2, Windows supports a new type of screen, "Wide Color Gamut" (WCG) and interop methods were added to allow retrieving the type of screen (including WCG) using a winrt API.
That API also works with Xbox so a new unified code path was created, and the legacy methods for Win32 and UWP remain for now, but are isolated for easy removal eventually.
The WCG screens caused a problem with Win11 because the Win32 API used until now was confusing them with an HDR capable screen, and as a result Kodi would attempt to switch Windows HDR on/off when playing videos, with bad visual results. At this time there is no documented way to detect WCG screens with the Win32 API.
Motivation and context
Helps with issue #24615, misdetection of WCG screen as HDR.
Some screens have wide color support and an on/off hdr software switch.
No problem with the on position, detected as expected by Kodi as HDR capable screen and used as such.
In the off position however, Microsoft added support for non-hdr wcg screens in Windows 11 and recent AMD drivers seem to take advantage of that, resulting in incorrect HDR detection by Kodi due to the way it's reported by the Win32 API.
Attempting to use the WCG capabilities with standard dynamic range is beyond the scope of v21 but at least the screen could be detected as SDR, which allows tonemapping.
How has this been tested?
Win11/Intel works fine, Xbox works
The Win32 detection still works on Windows 8 and 10.
What is the effect on users?
Avoid incorrect switch to non-working HDR mode when the screen is in SDR mode.
Types of change
Checklist: