Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drm: fix wrong degamma/shaper TFs on NV12 #1507

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/Backends/DRMBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ gamescope::ConVar<bool> cv_drm_debug_disable_color_range( "drm_debug_disable_col
gamescope::ConVar<bool> cv_drm_debug_disable_explicit_sync( "drm_debug_disable_explicit_sync", false, "Force disable explicit sync on the DRM backend." );
gamescope::ConVar<bool> cv_drm_debug_disable_in_fence_fd( "drm_debug_disable_in_fence_fd", false, "Force disable IN_FENCE_FD being set to avoid over-synchronization on the DRM backend." );

// HACK:
// Workaround for AMDGPU bug on SteamOS 3.6 right now.
// Using a Shaper or 3D LUT results in the commit failing, and we really want
// NV12 direct scanout so we can get GFXOFF.
// The compromise here is that colors may look diff to when we composite due to
// lack of 3D LUT, etc.
// TODO: Come back to me on the kernel side after figuring out what broke
// since we moved to the upstream properites and a bunch of work happened.
gamescope::ConVar<bool> cv_drm_hack_nv12_color_mgmt_fix( "drm_hack_nv12_color_mgmt_fix", true, "If using NV12, disable explicit degamma + shaper + 3D LUT" );

namespace gamescope
{
std::tuple<int32_t, int32_t, int32_t> GetKernelVersion()
Expand Down Expand Up @@ -2457,23 +2447,17 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
//
// Doing LINEAR/DEFAULT here introduces banding so... this is the best way.
// (sRGB DEGAMMA does NOT work on YUV planes!)
degamma_tf = AMDGPU_TRANSFER_FUNCTION_BT709_OETF;
shaper_tf = AMDGPU_TRANSFER_FUNCTION_BT709_INV_OETF;
degamma_tf = AMDGPU_TRANSFER_FUNCTION_BT709_INV_OETF;
shaper_tf = AMDGPU_TRANSFER_FUNCTION_BT709_OETF;
}

bool bUseDegamma = !cv_drm_debug_disable_degamma_tf;
if ( bYCbCr && cv_drm_hack_nv12_color_mgmt_fix )
bUseDegamma = false;

if ( bUseDegamma )
liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_DEGAMMA_TF", degamma_tf );
else
liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_DEGAMMA_TF", 0 );

bool bUseShaperAnd3DLUT = !cv_drm_debug_disable_shaper_and_3dlut;
if ( bYCbCr && cv_drm_hack_nv12_color_mgmt_fix )
bUseShaperAnd3DLUT = false;

if ( bUseShaperAnd3DLUT )
{
liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_LUT", drm->pending.shaperlut_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ]->GetBlobValue() );
Expand Down
Loading