Skip to content

Commit

Permalink
rendervulkan: Fix NV12 colorspace producing washed out colours
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Jun 22, 2024
1 parent 7cf3571 commit 9d61912
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,8 @@ int main(int argc, char **argv)
}
}

g_ForcedNV12ColorSpace = parse_colorspace_string( getenv( "GAMESCOPE_NV12_COLORSPACE" ) );

switch ( eCurrentBackend )
{
#if HAVE_DRM
Expand Down Expand Up @@ -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" );
Expand Down
2 changes: 1 addition & 1 deletion src/rendervulkan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/cs_composite_blit.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/cs_composite_blur.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/cs_composite_blur_cond.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/cs_composite_rcas.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/cs_gaussian_blur_horizontal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9d61912

Please sign in to comment.