Skip to content

Commit 7a8adcf

Browse files
committed
Merge pull request #117913 from allenwp/hdr-output-allow-request
Fix behavior of `window_is_hdr_output_supported` for Wayland and adjust warnings.
2 parents 4d794c4 + 4309120 commit 7a8adcf

5 files changed

Lines changed: 73 additions & 13 deletions

File tree

drivers/apple_embedded/display_server_apple_embedded.mm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,18 +853,32 @@ _FORCE_INLINE_ int _convert_utf32_offset_to_utf16(const String &p_existing_text,
853853
}
854854

855855
bool DisplayServerAppleEmbedded::window_is_hdr_output_supported(DisplayServerEnums::WindowID p_window) const {
856+
bool renderer_supports_hdr_output = false;
856857
#if defined(RD_ENABLED)
857-
if (rendering_device && !rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
858-
return false;
858+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
859+
renderer_supports_hdr_output = true;
859860
}
860861
#endif
862+
if (!renderer_supports_hdr_output) {
863+
return false;
864+
}
865+
861866
return _screen_hdr_is_supported();
862867
}
863868

864869
void DisplayServerAppleEmbedded::window_request_hdr_output(const bool p_enabled, DisplayServerEnums::WindowID p_window) {
870+
if (p_enabled) {
871+
bool renderer_supports_hdr_output = false;
865872
#if defined(RD_ENABLED)
866-
ERR_FAIL_COND_MSG(p_enabled && rendering_device && !rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT), "HDR output is not supported by the rendering device.");
873+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
874+
renderer_supports_hdr_output = true;
875+
}
867876
#endif
877+
if (!renderer_supports_hdr_output) {
878+
WARN_PRINT("HDR output requested, but is not supported by the renderer or rendering device driver.");
879+
return;
880+
}
881+
}
868882

869883
edr_requested = p_enabled;
870884
_update_hdr_output(false);

platform/linuxbsd/wayland/display_server_wayland.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,34 @@ void DisplayServerWayland::_window_update_hdr_state(WindowData &p_window) {
15351535

15361536
bool DisplayServerWayland::window_is_hdr_output_supported(DisplayServerEnums::WindowID p_window_id) const {
15371537
ERR_FAIL_COND_V(!windows.has(p_window_id), false);
1538+
bool renderer_supports_hdr_output = false;
1539+
#if defined(RD_ENABLED)
1540+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
1541+
renderer_supports_hdr_output = true;
1542+
}
1543+
#endif
1544+
if (!renderer_supports_hdr_output) {
1545+
return false;
1546+
}
1547+
15381548
const WindowData &wd = windows[p_window_id];
15391549

15401550
return wd.color_profile.target_max_luminance > wd.color_profile.reference_luminance;
15411551
}
15421552

15431553
void DisplayServerWayland::window_request_hdr_output(const bool p_enabled, DisplayServerEnums::WindowID p_window_id) {
1554+
if (p_enabled) {
1555+
bool renderer_supports_hdr_output = false;
15441556
#if defined(RD_ENABLED)
1545-
ERR_FAIL_COND_MSG(p_enabled && !(rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)), "HDR output is not supported by the rendering device.");
1557+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
1558+
renderer_supports_hdr_output = true;
1559+
}
15461560
#endif
1561+
if (!renderer_supports_hdr_output) {
1562+
WARN_PRINT("HDR output requested, but is not supported by the renderer or rendering device driver.");
1563+
return;
1564+
}
1565+
}
15471566

15481567
ERR_FAIL_COND(!windows.has(p_window_id));
15491568
WindowData &wd = windows[p_window_id];

platform/macos/display_server_macos_base.mm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,16 @@
590590
_THREAD_SAFE_METHOD_
591591

592592
ERR_FAIL_COND_V(!has_window(p_window), false);
593+
bool renderer_supports_hdr_output = false;
593594
#if defined(RD_ENABLED)
594-
if (rendering_device && !rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
595-
return false;
595+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
596+
renderer_supports_hdr_output = true;
596597
}
597598
#endif
599+
if (!renderer_supports_hdr_output) {
600+
return false;
601+
}
602+
598603
CGFloat max_potential_edr;
599604
window_get_edr_values(p_window, &max_potential_edr, nullptr);
600605
return max_potential_edr > 1.0f;
@@ -604,9 +609,18 @@
604609
_THREAD_SAFE_METHOD_
605610

