From 8b82cea704fca9728c5f50a2506f58a9c5948deb Mon Sep 17 00:00:00 2001 From: magumagu Date: Wed, 14 May 2014 13:27:00 -0700 Subject: [PATCH] Video backends: fix behavior of "konst" TEV inputs. Also fixes TEVCOLORARG_HALF. Values verified to match hardwarere. --- Source/Core/VideoBackends/Software/Tev.cpp | 26 +++++++++----- Source/Core/VideoCommon/PixelShaderGen.cpp | 42 +++++++++++----------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 9e6191c315..98f82dea9e 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -23,10 +23,10 @@ void Tev::Init() { FixedConstants[0] = 0; - FixedConstants[1] = 31; - FixedConstants[2] = 63; - FixedConstants[3] = 95; - FixedConstants[4] = 127; + FixedConstants[1] = 32; + FixedConstants[2] = 64; + FixedConstants[3] = 96; + FixedConstants[4] = 128; FixedConstants[5] = 159; FixedConstants[6] = 191; FixedConstants[7] = 223; @@ -74,10 +74,20 @@ void Tev::Init() m_KonstLUT[6][comp] = &FixedConstants[2]; m_KonstLUT[7][comp] = &FixedConstants[1]; - m_KonstLUT[12][comp] = &KonstantColors[0][comp]; - m_KonstLUT[13][comp] = &KonstantColors[1][comp]; - m_KonstLUT[14][comp] = &KonstantColors[2][comp]; - m_KonstLUT[15][comp] = &KonstantColors[3][comp]; + // These are "invalid" values, not meant to be used. On hardware, + // they all output zero. + for (int i = 8; i < 16; ++i) + { + m_KonstLUT[i][comp] = &FixedConstants[0]; + } + + if (comp != ALP_C) + { + m_KonstLUT[12][comp] = &KonstantColors[0][comp]; + m_KonstLUT[13][comp] = &KonstantColors[1][comp]; + m_KonstLUT[14][comp] = &KonstantColors[2][comp]; + m_KonstLUT[15][comp] = &KonstantColors[3][comp]; + } m_KonstLUT[16][comp] = &KonstantColors[0][RED_C]; m_KonstLUT[17][comp] = &KonstantColors[1][RED_C]; diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index a3aba7d427..7a508587be 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -24,14 +24,14 @@ static const char *tevKSelTableC[] = "223,223,223", // 7_8 = 0x01 "191,191,191", // 3_4 = 0x02 "159,159,159", // 5_8 = 0x03 - "127,127,127", // 1_2 = 0x04 - "95,95,95", // 3_8 = 0x05 - "63,63,63", // 1_4 = 0x06 - "31,31,31", // 1_8 = 0x07 - "ERROR1", // 0x08 - "ERROR2", // 0x09 - "ERROR3", // 0x0a - "ERROR4", // 0x0b + "128,128,128", // 1_2 = 0x04 + "96,96,96", // 3_8 = 0x05 + "64,64,64", // 1_4 = 0x06 + "32,32,32", // 1_8 = 0x07 + "0,0,0", // INVALID = 0x08 + "0,0,0", // INVALID = 0x09 + "0,0,0", // INVALID = 0x0a + "0,0,0", // INVALID = 0x0b I_KCOLORS"[0].rgb", // K0 = 0x0C I_KCOLORS"[1].rgb", // K1 = 0x0D I_KCOLORS"[2].rgb", // K2 = 0x0E @@ -60,18 +60,18 @@ static const char *tevKSelTableA[] = "223", // 7_8 = 0x01 "191", // 3_4 = 0x02 "159", // 5_8 = 0x03 - "127", // 1_2 = 0x04 - "95", // 3_8 = 0x05 - "63", // 1_4 = 0x06 - "31", // 1_8 = 0x07 - "ERROR5", // 0x08 - "ERROR6", // 0x09 - "ERROR7", // 0x0a - "ERROR8", // 0x0b - "ERROR9", // 0x0c - "ERROR10", // 0x0d - "ERROR11", // 0x0e - "ERROR12", // 0x0f + "128", // 1_2 = 0x04 + "96", // 3_8 = 0x05 + "64", // 1_4 = 0x06 + "32", // 1_8 = 0x07 + "0", // INVALID = 0x08 + "0", // INVALID = 0x09 + "0", // INVALID = 0x0a + "0", // INVALID = 0x0b + "0", // INVALID = 0x0c + "0", // INVALID = 0x0d + "0", // INVALID = 0x0e + "0", // INVALID = 0x0f I_KCOLORS"[0].r", // K0_R = 0x10 I_KCOLORS"[1].r", // K1_R = 0x11 I_KCOLORS"[2].r", // K2_R = 0x12 @@ -105,7 +105,7 @@ static const char *tevCInputTable[] = "rastemp.rgb", // RASC, "rastemp.aaa", // RASA, "int3(255,255,255)", // ONE - "int3(127,127,127)", // HALF + "int3(128,128,128)", // HALF "konsttemp.rgb", // KONST "int3(0,0,0)", // ZERO };