systemservice: query host display luminance through DXGI #1460
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1460
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1460/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ArtyomZabroda on GitHub · 2026-10-12 16:53 UTC · original
ArtyomZabroda:main→main· +70 −4 · 4 files · 1 commits · merged 2026-11-04 22:37 UTCProblem
SystemServiceGetHdrToneMapLuminance always returns hardcoded values instead of the host display's luminance:
max_full_frame_tone_map_luminance = 80.0f
max_tone_map_luminance = 1000.0f
min_tone_map_luminance = 0.0f
Games use these values for HDR tone mapping, so a full-frame limit of 80 nits makes the HDR image look dim.
Changes
AI Disclosure
This PR was written with the help of Claude Code. I reviewed the code.
Testing
Tested on Windows with Astro Bot with HDR enabled:
@coderabbitai[bot] on GitHub · 2026-10-12 16:58 UTC · original · edited 2026-11-04 22:26 UTC
Walkthrough
Windows builds now link DXGI for the emulator and full-emulator test targets. The window layer retrieves and caches luminance values for the display containing the SDL window, with refreshes after window creation and display or HDR-state changes.
SystemServiceGetHdrToneMapLuminancenow returns those values instead of fixed values.Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Low · up to
0ded0A window spanning differently aligned displays may use the wrong display’s luminance values. This is a bounded issue to address or accept before merging.
Pre-merge checks:
4 ·
1
Full details: Title check
Explanation
The title names the main change: the SystemService HDR tone-map luminance is now read from the host display through DXGI. The changeset adds DXGI luminance queries in window.cpp and switches SystemServiceGetHdrToneMapLuminance to use the queried values, so the title matches the primary change.
Full details: Description check
Explanation
The description explains the problem (hardcoded HDR tone-map luminance values), the Windows DXGI approach with caching and event-driven refresh, the logging behavior, the Linux/macOS limitation, and the testing performed. This matches the changeset, which adds DXGI luminance support in window.cpp, the DisplayLuminance API in window.h, and the updated SystemServiceGetHdrToneMapLuminance in libSystemService.cpp.
Full details: Docstring Coverage
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 3 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@coderabbitai[bot] on GitHub · 2026-10-12 16:59 UTC · original
On
src/graphics/presentation/window/displayLuminance.cppline 33 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9044
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11897
🌐 Web query:
Microsoft DXGI IDXGIAdapter1 EnumAdapters1 IDXGIAdapter EnumOutputs DXGI_ERROR_NOT_CURRENTLY_AVAILABLE Session 0 output parameter failure contract💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8064
Check both DXGI HRESULTs before using the COM pointers.
EnumAdapters1andEnumOutputscontinue the loops for every result exceptDXGI_ERROR_NOT_FOUND. A different failure can leaveadapteroroutputnull or stale afterRelease(). The following dereferences can then crash the process.EnumOutputsdocumentsDXGI_ERROR_NOT_CURRENTLY_AVAILABLEfor Session 0.WindowInitreachesRefreshDisplayLuminance()after creating the Windows window, and display events call it again.Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-12 16:59 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
2be4a21d-4a0c-4f12-b838-0f2eea8cb091📥 Commits
Reviewing files that changed from the base of the PR and between
df5b9b92beand ff2964a82d7091e231c75213a61d7faeef1a7701.📒 Files selected for processing (6)
CMakeLists.txtsrc/graphics/presentation/window.hsrc/graphics/presentation/window/displayLuminance.cppsrc/graphics/presentation/window/window.cppsrc/graphics/presentation/window/windowInternal.hsrc/libs/libSystemService.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Ebolivar001 on GitHub · 2026-10-12 17:06 UTC · original · approved these changes
@ -137,0 +169,4 @@DXGI_OUTPUT_DESC1 desc {};DisplayLuminance luminance;if (GetOutputDesc(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &desc) &&@coderabbitai[bot] on GitHub · 2026-11-04 22:26 UTC · original
Select the monitor using SDL’s window-display rule.
When a window straddles differently aligned monitors, SDL can associate it with the display containing its center while
MonitorFromWindowselects the monitor with the largest area of intersection. The cache can then hold luminance for the other display afterSDL_EVENT_WINDOW_DISPLAY_CHANGED, andSystemServiceGetHdrToneMapLuminancereturns those values until another refresh. Select the monitor containing the window’s center so the DXGI lookup matches SDL’s display-change event. (wiki.libsdl.org)@coderabbitai[bot] on GitHub · 2026-11-04 22:26 UTC · original · reviewed
Actionable comments posted: 1
dcd8189f-a9dc-4434-a0cc-3c390cdd5a0dReviewing files that changed from the base of the PR and between 0f73ec233047b8e681b02d8c2818750b1929bf80 and
0ded0f3fc7.CMakeLists.txtsrc/graphics/presentation/window.hsrc/graphics/presentation/window/window.cppsrc/libs/libSystemService.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.