From ff3e3b188cd77758a360369621fb42a164afc884 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Fri, 21 Apr 2023 00:06:58 +0100 Subject: [PATCH] drm: Add some chicken bits for color pipeline --- src/drm.cpp | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index 851d2ca..079fb30 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -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 ); - liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", degamma_tf ); - 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. - liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_BLEND_TF", drm->pending.output_tf ); + 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 @@ -2167,9 +2189,16 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI if ( drm_supports_color_mgmt( &g_DRM ) && frameInfo->applyOutputColorMgmt ) { - drm->pending.output_tf = g_bOutputHDREnabled - ? DRM_VALVE1_TRANSFER_FUNCTION_PQ - : DRM_VALVE1_TRANSFER_FUNCTION_SRGB; + if ( !g_bDisableRegamma ) + { + drm->pending.output_tf = g_bOutputHDREnabled + ? DRM_VALVE1_TRANSFER_FUNCTION_PQ + : DRM_VALVE1_TRANSFER_FUNCTION_SRGB; + } + else + { + drm->pending.output_tf = DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT; + } } else {