Browse Source

testcolorspace: show a reasonable HDR gradient on Wayland

On some Wayland configurations, the SDR white level is 203 nits and the max luminance is 10000 nits, and HDR content in the PQ range is mapped by the compositor into the actual display capabilities. We don't want to show an HDR gradient up to 10000 nits, so let's cap it to ~1000 nits in this case.
Sam Lantinga 1 month ago
parent
commit
9f4a1215e2
1 changed files with 6 additions and 0 deletions
  1. 6 0
      test/testcolorspace.c

+ 6 - 0
test/testcolorspace.c

@@ -85,6 +85,12 @@ static void UpdateHDRState(void)
         }
         SDR_white_level = SDL_GetFloatProperty(props, SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT, 1.0f);
         HDR_headroom = SDL_GetFloatProperty(props, SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT, 1.0f);
+		if (((SDR_white_level * 80.0f) * HDR_headroom) == 10000.0f) {
+			// The system is advertising the PQ luminance range (10000 nits)
+			// and tone mapping into the actual display capabilities.
+			// Let's use a more reasonable range for the gradient test.
+			HDR_headroom = 5.0f;
+		}
     } else {
         SDR_white_level = 1.0f;
         HDR_headroom = 1.0f;