606611
ERR_FAIL_COND(!has_window(p_window));
612+
if (p_enabled) {
613+
bool renderer_supports_hdr_output = false;
607614
#if defined(RD_ENABLED)
608-
ERR_FAIL_COND_MSG(p_enabled && rendering_device && !rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT), "HDR output is not supported by the rendering device.");
615+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
616+
renderer_supports_hdr_output = true;
617+
}
609618
#endif
619+
if (!renderer_supports_hdr_output) {
620+
WARN_PRINT("HDR output requested, but is not supported by the renderer or rendering device driver.");
621+
return;
622+
}
623+
}
610624

611625
HDROutput &hdr = _get_hdr_output(p_window);
612626
hdr.requested = p_enabled;

platform/windows/display_server_windows.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4773,11 +4773,15 @@ bool DisplayServerWindows::window_is_hdr_output_supported(DisplayServerEnums::Wi
47734773
_THREAD_SAFE_METHOD_
47744774

47754775
ERR_FAIL_COND_V(!windows.has(p_window), false);
4776+
bool renderer_supports_hdr_output = false;
47764777
#if defined(RD_ENABLED)
4777-
if (rendering_device && !rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
4778-
return false; // HDR output is not supported by the rendering device.
4778+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
4779+
renderer_supports_hdr_output = true;
47794780
}
47804781
#endif
4782+
if (!renderer_supports_hdr_output) {
4783+
return false;
4784+
}
47814785

47824786
// The window supports HDR if the screen it is on supports HDR.
47834787
DisplayServerWindows::ScreenHdrData data = _get_screen_hdr_data(p_window, false);
@@ -4788,9 +4792,18 @@ void DisplayServerWindows::window_request_hdr_output(const bool p_enable, Displa
47884792
_THREAD_SAFE_METHOD_
47894793

47904794
ERR_FAIL_COND(!windows.has(p_window));
4795+
if (p_enable) {
4796+
bool renderer_supports_hdr_output = false;
47914797
#if defined(RD_ENABLED)
4792-
ERR_FAIL_COND_EDMSG(p_enable && (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) == false, "HDR output is not supported by the rendering device.");
4798+
if (rendering_device && rendering_device->has_feature(RenderingDevice::Features::SUPPORTS_HDR_OUTPUT)) {
4799+
renderer_supports_hdr_output = true;
4800+
}
47934801
#endif
4802+
if (!renderer_supports_hdr_output) {
4803+
WARN_PRINT("HDR output requested, but is not supported by the renderer or rendering device driver.");
4804+
return;
4805+
}
4806+
}
47944807

47954808
WindowData &wd = windows[p_window];
47964809
wd.hdr_output_requested = p_enable;

servers/display/display_server.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ bool DisplayServer::window_is_hdr_output_supported(DisplayServerEnums::WindowID
13041304

13051305
void DisplayServer::window_request_hdr_output(const bool p_enable, DisplayServerEnums::WindowID p_window) {
13061306
if (p_enable) {
1307-
WARN_PRINT_ED("HDR output is not supported by this display server.");
1307+
WARN_PRINT("HDR output requested, but it is not supported by this display server.");
13081308
}
13091309
}
13101310

@@ -1317,7 +1317,7 @@ bool DisplayServer::window_is_hdr_output_enabled(DisplayServerEnums::WindowID p_
13171317
}
13181318

13191319
void DisplayServer::window_set_hdr_output_reference_luminance(const float p_reference_luminance, DisplayServerEnums::WindowID p_window) {
1320-
WARN_PRINT_ED("HDR output is not supported by this display server.");
1320+
WARN_PRINT("Attempting to set reference luminance, but HDR output is not supported by this display server.");
13211321
}
13221322

13231323
float DisplayServer::window_get_hdr_output_reference_luminance(DisplayServerEnums::WindowID p_window) const {
@@ -1329,7 +1329,7 @@ float DisplayServer::window_get_hdr_output_current_reference_luminance(DisplaySe
13291329
}
13301330

13311331
void DisplayServer::window_set_hdr_output_max_luminance(const float p_max_luminance, DisplayServerEnums::WindowID p_window) {
1332-
WARN_PRINT_ED("HDR output is not supported by this display server.");
1332+
WARN_PRINT("Attempting to set max luminance, but HDR output is not supported by this display server.");
13331333
}
13341334

13351335
float DisplayServer::window_get_hdr_output_max_luminance(DisplayServerEnums::WindowID p_window) const {

0 commit comments

Comments
 (0)