summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/Tev.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-04-10 17:41:06 -0700
committerPokechu22 <Pokechu022@gmail.com>2021-05-07 16:27:52 -0700
commitc3668e179c28dbe769f8a128e780a2269044f962 (patch)
tree63cd94129a280825bc80299fd71fb319ae27ab7d /Source/Core/VideoBackends/Software/Tev.cpp
parent1d628d087b96b95586d666b1431a42ab00ee22f3 (diff)
Split TevStageIndirect::mid into matrix_index and matrix_id
Diffstat (limited to 'Source/Core/VideoBackends/Software/Tev.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/Tev.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp
index 65227339e4..30258f6cd3 100644
--- a/Source/Core/VideoBackends/Software/Tev.cpp
+++ b/Source/Core/VideoBackends/Software/Tev.cpp
@@ -485,20 +485,16 @@ void Tev::Indirect(unsigned int stageNum, s32 s, s32 t)
// matrix multiply - results might overflow, but we don't care since we only use the lower 24 bits
// of the result.
- const int indmtxid = indirect.mid & 3;
- if (indmtxid)
+ if (indirect.matrix_index != IndMtxIndex::Off)
{
- const IND_MTX& indmtx = bpmem.indmtx[indmtxid - 1];
- const int scale =
- ((u32)indmtx.col0.s0 << 0) | ((u32)indmtx.col1.s1 << 2) | ((u32)indmtx.col2.s2 << 4);
+ const IND_MTX& indmtx = bpmem.indmtx[static_cast<u32>(indirect.matrix_index.Value()) - 1];
- int shift;
+ const int shift = 17 - indmtx.GetScale();
- switch (indirect.mid & 12)
+ switch (indirect.matrix_id)
{
- case 0:
+ case IndMtxId::Indirect:
// matrix values are S0.10, output format is S17.7, so divide by 8
- shift = (17 - scale);
indtevtrans[0] = (indmtx.col0.ma * indcoord[0] + indmtx.col1.mc * indcoord[1] +
indmtx.col2.me * indcoord[2]) >>
3;
@@ -506,25 +502,29 @@ void Tev::Indirect(unsigned int stageNum, s32 s, s32 t)
indmtx.col2.mf * indcoord[2]) >>
3;
break;
- case 4: // s matrix
+ case IndMtxId::S:
// s is S17.7, matrix elements are divided by 256, output is S17.7, so divide by 256. - TODO:
// Maybe, since s is actually stored as S24, we should divide by 256*64?
- shift = (17 - scale);
indtevtrans[0] = s * indcoord[0] / 256;
indtevtrans[1] = t * indcoord[0] / 256;
break;
- case 8: // t matrix
- shift = (17 - scale);
+ case IndMtxId::T:
indtevtrans[0] = s * indcoord[1] / 256;
indtevtrans[1] = t * indcoord[1] / 256;
break;
default:
+ PanicAlertFmt("Invalid indirect matrix ID {}", indirect.matrix_id);
return;
}
indtevtrans[0] = shift >= 0 ? indtevtrans[0] >> shift : indtevtrans[0] << -shift;
indtevtrans[1] = shift >= 0 ? indtevtrans[1] >> shift : indtevtrans[1] << -shift;
}
+ else
+ {
+ // If matrix_index is Off (0), matrix_id should be Indirect (0)
+ ASSERT(indirect.matrix_id == IndMtxId::Indirect);
+ }
if (indirect.fb_addprev)
{