drm: Add some chicken bits for color pipeline

This commit is contained in:
Joshua Ashton 2023-04-21 00:06:58 +01:00
parent 7e37ab2ff6
commit ff3e3b188c

View file

@ -1981,6 +1981,11 @@ static bool is_liftoff_caching_enabled()
return !disabled;
}
bool g_bDisableShaperAnd3DLUT = false;
bool g_bDisableDegamma = false;
bool g_bDisableRegamma = false;
bool g_bDisableBlendTF = false;
static int
drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, bool needs_modeset )
{
@ -2048,12 +2053,29 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
{
drm_valve1_transfer_function degamma_tf = colorspace_to_plane_degamma_tf( entry.layerState[i].colorspace );
drm_valve1_transfer_function shaper_tf = colorspace_to_plane_shaper_tf( entry.layerState[i].colorspace );
if (!g_bDisableDegamma)
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", degamma_tf );
else
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", 0 );
if ( !g_bDisableShaperAnd3DLUT )
{
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_LUT", drm->pending.shaperlut_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ] );
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_TF", shaper_tf );
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_LUT3D", drm->pending.lut3d_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ] );
// Josh: See shaders/colorimetry.h colorspace_blend_tf if you have questions as to why we start doing sRGB for BLEND_TF despite potentially working in Gamma 2.2 space prior.
}
else
{
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_LUT", 0 );
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_TF", 0 );
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_LUT3D", 0 );
}
if (!g_bDisableBlendTF)
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_BLEND_TF", drm->pending.output_tf );
else
liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_BLEND_TF", 0 );
}
}
else
@ -2166,6 +2188,8 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
}
if ( drm_supports_color_mgmt( &g_DRM ) && frameInfo->applyOutputColorMgmt )
{
if ( !g_bDisableRegamma )
{
drm->pending.output_tf = g_bOutputHDREnabled
? DRM_VALVE1_TRANSFER_FUNCTION_PQ
@ -2175,6 +2199,11 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
{
drm->pending.output_tf = DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
}
}
else
{
drm->pending.output_tf = DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
}
uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK;