Skip to content

Commit 9416ca9

Browse files
matte-schwartzmisyltoad
authored andcommitted
DRMBackend: Fix HDR static metadata creation for PQ EOTF via lua config
The HDR10 infoframe creation was nested inside the EDID parsing block, so it only ran when HDR info came from the EDID. If a PQ EOTF was set via lua config, bHasKnownHDRInfo would be true, the EDID block would be skipped, and pDefaultMetadataBlob would never be created. Move the infoframe creation outside the EDID parsing block and gate it on HDR10 so the metadata is created whenever PQ output is configured, regardless of whether the HDR info came from lua config or EDID. We still use the EDID metadata when undefined in the lua config, or when there is no config for a PQ-compatible display.
1 parent c4bc440 commit 9416ca9

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

src/Backends/DRMBackend.cpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,38 +2483,41 @@ namespace gamescope
24832483
pHDRStaticMetadata->desired_content_min_luminance
24842484
? nits_to_u16_dark( pHDRStaticMetadata->desired_content_min_luminance )
24852485
: nits_to_u16_dark( 0.0f );
2486-
2487-
// Generate a default HDR10 infoframe.
2488-
hdr_output_metadata defaultHDRMetadata{};
2489-
hdr_metadata_infoframe *pInfoframe = &defaultHDRMetadata.hdmi_metadata_type1;
2490-
2491-
// To be filled in by the app based on the scene, default to desired_content_max_luminance
2492-
//
2493-
// Using display's max_fall for the default metadata max_cll to avoid displays
2494-
// overcompensating with tonemapping for SDR content.
2495-
uint16_t uDefaultInfoframeLuminances = m_Mutable.HDR.uMaxFrameAverageLuminance;
2496-
2497-
pInfoframe->display_primaries[0].x = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.r.x );
2498-
pInfoframe->display_primaries[0].y = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.r.y );
2499-
pInfoframe->display_primaries[1].x = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.g.x );
2500-
pInfoframe->display_primaries[1].y = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.g.y );
2501-
pInfoframe->display_primaries[2].x = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.b.x );
2502-
pInfoframe->display_primaries[2].y = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.b.y );
2503-
pInfoframe->white_point.x = color_xy_to_u16( m_Mutable.DisplayColorimetry.white.x );
2504-
pInfoframe->white_point.y = color_xy_to_u16( m_Mutable.DisplayColorimetry.white.y );
2505-
pInfoframe->max_display_mastering_luminance = uDefaultInfoframeLuminances;
2506-
pInfoframe->min_display_mastering_luminance = m_Mutable.HDR.uMinContentLightLevel;
2507-
pInfoframe->max_cll = uDefaultInfoframeLuminances;
2508-
pInfoframe->max_fall = uDefaultInfoframeLuminances;
2509-
pInfoframe->eotf = HDMI_EOTF_ST2084;
2510-
2511-
m_Mutable.HDR.pDefaultMetadataBlob = GetBackend()->CreateBackendBlob( defaultHDRMetadata );
25122486
}
25132487
else
25142488
{
25152489
m_Mutable.HDR.bExposeHDRSupport = false;
25162490
}
25172491
}
2492+
2493+
// Generate a default HDR10 infoframe.
2494+
if ( m_Mutable.HDR.IsHDR10() )
2495+
{
2496+
hdr_output_metadata defaultHDRMetadata{};
2497+
hdr_metadata_infoframe *pInfoframe = &defaultHDRMetadata.hdmi_metadata_type1;
2498+
2499+
// To be filled in by the app based on the scene, default to desired_content_max_luminance
2500+
//
2501+
// Using display's max_fall for the default metadata max_cll to avoid displays
2502+
// overcompensating with tonemapping for SDR content.
2503+
uint16_t uDefaultInfoframeLuminances = m_Mutable.HDR.uMaxFrameAverageLuminance;
2504+
2505+
pInfoframe->display_primaries[0].x = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.r.x );
2506+
pInfoframe->display_primaries[0].y = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.r.y );
2507+
pInfoframe->display_primaries[1].x = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.g.x );
2508+
pInfoframe->display_primaries[1].y = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.g.y );
2509+
pInfoframe->display_primaries[2].x = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.b.x );
2510+
pInfoframe->display_primaries[2].y = color_xy_to_u16( m_Mutable.DisplayColorimetry.primaries.b.y );
2511+
pInfoframe->white_point.x = color_xy_to_u16( m_Mutable.DisplayColorimetry.white.x );
2512+
pInfoframe->white_point.y = color_xy_to_u16( m_Mutable.DisplayColorimetry.white.y );
2513+
pInfoframe->max_display_mastering_luminance = uDefaultInfoframeLuminances;
2514+
pInfoframe->min_display_mastering_luminance = m_Mutable.HDR.uMinContentLightLevel;
2515+
pInfoframe->max_cll = uDefaultInfoframeLuminances;
2516+
pInfoframe->max_fall = uDefaultInfoframeLuminances;
2517+
pInfoframe->eotf = HDMI_EOTF_ST2084;
2518+
2519+
m_Mutable.HDR.pDefaultMetadataBlob = GetBackend()->CreateBackendBlob( defaultHDRMetadata );
2520+
}
25182521
}
25192522

25202523
/////////////////////////

0 commit comments

Comments
 (0)