From accce4294aec05f59571c9983811624e2b4f5a70 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 14 Dec 2016 23:58:23 +1000 Subject: [PATCH] TextureCache: Use same color coefficients for EFB2Tex as EFB2RAM --- .../Core/VideoBackends/D3D/PixelShaderCache.cpp | 4 ++-- .../VideoBackends/D3D12/StaticShaderCache.cpp | 4 ++-- Source/Core/VideoBackends/OGL/TextureCache.cpp | 2 +- .../Core/VideoBackends/Vulkan/TextureCache.cpp | 2 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 16 ++++++++-------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp b/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp index 5364c58cdd..6b62e1575f 100644 --- a/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp @@ -104,7 +104,7 @@ const char color_matrix_program_code[] = {"sampler samp0 : register(s0);\n" "in float4 pos : SV_Position,\n" "in float3 uv0 : TEXCOORD0){\n" "float4 texcol = Tex0.Sample(samp0,uv0);\n" - "texcol = round(texcol * cColMatrix[5])*cColMatrix[6];\n" + "texcol = floor(texcol * cColMatrix[5])*cColMatrix[6];\n" "ocol0 = " "float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[" "1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3]))" @@ -126,7 +126,7 @@ const char color_matrix_program_code_msaa[] = { "for(int i = 0; i < SAMPLES; ++i)\n" " texcol += Tex0.Load(int3(uv0.x*(width), uv0.y*(height), uv0.z), i);\n" "texcol /= SAMPLES;\n" - "texcol = round(texcol * cColMatrix[5])*cColMatrix[6];\n" + "texcol = floor(texcol * cColMatrix[5])*cColMatrix[6];\n" "ocol0 = " "float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(" "texcol,cColMatrix[3])) + cColMatrix[4];\n" diff --git a/Source/Core/VideoBackends/D3D12/StaticShaderCache.cpp b/Source/Core/VideoBackends/D3D12/StaticShaderCache.cpp index 652b1515ba..0535c7c05a 100644 --- a/Source/Core/VideoBackends/D3D12/StaticShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D12/StaticShaderCache.cpp @@ -131,7 +131,7 @@ static constexpr const char s_color_matrix_program_hlsl[] = { "in float4 pos : SV_Position,\n" "in float3 uv0 : TEXCOORD0){\n" "float4 texcol = Tex0.Sample(samp0,uv0);\n" - "texcol = round(texcol * cColMatrix[5])*cColMatrix[6];\n" + "texcol = floor(texcol * cColMatrix[5])*cColMatrix[6];\n" "ocol0 = " "float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(" "texcol,cColMatrix[3])) + cColMatrix[4];\n" @@ -152,7 +152,7 @@ static constexpr const char s_color_matrix_program_msaa_hlsl[] = { "for(int i = 0; i < SAMPLES; ++i)\n" " texcol += Tex0.Load(int3(uv0.x*(width), uv0.y*(height), uv0.z), i);\n" "texcol /= SAMPLES;\n" - "texcol = round(texcol * cColMatrix[5])*cColMatrix[6];\n" + "texcol = floor(texcol * cColMatrix[5])*cColMatrix[6];\n" "ocol0 = " "float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(" "texcol,cColMatrix[3])) + cColMatrix[4];\n" diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index dc9d290f3e..50c729d45e 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -333,7 +333,7 @@ bool TextureCache::CompileShaders() "\n" "void main(){\n" " vec4 texcol = texture(samp9, f_uv0);\n" - " texcol = round(texcol * colmat[5]) * colmat[6];\n" + " texcol = floor(texcol * colmat[5]) * colmat[6];\n" " ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];\n" "}\n"; diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.cpp b/Source/Core/VideoBackends/Vulkan/TextureCache.cpp index b08ae89f91..a860e8601d 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.cpp +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.cpp @@ -602,7 +602,7 @@ bool TextureCache::CompileShaders() void main() { float4 texcol = texture(samp0, uv0); - texcol = round(texcol * C.colmat[5]) * C.colmat[6]; + texcol = floor(texcol * C.colmat[5]) * C.colmat[6]; ocol0 = texcol * mat4(C.colmat[0], C.colmat[1], C.colmat[2], C.colmat[3]) + C.colmat[4]; } )"; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 9b5df69627..47ecc4f528 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1039,7 +1039,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo fConstAdd[3] = 16.0f / 255.0f; if (dstFormat == 0) { - ColorMask[0] = ColorMask[1] = ColorMask[2] = 15.0f; + ColorMask[0] = ColorMask[1] = ColorMask[2] = 255.0f / 16.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = 1.0f / 15.0f; cbufid = 9; } @@ -1053,7 +1053,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo colmat[15] = 1; if (dstFormat == 2) { - ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 15.0f; + ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f / 16.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 15.0f; cbufid = 11; } @@ -1077,7 +1077,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo { case 0: // R4 colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1; - ColorMask[0] = 15.0f; + ColorMask[0] = 255.0f / 16.0f; ColorMask[4] = 1.0f / 15.0f; cbufid = 14; dstFormat |= _GX_TF_CTF; @@ -1091,7 +1091,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo case 2: // RA4 colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1.0f; - ColorMask[0] = ColorMask[3] = 15.0f; + ColorMask[0] = ColorMask[3] = 255.0f / 16.0f; ColorMask[4] = ColorMask[7] = 1.0f / 15.0f; cbufid = 16; @@ -1157,9 +1157,9 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo case 4: // RGB565 colmat[0] = colmat[5] = colmat[10] = 1.0f; - ColorMask[0] = ColorMask[2] = 31.0f; + ColorMask[0] = ColorMask[2] = 255.0f / 8.0f; ColorMask[4] = ColorMask[6] = 1.0f / 31.0f; - ColorMask[1] = 63.0f; + ColorMask[1] = 255.0f / 4.0f; ColorMask[5] = 1.0f / 63.0f; fConstAdd[3] = 1.0f; // set alpha to 1 cbufid = 26; @@ -1167,9 +1167,9 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo case 5: // RGB5A3 colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1.0f; - ColorMask[0] = ColorMask[1] = ColorMask[2] = 31.0f; + ColorMask[0] = ColorMask[1] = ColorMask[2] = 255.0f / 8.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = 1.0f / 31.0f; - ColorMask[3] = 7.0f; + ColorMask[3] = 255.0f / 32.0f; ColorMask[7] = 1.0f / 7.0f; cbufid = 27;