From 9d61912b0aed7fb1f539a6e0bec9ce9010118282 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 22 Jun 2024 03:59:59 +0100 Subject: [PATCH] rendervulkan: Fix NV12 colorspace producing washed out colours --- src/main.cpp | 4 ++-- src/rendervulkan.hpp | 2 +- src/shaders/cs_composite_blit.comp | 2 +- src/shaders/cs_composite_blur.comp | 2 +- src/shaders/cs_composite_blur_cond.comp | 2 +- src/shaders/cs_composite_rcas.comp | 2 +- src/shaders/cs_gaussian_blur_horizontal.comp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c652f28924..59dec4f824 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -912,6 +912,8 @@ int main(int argc, char **argv) } } + g_ForcedNV12ColorSpace = parse_colorspace_string( getenv( "GAMESCOPE_NV12_COLORSPACE" ) ); + switch ( eCurrentBackend ) { #if HAVE_DRM @@ -952,8 +954,6 @@ int main(int argc, char **argv) UpdateCompatEnvVars(); - g_ForcedNV12ColorSpace = parse_colorspace_string( getenv( "GAMESCOPE_NV12_COLORSPACE" ) ); - if ( !vulkan_init_formats() ) { fprintf( stderr, "vulkan_init_formats failed\n" ); diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp index 83e2ae6958..dca98dde0d 100644 --- a/src/rendervulkan.hpp +++ b/src/rendervulkan.hpp @@ -111,7 +111,7 @@ inline GamescopeAppTextureColorspace VkColorSpaceToGamescopeAppTextureColorSpace default: case VK_COLOR_SPACE_SRGB_NONLINEAR_KHR: // We will use image view conversions for these 8888 formats. - if (ToSrgbVulkanFormat(format) != ToLinearVulkanFormat(format) || format == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM) + if (ToSrgbVulkanFormat(format) != ToLinearVulkanFormat(format)) return GAMESCOPE_APP_TEXTURE_COLORSPACE_LINEAR; return GAMESCOPE_APP_TEXTURE_COLORSPACE_SRGB; diff --git a/src/shaders/cs_composite_blit.comp b/src/shaders/cs_composite_blit.comp index 51727fe86a..d2ef47b115 100644 --- a/src/shaders/cs_composite_blit.comp +++ b/src/shaders/cs_composite_blit.comp @@ -15,7 +15,7 @@ layout( vec4 sampleLayer(uint layerIdx, vec2 uv) { if ((c_ycbcrMask & (1 << layerIdx)) != 0) - return srgbToLinear(sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false)); + return sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false); return sampleLayer(s_samplers[layerIdx], layerIdx, uv, true); } diff --git a/src/shaders/cs_composite_blur.comp b/src/shaders/cs_composite_blur.comp index a9326aa1a7..38c43ecd17 100644 --- a/src/shaders/cs_composite_blur.comp +++ b/src/shaders/cs_composite_blur.comp @@ -18,7 +18,7 @@ layout( vec4 sampleLayer(uint layerIdx, vec2 uv) { if ((c_ycbcrMask & (1 << layerIdx)) != 0) - return srgbToLinear(sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false)); + return sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false); return sampleLayer(s_samplers[layerIdx], layerIdx, uv, true); } diff --git a/src/shaders/cs_composite_blur_cond.comp b/src/shaders/cs_composite_blur_cond.comp index 7538cb06ad..d61f494ac1 100644 --- a/src/shaders/cs_composite_blur_cond.comp +++ b/src/shaders/cs_composite_blur_cond.comp @@ -18,7 +18,7 @@ layout( vec4 sampleLayer(uint layerIdx, vec2 uv) { if ((c_ycbcrMask & (1 << layerIdx)) != 0) - return srgbToLinear(sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false)); + return sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false); return sampleLayer(s_samplers[layerIdx], layerIdx, uv, true); } diff --git a/src/shaders/cs_composite_rcas.comp b/src/shaders/cs_composite_rcas.comp index cee2a45c29..85557a0427 100644 --- a/src/shaders/cs_composite_rcas.comp +++ b/src/shaders/cs_composite_rcas.comp @@ -43,7 +43,7 @@ void FsrRcasInputF(inout float r, inout float g, inout float b) {} vec4 sampleLayer(uint layerIdx, vec2 uv) { if ((c_ycbcrMask & (1 << layerIdx)) != 0) - return srgbToLinear(sampleLayerEx(s_ycbcr_samplers[layerIdx], layerIdx - 1, layerIdx, uv, false)); + return sampleLayerEx(s_ycbcr_samplers[layerIdx], layerIdx - 1, layerIdx, uv, false); return sampleLayerEx(s_samplers[layerIdx], layerIdx - 1, layerIdx, uv, true); } diff --git a/src/shaders/cs_gaussian_blur_horizontal.comp b/src/shaders/cs_gaussian_blur_horizontal.comp index a4f6a92cb7..ab025e355f 100644 --- a/src/shaders/cs_gaussian_blur_horizontal.comp +++ b/src/shaders/cs_gaussian_blur_horizontal.comp @@ -50,7 +50,7 @@ void main() vec4 layerColor; // YCBCR technically has incorrect blending here but... meh. if ((c_ycbcrMask & (1 << i)) != 0) - layerColor = srgbToLinear(gaussian_blur(s_ycbcr_samplers[i], i, pos, u_blur_radius, false, false)); + layerColor = gaussian_blur(s_ycbcr_samplers[i], i, pos, u_blur_radius, false, false); else layerColor = gaussian_blur(s_samplers[i], i, pos, u_blur_radius, false, true);