diff options
| author | Pokechu22 <pokechu022@gmail.com> | 2022-09-08 09:42:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-08 09:42:12 -0700 |
| commit | 2dfe91336a739ba10d9bfcf7c85c1e8f4802e1b2 (patch) | |
| tree | 2022f9d5f4e430dd3ec6711e2cd488b98097b539 /Source/Core/VideoBackends/Software/Tev.cpp | |
| parent | 74851fe94a86c64217721b9450ed184f43dae0be (diff) | |
| parent | 698def66ff36fc0155d84b3777501e71a2ad22a1 (diff) | |
Merge pull request #10549 from Pokechu22/sw-tev-enum-map
Refactor various bits of graphics code for readability
Diffstat (limited to 'Source/Core/VideoBackends/Software/Tev.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Software/Tev.cpp | 303 |
1 files changed, 82 insertions, 221 deletions
diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index c2039df3ea..e788d55d92 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -27,190 +27,49 @@ #define ALLOW_TEV_DUMPS 0 #endif -void Tev::Init() -{ - FixedConstants[0] = 0; - FixedConstants[1] = 32; - FixedConstants[2] = 64; - FixedConstants[3] = 96; - FixedConstants[4] = 128; - FixedConstants[5] = 159; - FixedConstants[6] = 191; - FixedConstants[7] = 223; - FixedConstants[8] = 255; - - for (s16& comp : Zero16) - { - comp = 0; - } - - m_ColorInputLUT[0][RED_INP] = &Reg[0][RED_C]; - m_ColorInputLUT[0][GRN_INP] = &Reg[0][GRN_C]; - m_ColorInputLUT[0][BLU_INP] = &Reg[0][BLU_C]; // prev.rgb - m_ColorInputLUT[1][RED_INP] = &Reg[0][ALP_C]; - m_ColorInputLUT[1][GRN_INP] = &Reg[0][ALP_C]; - m_ColorInputLUT[1][BLU_INP] = &Reg[0][ALP_C]; // prev.aaa - m_ColorInputLUT[2][RED_INP] = &Reg[1][RED_C]; - m_ColorInputLUT[2][GRN_INP] = &Reg[1][GRN_C]; - m_ColorInputLUT[2][BLU_INP] = &Reg[1][BLU_C]; // c0.rgb - m_ColorInputLUT[3][RED_INP] = &Reg[1][ALP_C]; - m_ColorInputLUT[3][GRN_INP] = &Reg[1][ALP_C]; - m_ColorInputLUT[3][BLU_INP] = &Reg[1][ALP_C]; // c0.aaa - m_ColorInputLUT[4][RED_INP] = &Reg[2][RED_C]; - m_ColorInputLUT[4][GRN_INP] = &Reg[2][GRN_C]; - m_ColorInputLUT[4][BLU_INP] = &Reg[2][BLU_C]; // c1.rgb - m_ColorInputLUT[5][RED_INP] = &Reg[2][ALP_C]; - m_ColorInputLUT[5][GRN_INP] = &Reg[2][ALP_C]; - m_ColorInputLUT[5][BLU_INP] = &Reg[2][ALP_C]; // c1.aaa - m_ColorInputLUT[6][RED_INP] = &Reg[3][RED_C]; - m_ColorInputLUT[6][GRN_INP] = &Reg[3][GRN_C]; - m_ColorInputLUT[6][BLU_INP] = &Reg[3][BLU_C]; // c2.rgb - m_ColorInputLUT[7][RED_INP] = &Reg[3][ALP_C]; - m_ColorInputLUT[7][GRN_INP] = &Reg[3][ALP_C]; - m_ColorInputLUT[7][BLU_INP] = &Reg[3][ALP_C]; // c2.aaa - m_ColorInputLUT[8][RED_INP] = &TexColor[RED_C]; - m_ColorInputLUT[8][GRN_INP] = &TexColor[GRN_C]; - m_ColorInputLUT[8][BLU_INP] = &TexColor[BLU_C]; // tex.rgb - m_ColorInputLUT[9][RED_INP] = &TexColor[ALP_C]; - m_ColorInputLUT[9][GRN_INP] = &TexColor[ALP_C]; - m_ColorInputLUT[9][BLU_INP] = &TexColor[ALP_C]; // tex.aaa - m_ColorInputLUT[10][RED_INP] = &RasColor[RED_C]; - m_ColorInputLUT[10][GRN_INP] = &RasColor[GRN_C]; - m_ColorInputLUT[10][BLU_INP] = &RasColor[BLU_C]; // ras.rgb - m_ColorInputLUT[11][RED_INP] = &RasColor[ALP_C]; - m_ColorInputLUT[11][GRN_INP] = &RasColor[ALP_C]; - m_ColorInputLUT[11][BLU_INP] = &RasColor[ALP_C]; // ras.rgb - m_ColorInputLUT[12][RED_INP] = &FixedConstants[8]; - m_ColorInputLUT[12][GRN_INP] = &FixedConstants[8]; - m_ColorInputLUT[12][BLU_INP] = &FixedConstants[8]; // one - m_ColorInputLUT[13][RED_INP] = &FixedConstants[4]; - m_ColorInputLUT[13][GRN_INP] = &FixedConstants[4]; - m_ColorInputLUT[13][BLU_INP] = &FixedConstants[4]; // half - m_ColorInputLUT[14][RED_INP] = &StageKonst[RED_C]; - m_ColorInputLUT[14][GRN_INP] = &StageKonst[GRN_C]; - m_ColorInputLUT[14][BLU_INP] = &StageKonst[BLU_C]; // konst - m_ColorInputLUT[15][RED_INP] = &FixedConstants[0]; - m_ColorInputLUT[15][GRN_INP] = &FixedConstants[0]; - m_ColorInputLUT[15][BLU_INP] = &FixedConstants[0]; // zero - - m_AlphaInputLUT[0] = &Reg[0][ALP_C]; // prev - m_AlphaInputLUT[1] = &Reg[1][ALP_C]; // c0 - m_AlphaInputLUT[2] = &Reg[2][ALP_C]; // c1 - m_AlphaInputLUT[3] = &Reg[3][ALP_C]; // c2 - m_AlphaInputLUT[4] = &TexColor[ALP_C]; // tex - m_AlphaInputLUT[5] = &RasColor[ALP_C]; // ras - m_AlphaInputLUT[6] = &StageKonst[ALP_C]; // konst - m_AlphaInputLUT[7] = &Zero16[ALP_C]; // zero - - for (int comp = 0; comp < 4; comp++) - { - m_KonstLUT[0][comp] = &FixedConstants[8]; - m_KonstLUT[1][comp] = &FixedConstants[7]; - m_KonstLUT[2][comp] = &FixedConstants[6]; - m_KonstLUT[3][comp] = &FixedConstants[5]; - m_KonstLUT[4][comp] = &FixedConstants[4]; - m_KonstLUT[5][comp] = &FixedConstants[3]; - m_KonstLUT[6][comp] = &FixedConstants[2]; - m_KonstLUT[7][comp] = &FixedConstants[1]; - - // 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]; - m_KonstLUT[18][comp] = &KonstantColors[2][RED_C]; - m_KonstLUT[19][comp] = &KonstantColors[3][RED_C]; - m_KonstLUT[20][comp] = &KonstantColors[0][GRN_C]; - m_KonstLUT[21][comp] = &KonstantColors[1][GRN_C]; - m_KonstLUT[22][comp] = &KonstantColors[2][GRN_C]; - m_KonstLUT[23][comp] = &KonstantColors[3][GRN_C]; - m_KonstLUT[24][comp] = &KonstantColors[0][BLU_C]; - m_KonstLUT[25][comp] = &KonstantColors[1][BLU_C]; - m_KonstLUT[26][comp] = &KonstantColors[2][BLU_C]; - m_KonstLUT[27][comp] = &KonstantColors[3][BLU_C]; - m_KonstLUT[28][comp] = &KonstantColors[0][ALP_C]; - m_KonstLUT[29][comp] = &KonstantColors[1][ALP_C]; - m_KonstLUT[30][comp] = &KonstantColors[2][ALP_C]; - m_KonstLUT[31][comp] = &KonstantColors[3][ALP_C]; - } - - m_BiasLUT[0] = 0; - m_BiasLUT[1] = 128; - m_BiasLUT[2] = -128; - m_BiasLUT[3] = 0; - - m_ScaleLShiftLUT[0] = 0; - m_ScaleLShiftLUT[1] = 1; - m_ScaleLShiftLUT[2] = 2; - m_ScaleLShiftLUT[3] = 0; - - m_ScaleRShiftLUT[0] = 0; - m_ScaleRShiftLUT[1] = 0; - m_ScaleRShiftLUT[2] = 0; - m_ScaleRShiftLUT[3] = 1; -} - static inline s16 Clamp255(s16 in) { - return in > 255 ? 255 : (in < 0 ? 0 : in); + return std::clamp<s16>(in, 0, 255); } static inline s16 Clamp1024(s16 in) { - return in > 1023 ? 1023 : (in < -1024 ? -1024 : in); + return std::clamp<s16>(in, -1024, 1023); } -void Tev::SetRasColor(RasColorChan colorChan, int swaptable) +void Tev::SetRasColor(RasColorChan colorChan, u32 swaptable) { switch (colorChan) { case RasColorChan::Color0: { const u8* color = Color[0]; - RasColor[RED_C] = color[bpmem.tevksel[swaptable].swap1]; - RasColor[GRN_C] = color[bpmem.tevksel[swaptable].swap2]; - swaptable++; - RasColor[BLU_C] = color[bpmem.tevksel[swaptable].swap1]; - RasColor[ALP_C] = color[bpmem.tevksel[swaptable].swap2]; + const auto& swap = bpmem.tevksel.GetSwapTable(swaptable); + RasColor.r = color[u32(swap[ColorChannel::Red])]; + RasColor.g = color[u32(swap[ColorChannel::Green])]; + RasColor.b = color[u32(swap[ColorChannel::Blue])]; + RasColor.a = color[u32(swap[ColorChannel::Alpha])]; } break; case RasColorChan::Color1: { const u8* color = Color[1]; - RasColor[RED_C] = color[bpmem.tevksel[swaptable].swap1]; - RasColor[GRN_C] = color[bpmem.tevksel[swaptable].swap2]; - swaptable++; - RasColor[BLU_C] = color[bpmem.tevksel[swaptable].swap1]; - RasColor[ALP_C] = color[bpmem.tevksel[swaptable].swap2]; + const auto& swap = bpmem.tevksel.GetSwapTable(swaptable); + RasColor.r = color[u32(swap[ColorChannel::Red])]; + RasColor.g = color[u32(swap[ColorChannel::Green])]; + RasColor.b = color[u32(swap[ColorChannel::Blue])]; + RasColor.a = color[u32(swap[ColorChannel::Alpha])]; } break; case RasColorChan::AlphaBump: { - for (s16& comp : RasColor) - { - comp = AlphaBump; - } + RasColor = TevColor::All(AlphaBump); } break; case RasColorChan::NormalizedAlphaBump: { const u8 normalized = AlphaBump | AlphaBump >> 5; - for (s16& comp : RasColor) - { - comp = normalized; - } + RasColor = TevColor::All(normalized); } break; default: @@ -218,10 +77,7 @@ void Tev::SetRasColor(RasColorChan colorChan, int swaptable) if (colorChan != RasColorChan::Zero) PanicAlertFmt("Invalid ras color channel: {}", colorChan); - for (s16& comp : RasColor) - { - comp = 0; - } + RasColor = TevColor::All(0); } break; } @@ -236,17 +92,15 @@ void Tev::DrawColorRegular(const TevStageCombiner::ColorCombiner& cc, const Inpu const u16 c = InputReg.c + (InputReg.c >> 7); s32 temp = InputReg.a * (256 - c) + (InputReg.b * c); - temp <<= m_ScaleLShiftLUT[u32(cc.scale.Value())]; + temp <<= s_ScaleLShiftLUT[cc.scale]; temp += (cc.scale == TevScale::Divide2) ? 0 : (cc.op == TevOp::Sub) ? 127 : 128; temp >>= 8; temp = cc.op == TevOp::Sub ? -temp : temp; - s32 result = ((InputReg.d + m_BiasLUT[u32(cc.bias.Value())]) - << m_ScaleLShiftLUT[u32(cc.scale.Value())]) + - temp; - result = result >> m_ScaleRShiftLUT[u32(cc.scale.Value())]; + s32 result = ((InputReg.d + s_BiasLUT[cc.bias]) << s_ScaleLShiftLUT[cc.scale]) + temp; + result = result >> s_ScaleRShiftLUT[cc.scale]; - Reg[u32(cc.dest.Value())][i] = result; + Reg[cc.dest][i] = result; } } @@ -283,9 +137,9 @@ void Tev::DrawColorCompare(const TevStageCombiner::ColorCombiner& cc, const Inpu } if (cc.comparison == TevComparison::GT) - Reg[u32(cc.dest.Value())][i] = inputs[i].d + ((a > b) ? inputs[i].c : 0); + Reg[cc.dest][i] = inputs[i].d + ((a > b) ? inputs[i].c : 0); else - Reg[u32(cc.dest.Value())][i] = inputs[i].d + ((a == b) ? inputs[i].c : 0); + Reg[cc.dest][i] = inputs[i].d + ((a == b) ? inputs[i].c : 0); } } @@ -296,16 +150,14 @@ void Tev::DrawAlphaRegular(const TevStageCombiner::AlphaCombiner& ac, const Inpu const u16 c = InputReg.c + (InputReg.c >> 7); s32 temp = InputReg.a * (256 - c) + (InputReg.b * c); - temp <<= m_ScaleLShiftLUT[u32(ac.scale.Value())]; + temp <<= s_ScaleLShiftLUT[ac.scale]; temp += (ac.scale == TevScale::Divide2) ? 0 : (ac.op == TevOp::Sub) ? 127 : 128; temp = ac.op == TevOp::Sub ? (-temp >> 8) : (temp >> 8); - s32 result = - ((InputReg.d + m_BiasLUT[u32(ac.bias.Value())]) << m_ScaleLShiftLUT[u32(ac.scale.Value())]) + - temp; - result = result >> m_ScaleRShiftLUT[u32(ac.scale.Value())]; + s32 result = ((InputReg.d + s_BiasLUT[ac.bias]) << s_ScaleLShiftLUT[ac.scale]) + temp; + result = result >> s_ScaleRShiftLUT[ac.scale]; - Reg[u32(ac.dest.Value())][ALP_C] = result; + Reg[ac.dest].a = result; } void Tev::DrawAlphaCompare(const TevStageCombiner::AlphaCombiner& ac, const InputRegType inputs[4]) @@ -339,9 +191,9 @@ void Tev::DrawAlphaCompare(const TevStageCombiner::AlphaCombiner& ac, const Inpu } if (ac.comparison == TevComparison::GT) - Reg[u32(ac.dest.Value())][ALP_C] = inputs[ALP_C].d + ((a > b) ? inputs[ALP_C].c : 0); + Reg[ac.dest].a = inputs[ALP_C].d + ((a > b) ? inputs[ALP_C].c : 0); else - Reg[u32(ac.dest.Value())][ALP_C] = inputs[ALP_C].d + ((a == b) ? inputs[ALP_C].c : 0); + Reg[ac.dest].a = inputs[ALP_C].d + ((a == b) ? inputs[ALP_C].c : 0); } static bool AlphaCompare(int alpha, int ref, CompareMode comp) @@ -548,10 +400,10 @@ void Tev::Draw() // initial color values for (int i = 0; i < 4; i++) { - Reg[i][RED_C] = PixelShaderManager::constants.colors[i][0]; - Reg[i][GRN_C] = PixelShaderManager::constants.colors[i][1]; - Reg[i][BLU_C] = PixelShaderManager::constants.colors[i][2]; - Reg[i][ALP_C] = PixelShaderManager::constants.colors[i][3]; + Reg[static_cast<TevOutput>(i)].r = PixelShaderManager::constants.colors[i][0]; + Reg[static_cast<TevOutput>(i)].g = PixelShaderManager::constants.colors[i][1]; + Reg[static_cast<TevOutput>(i)].b = PixelShaderManager::constants.colors[i][2]; + Reg[static_cast<TevOutput>(i)].a = PixelShaderManager::constants.colors[i][3]; } for (unsigned int stageNum = 0; stageNum < bpmem.genMode.numindstages; stageNum++) @@ -593,7 +445,6 @@ void Tev::Draw() const int stageNum2 = stageNum >> 1; const int stageOdd = stageNum & 1; const TwoTevStageOrders& order = bpmem.tevorders[stageNum2]; - const TevKSel& kSel = bpmem.tevksel[stageNum2]; // stage combiners const TevStageCombiner::ColorCombiner& cc = bpmem.combiners[stageNum].colorC; @@ -632,39 +483,42 @@ void Tev::Draw() DebugUtil::DrawTempBuffer(texel, DIRECT_TFETCH + stageNum); #endif - int swaptable = ac.tswap * 2; - - TexColor[RED_C] = texel[bpmem.tevksel[swaptable].swap1]; - TexColor[GRN_C] = texel[bpmem.tevksel[swaptable].swap2]; - swaptable++; - TexColor[BLU_C] = texel[bpmem.tevksel[swaptable].swap1]; - TexColor[ALP_C] = texel[bpmem.tevksel[swaptable].swap2]; + const auto& swap = bpmem.tevksel.GetSwapTable(ac.tswap); + TexColor.r = texel[u32(swap[ColorChannel::Red])]; + TexColor.g = texel[u32(swap[ColorChannel::Green])]; + TexColor.b = texel[u32(swap[ColorChannel::Blue])]; + TexColor.a = texel[u32(swap[ColorChannel::Alpha])]; } // set konst for this stage - const auto kc = u32(kSel.getKC(stageOdd)); - const auto ka = u32(kSel.getKA(stageOdd)); - StageKonst[RED_C] = *(m_KonstLUT[kc][RED_C]); - StageKonst[GRN_C] = *(m_KonstLUT[kc][GRN_C]); - StageKonst[BLU_C] = *(m_KonstLUT[kc][BLU_C]); - StageKonst[ALP_C] = *(m_KonstLUT[ka][ALP_C]); + const auto kc = bpmem.tevksel.GetKonstColor(stageNum); + const auto ka = bpmem.tevksel.GetKonstAlpha(stageNum); + StageKonst.r = m_KonstLUT[kc].r; + StageKonst.g = m_KonstLUT[kc].g; + StageKonst.b = m_KonstLUT[kc].b; + StageKonst.a = m_KonstLUT[ka].a; // set color - SetRasColor(order.getColorChan(stageOdd), ac.rswap * 2); + SetRasColor(order.getColorChan(stageOdd), ac.rswap); // combine inputs InputRegType inputs[4]; - for (int i = 0; i < 3; i++) - { - inputs[BLU_C + i].a = *m_ColorInputLUT[u32(cc.a.Value())][i]; - inputs[BLU_C + i].b = *m_ColorInputLUT[u32(cc.b.Value())][i]; - inputs[BLU_C + i].c = *m_ColorInputLUT[u32(cc.c.Value())][i]; - inputs[BLU_C + i].d = *m_ColorInputLUT[u32(cc.d.Value())][i]; - } - inputs[ALP_C].a = *m_AlphaInputLUT[u32(ac.a.Value())]; - inputs[ALP_C].b = *m_AlphaInputLUT[u32(ac.b.Value())]; - inputs[ALP_C].c = *m_AlphaInputLUT[u32(ac.c.Value())]; - inputs[ALP_C].d = *m_AlphaInputLUT[u32(ac.d.Value())]; + inputs[BLU_C].a = m_ColorInputLUT[cc.a].b; + inputs[BLU_C].b = m_ColorInputLUT[cc.b].b; + inputs[BLU_C].c = m_ColorInputLUT[cc.c].b; + inputs[BLU_C].d = m_ColorInputLUT[cc.d].b; + inputs[GRN_C].a = m_ColorInputLUT[cc.a].g; + inputs[GRN_C].b = m_ColorInputLUT[cc.b].g; + inputs[GRN_C].c = m_ColorInputLUT[cc.c].g; + inputs[GRN_C].d = m_ColorInputLUT[cc.d].g; + inputs[RED_C].a = m_ColorInputLUT[cc.a].r; + inputs[RED_C].b = m_ColorInputLUT[cc.b].r; + inputs[RED_C].c = m_ColorInputLUT[cc.c].r; + inputs[RED_C].d = m_ColorInputLUT[cc.d].r; + inputs[ALP_C].a = m_AlphaInputLUT[ac.a].a; + inputs[ALP_C].b = m_AlphaInputLUT[ac.b].a; + inputs[ALP_C].c = m_AlphaInputLUT[ac.c].a; + inputs[ALP_C].d = m_AlphaInputLUT[ac.d].a; if (cc.bias != TevBias::Compare) DrawColorRegular(cc, inputs); @@ -673,15 +527,15 @@ void Tev::Draw() if (cc.clamp) { - Reg[u32(cc.dest.Value())][RED_C] = Clamp255(Reg[u32(cc.dest.Value())][RED_C]); - Reg[u32(cc.dest.Value())][GRN_C] = Clamp255(Reg[u32(cc.dest.Value())][GRN_C]); - Reg[u32(cc.dest.Value())][BLU_C] = Clamp255(Reg[u32(cc.dest.Value())][BLU_C]); + Reg[cc.dest].r = Clamp255(Reg[cc.dest].r); + Reg[cc.dest].g = Clamp255(Reg[cc.dest].g); + Reg[cc.dest].b = Clamp255(Reg[cc.dest].b); } else { - Reg[u32(cc.dest.Value())][RED_C] = Clamp1024(Reg[u32(cc.dest.Value())][RED_C]); - Reg[u32(cc.dest.Value())][GRN_C] = Clamp1024(Reg[u32(cc.dest.Value())][GRN_C]); - Reg[u32(cc.dest.Value())][BLU_C] = Clamp1024(Reg[u32(cc.dest.Value())][BLU_C]); + Reg[cc.dest].r = Clamp1024(Reg[cc.dest].r); + Reg[cc.dest].g = Clamp1024(Reg[cc.dest].g); + Reg[cc.dest].b = Clamp1024(Reg[cc.dest].b); } if (ac.bias != TevBias::Compare) @@ -690,14 +544,15 @@ void Tev::Draw() DrawAlphaCompare(ac, inputs); if (ac.clamp) - Reg[u32(ac.dest.Value())][ALP_C] = Clamp255(Reg[u32(ac.dest.Value())][ALP_C]); + Reg[ac.dest].a = Clamp255(Reg[ac.dest].a); else - Reg[u32(ac.dest.Value())][ALP_C] = Clamp1024(Reg[u32(ac.dest.Value())][ALP_C]); + Reg[ac.dest].a = Clamp1024(Reg[ac.dest].a); #if ALLOW_TEV_DUMPS if (g_ActiveConfig.bDumpTevStages) { - u8 stage[4] = {(u8)Reg[0][RED_C], (u8)Reg[0][GRN_C], (u8)Reg[0][BLU_C], (u8)Reg[0][ALP_C]}; + u8 stage[4] = {(u8)Reg[cc.dest].r, (u8)Reg[cc.dest].g, (u8)Reg[cc.dest].b, + (u8)Reg[ac.dest].a}; DebugUtil::DrawTempBuffer(stage, DIRECT + stageNum); } #endif @@ -706,10 +561,10 @@ void Tev::Draw() // convert to 8 bits per component // the results of the last tev stage are put onto the screen, // regardless of the used destination register - TODO: Verify! - const u32 color_index = u32(bpmem.combiners[bpmem.genMode.numtevstages].colorC.dest.Value()); - const u32 alpha_index = u32(bpmem.combiners[bpmem.genMode.numtevstages].alphaC.dest.Value()); - u8 output[4] = {(u8)Reg[alpha_index][ALP_C], (u8)Reg[color_index][BLU_C], - (u8)Reg[color_index][GRN_C], (u8)Reg[color_index][RED_C]}; + const auto& color_index = bpmem.combiners[bpmem.genMode.numtevstages].colorC.dest; + const auto& alpha_index = bpmem.combiners[bpmem.genMode.numtevstages].alphaC.dest; + u8 output[4] = {(u8)Reg[alpha_index].a, (u8)Reg[color_index].b, (u8)Reg[color_index].g, + (u8)Reg[color_index].r}; if (!TevAlphaTest(output[ALP_C])) return; @@ -882,7 +737,13 @@ void Tev::Draw() EfbInterface::BlendTev(Position[0], Position[1], output); } -void Tev::SetRegColor(int reg, int comp, s16 color) +void Tev::SetKonstColors() { - KonstantColors[reg][comp] = color; + for (int i = 0; i < 4; i++) + { + KonstantColors[i].r = PixelShaderManager::constants.kcolors[i][0]; + KonstantColors[i].g = PixelShaderManager::constants.kcolors[i][1]; + KonstantColors[i].b = PixelShaderManager::constants.kcolors[i][2]; + KonstantColors[i].a = PixelShaderManager::constants.kcolors[i][3]; + } } |
