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

[UWP] Prefere 60Hz display mode instead of 120Hz #4798

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions starboard/shared/uwp/application_uwp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const Platform::String ^ kGenericPnpMonitorAqs = ref new Platform::String(
L"True");

const uint32_t kYuv420BitsPerPixelForHdr10Mode = 24;
const uint32_t kHdr4kRefreshRateMaximum = 60;
const uint32_t kRefreshRateMaximum = 60;
const uint32_t k4kResolutionWidth = 3840;
const uint32_t k4kResolutionHeight = 2160;

Expand Down Expand Up @@ -976,6 +976,8 @@ void ApplicationUwp::UpdateDisplayPreferredMode() {
ScopedLock lock(preferred_display_mode_mutex_);
preferred_display_mode_hdmi_ = nullptr;
preferred_display_mode_hdr_ = nullptr;
Windows::Graphics::Display::Core::HdmiDisplayMode ^
preferred_display_mode_sdr_ = nullptr;
if (!ApiInformation::IsTypePresent(
"Windows.Graphics.Display.Core.HdmiDisplayInformation")) {
return;
Expand All @@ -988,13 +990,23 @@ void ApplicationUwp::UpdateDisplayPreferredMode() {

preferred_display_mode_hdmi_ = hdmi_display_info->GetCurrentDisplayMode();
for (auto mode : hdmi_display_info->GetSupportedDisplayModes()) {
// 120Hz is not supported in UWP apps even though the app can select 120Hz display mode.
// Microsoft Support recommend that UWPs do not select 120Hz display mode.
if (mode->RefreshRate > kRefreshRateMaximum) {
continue;
}
// Check that resolution matches the preferred display mode.
if (mode->ResolutionWidthInRawPixels !=
preferred_display_mode_hdmi_->ResolutionWidthInRawPixels ||
mode->ResolutionHeightInRawPixels !=
preferred_display_mode_hdmi_->ResolutionHeightInRawPixels) {
continue;
}
if (preferred_display_mode_hdmi_->RefreshRate > kRefreshRateMaximum &&
(!preferred_display_mode_sdr_ ||
preferred_display_mode_sdr_->RefreshRate < mode->RefreshRate)) {
preferred_display_mode_sdr_ = mode;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In theory it could happen that we don't find any different mode so preferred_display_mode_hdmi_ would have 120Hz on the end anyways but in practice, I think it's not possible (if device support 120Hz it should also support 60Hz).

to cover it we would need use 60Hz as a default refresh rate:
https://github.com/youtube/cobalt/blob/25.lts.1%2B/starboard/shared/uwp/application_uwp.h#L145

}
// Verify HDR metadata and transfer function are supported.
if (!mode->Is2086MetadataSupported || !mode->IsSmpte2084Supported) {
continue;
Expand All @@ -1004,18 +1016,14 @@ void ApplicationUwp::UpdateDisplayPreferredMode() {
mode->ColorSpace != HdmiDisplayColorSpace::BT2020) {
continue;
}
// We don't serve 4k HDR videos over 60fps, skipping display modes that will
// consume more power than needed.
if (mode->ResolutionWidthInRawPixels >= k4kResolutionWidth &&
mode->ResolutionHeightInRawPixels >= k4kResolutionHeight &&
mode->RefreshRate > kHdr4kRefreshRateMaximum) {
continue;
}
if (!preferred_display_mode_hdr_ ||
preferred_display_mode_hdr_->RefreshRate < mode->RefreshRate) {
preferred_display_mode_hdr_ = mode;
}
}
preferred_display_mode_hdmi_ = preferred_display_mode_sdr_
? preferred_display_mode_sdr_
: preferred_display_mode_hdmi_;
Comment on lines +1024 to +1026
Copy link
Collaborator Author

@MarekLuxoft MarekLuxoft Jan 30, 2025

Choose a reason for hiding this comment

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

In theory if we change display mode, we should also set new currently mode:
SetCurrentDisplayMode
but we change on the same resolution, so I didn't observe any side effect of those changes (and omitting SetCurrentDisplayMode)

}

bool ApplicationUwp::DispatchNextEvent() {
Expand Down
Loading