Merge pull request #4517 from stenzek/mp3-blotches
TextureCache: Use same color coefficients for EFB2Tex as EFB2RAM
This commit is contained in:
commit
01047319f8
|
@ -104,7 +104,7 @@ const char color_matrix_program_code[] = {"sampler samp0 : register(s0);\n"
|
||||||
"in float4 pos : SV_Position,\n"
|
"in float4 pos : SV_Position,\n"
|
||||||
"in float3 uv0 : TEXCOORD0){\n"
|
"in float3 uv0 : TEXCOORD0){\n"
|
||||||
"float4 texcol = Tex0.Sample(samp0,uv0);\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 = "
|
"ocol0 = "
|
||||||
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix["
|
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix["
|
||||||
"1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3]))"
|
"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"
|
"for(int i = 0; i < SAMPLES; ++i)\n"
|
||||||
" texcol += Tex0.Load(int3(uv0.x*(width), uv0.y*(height), uv0.z), i);\n"
|
" texcol += Tex0.Load(int3(uv0.x*(width), uv0.y*(height), uv0.z), i);\n"
|
||||||
"texcol /= SAMPLES;\n"
|
"texcol /= SAMPLES;\n"
|
||||||
"texcol = round(texcol * cColMatrix[5])*cColMatrix[6];\n"
|
"texcol = floor(texcol * cColMatrix[5])*cColMatrix[6];\n"
|
||||||
"ocol0 = "
|
"ocol0 = "
|
||||||
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot("
|
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot("
|
||||||
"texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
"texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||||
|
|
|
@ -131,7 +131,7 @@ static constexpr const char s_color_matrix_program_hlsl[] = {
|
||||||
"in float4 pos : SV_Position,\n"
|
"in float4 pos : SV_Position,\n"
|
||||||
"in float3 uv0 : TEXCOORD0){\n"
|
"in float3 uv0 : TEXCOORD0){\n"
|
||||||
"float4 texcol = Tex0.Sample(samp0,uv0);\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 = "
|
"ocol0 = "
|
||||||
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot("
|
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot("
|
||||||
"texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
"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"
|
"for(int i = 0; i < SAMPLES; ++i)\n"
|
||||||
" texcol += Tex0.Load(int3(uv0.x*(width), uv0.y*(height), uv0.z), i);\n"
|
" texcol += Tex0.Load(int3(uv0.x*(width), uv0.y*(height), uv0.z), i);\n"
|
||||||
"texcol /= SAMPLES;\n"
|
"texcol /= SAMPLES;\n"
|
||||||
"texcol = round(texcol * cColMatrix[5])*cColMatrix[6];\n"
|
"texcol = floor(texcol * cColMatrix[5])*cColMatrix[6];\n"
|
||||||
"ocol0 = "
|
"ocol0 = "
|
||||||
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot("
|
"float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot("
|
||||||
"texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
"texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||||
|
|
|
@ -333,7 +333,7 @@ bool TextureCache::CompileShaders()
|
||||||
"\n"
|
"\n"
|
||||||
"void main(){\n"
|
"void main(){\n"
|
||||||
" vec4 texcol = texture(samp9, f_uv0);\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"
|
" ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ static void EncodeRGBA6(u8* dst, const u8* src, u32 format)
|
||||||
src += readStride;
|
src += readStride;
|
||||||
|
|
||||||
u16 val =
|
u16 val =
|
||||||
((srcColor >> 8) & 0xf800) | ((srcColor >> 7) & 0x07e0) | ((srcColor >> 7) & 0x001e);
|
((srcColor >> 8) & 0xf800) | ((srcColor >> 7) & 0x07e0) | ((srcColor >> 7) & 0x001f);
|
||||||
*(u16*)dst = Common::swap16(val);
|
*(u16*)dst = Common::swap16(val);
|
||||||
dst += 2;
|
dst += 2;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ static void EncodeRGBA6(u8* dst, const u8* src, u32 format)
|
||||||
u16 val;
|
u16 val;
|
||||||
if (alpha == 0x7000) // 555
|
if (alpha == 0x7000) // 555
|
||||||
val = 0x8000 | ((srcColor >> 9) & 0x7c00) | ((srcColor >> 8) & 0x03e0) |
|
val = 0x8000 | ((srcColor >> 9) & 0x7c00) | ((srcColor >> 8) & 0x03e0) |
|
||||||
((srcColor >> 7) & 0x001e);
|
((srcColor >> 7) & 0x001f);
|
||||||
else // 4443
|
else // 4443
|
||||||
val = alpha | ((srcColor >> 12) & 0x0f00) | ((srcColor >> 10) & 0x00f0) |
|
val = alpha | ((srcColor >> 12) & 0x0f00) | ((srcColor >> 10) & 0x00f0) |
|
||||||
((srcColor >> 8) & 0x000f);
|
((srcColor >> 8) & 0x000f);
|
||||||
|
@ -573,7 +573,7 @@ static void EncodeRGBA6halfscale(u8* dst, const u8* src, u32 format)
|
||||||
BoxfilterRGBA_to_RGB8(src, &r, &g, &b);
|
BoxfilterRGBA_to_RGB8(src, &r, &g, &b);
|
||||||
src += readStride;
|
src += readStride;
|
||||||
|
|
||||||
u16 val = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001e);
|
u16 val = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f);
|
||||||
*(u16*)dst = Common::swap16(val);
|
*(u16*)dst = Common::swap16(val);
|
||||||
dst += 2;
|
dst += 2;
|
||||||
}
|
}
|
||||||
|
@ -590,7 +590,7 @@ static void EncodeRGBA6halfscale(u8* dst, const u8* src, u32 format)
|
||||||
|
|
||||||
u16 val;
|
u16 val;
|
||||||
if (a >= 224) // 5551
|
if (a >= 224) // 5551
|
||||||
val = 0x8000 | ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001e);
|
val = 0x8000 | ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f);
|
||||||
else // 4443
|
else // 4443
|
||||||
val = ((a << 7) & 0x7000) | ((r << 4) & 0x0f00) | (g & 0x00f0) | ((b >> 4) & 0x000f);
|
val = ((a << 7) & 0x7000) | ((r << 4) & 0x0f00) | (g & 0x00f0) | ((b >> 4) & 0x000f);
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ static void EncodeRGB8(u8* dst, const u8* src, u32 format)
|
||||||
SetSpans(sBlkSize, tBlkSize, &tSpan, &sBlkSpan, &tBlkSpan, &writeStride);
|
SetSpans(sBlkSize, tBlkSize, &tSpan, &sBlkSpan, &tBlkSpan, &writeStride);
|
||||||
ENCODE_LOOP_BLOCKS
|
ENCODE_LOOP_BLOCKS
|
||||||
{
|
{
|
||||||
u16 val = ((src[2] << 8) & 0xf800) | ((src[1] << 3) & 0x07e0) | ((src[0] >> 3) & 0x001e);
|
u16 val = ((src[2] << 8) & 0xf800) | ((src[1] << 3) & 0x07e0) | ((src[0] >> 3) & 0x001f);
|
||||||
*(u16*)dst = Common::swap16(val);
|
*(u16*)dst = Common::swap16(val);
|
||||||
src += readStride;
|
src += readStride;
|
||||||
dst += 2;
|
dst += 2;
|
||||||
|
@ -814,7 +814,7 @@ static void EncodeRGB8(u8* dst, const u8* src, u32 format)
|
||||||
ENCODE_LOOP_BLOCKS
|
ENCODE_LOOP_BLOCKS
|
||||||
{
|
{
|
||||||
u16 val =
|
u16 val =
|
||||||
0x8000 | ((src[2] << 7) & 0x7c00) | ((src[1] << 2) & 0x03e0) | ((src[0] >> 3) & 0x001e);
|
0x8000 | ((src[2] << 7) & 0x7c00) | ((src[1] << 2) & 0x03e0) | ((src[0] >> 3) & 0x001f);
|
||||||
*(u16*)dst = Common::swap16(val);
|
*(u16*)dst = Common::swap16(val);
|
||||||
src += readStride;
|
src += readStride;
|
||||||
dst += 2;
|
dst += 2;
|
||||||
|
@ -1018,7 +1018,7 @@ static void EncodeRGB8halfscale(u8* dst, const u8* src, u32 format)
|
||||||
ENCODE_LOOP_BLOCKS
|
ENCODE_LOOP_BLOCKS
|
||||||
{
|
{
|
||||||
BoxfilterRGB_to_RGB8(src, &r, &g, &b);
|
BoxfilterRGB_to_RGB8(src, &r, &g, &b);
|
||||||
u16 val = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001e);
|
u16 val = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f);
|
||||||
*(u16*)dst = Common::swap16(val);
|
*(u16*)dst = Common::swap16(val);
|
||||||
src += readStride;
|
src += readStride;
|
||||||
dst += 2;
|
dst += 2;
|
||||||
|
@ -1032,7 +1032,7 @@ static void EncodeRGB8halfscale(u8* dst, const u8* src, u32 format)
|
||||||
ENCODE_LOOP_BLOCKS
|
ENCODE_LOOP_BLOCKS
|
||||||
{
|
{
|
||||||
BoxfilterRGB_to_RGB8(src, &r, &g, &b);
|
BoxfilterRGB_to_RGB8(src, &r, &g, &b);
|
||||||
u16 val = 0x8000 | ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001e);
|
u16 val = 0x8000 | ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f);
|
||||||
*(u16*)dst = Common::swap16(val);
|
*(u16*)dst = Common::swap16(val);
|
||||||
src += readStride;
|
src += readStride;
|
||||||
dst += 2;
|
dst += 2;
|
||||||
|
|
|
@ -602,7 +602,7 @@ bool TextureCache::CompileShaders()
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float4 texcol = texture(samp0, uv0);
|
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];
|
ocol0 = texcol * mat4(C.colmat[0], C.colmat[1], C.colmat[2], C.colmat[3]) + C.colmat[4];
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
|
@ -1039,7 +1039,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
|
||||||
fConstAdd[3] = 16.0f / 255.0f;
|
fConstAdd[3] = 16.0f / 255.0f;
|
||||||
if (dstFormat == 0)
|
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;
|
ColorMask[4] = ColorMask[5] = ColorMask[6] = 1.0f / 15.0f;
|
||||||
cbufid = 9;
|
cbufid = 9;
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1053,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
|
||||||
colmat[15] = 1;
|
colmat[15] = 1;
|
||||||
if (dstFormat == 2)
|
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;
|
ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 15.0f;
|
||||||
cbufid = 11;
|
cbufid = 11;
|
||||||
}
|
}
|
||||||
|
@ -1077,7 +1077,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
|
||||||
{
|
{
|
||||||
case 0: // R4
|
case 0: // R4
|
||||||
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
|
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;
|
ColorMask[4] = 1.0f / 15.0f;
|
||||||
cbufid = 14;
|
cbufid = 14;
|
||||||
dstFormat |= _GX_TF_CTF;
|
dstFormat |= _GX_TF_CTF;
|
||||||
|
@ -1091,7 +1091,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
|
||||||
|
|
||||||
case 2: // RA4
|
case 2: // RA4
|
||||||
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1.0f;
|
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;
|
ColorMask[4] = ColorMask[7] = 1.0f / 15.0f;
|
||||||
|
|
||||||
cbufid = 16;
|
cbufid = 16;
|
||||||
|
@ -1157,9 +1157,9 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
|
||||||
|
|
||||||
case 4: // RGB565
|
case 4: // RGB565
|
||||||
colmat[0] = colmat[5] = colmat[10] = 1.0f;
|
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[4] = ColorMask[6] = 1.0f / 31.0f;
|
||||||
ColorMask[1] = 63.0f;
|
ColorMask[1] = 255.0f / 4.0f;
|
||||||
ColorMask[5] = 1.0f / 63.0f;
|
ColorMask[5] = 1.0f / 63.0f;
|
||||||
fConstAdd[3] = 1.0f; // set alpha to 1
|
fConstAdd[3] = 1.0f; // set alpha to 1
|
||||||
cbufid = 26;
|
cbufid = 26;
|
||||||
|
@ -1167,9 +1167,9 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
|
||||||
|
|
||||||
case 5: // RGB5A3
|
case 5: // RGB5A3
|
||||||
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1.0f;
|
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[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;
|
ColorMask[7] = 1.0f / 7.0f;
|
||||||
|
|
||||||
cbufid = 27;
|
cbufid = 27;
|
||||||
|
|
Loading…
Reference in New Issue