From 0fac1d6e87990a732916b107ec836ca3b0f0e393 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Mon, 13 Jun 2022 13:07:20 -0700 Subject: [PATCH] VideoCommon: Fix D3D shader warning X3571 (negative base for pow()) Add abs() to fix "pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them". --- Source/Core/VideoCommon/TextureConversionShader.cpp | 4 ++-- Source/Core/VideoCommon/TextureConverterShaderGen.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 19f2a384f0..2c53250cea 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -749,8 +749,8 @@ static void WriteXFBEncoder(ShaderCode& code, APIType api_type, const EFBCopyPar WriteSampleColor(code, "rgb", "color1", 1, api_type, params); // Gamma is only applied to XFB copies. - code.Write(" color0 = pow(color0, float3(gamma_rcp, gamma_rcp, gamma_rcp));\n" - " color1 = pow(color1, float3(gamma_rcp, gamma_rcp, gamma_rcp));\n"); + code.Write(" color0 = pow(abs(color0), float3(gamma_rcp, gamma_rcp, gamma_rcp));\n" + " color1 = pow(abs(color1), float3(gamma_rcp, gamma_rcp, gamma_rcp));\n"); // Convert to YUV. code.Write(" const float3 y_const = float3(0.257, 0.504, 0.098);\n" diff --git a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp index c5a440b801..579dbf69c5 100644 --- a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp +++ b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp @@ -313,8 +313,8 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data) break; case EFBCopyFormat::XFB: - out.Write( - " ocol0 = float4(pow(texcol.rgb, float3(gamma_rcp, gamma_rcp, gamma_rcp)), 1.0f);\n"); + out.Write(" ocol0 = float4(pow(abs(texcol.rgb), float3(gamma_rcp, gamma_rcp, gamma_rcp)), " + "1.0f);\n"); break; default: