From 767f56d7c8294e0af6163065714f46d9794d9002 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Sun, 13 Mar 2016 03:38:44 -0400 Subject: Software renderer fix --- .../Core/VideoBackends/Software/TransformUnit.cpp | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 57492cc326..0ab93ce106 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -147,14 +147,14 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo MultiplyVec3Mat34(*src, mat, *dst); } + // normalize + const PostMtxInfo& postInfo = xfmem.postMtxInfo[coordNum]; + const float* postMat = &xfmem.postMatrices[postInfo.index * 4]; + if (xfmem.dualTexTrans.enabled) { Vec3 tempCoord; - // normalize - const PostMtxInfo& postInfo = xfmem.postMtxInfo[coordNum]; - const float* postMat = &xfmem.postMatrices[postInfo.index * 4]; - if (specialCase) { // no normalization @@ -177,6 +177,23 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo MultiplyVec3Mat34(tempCoord, postMat, *dst); } } + + // TODO write comment + if(dst->z == 0.0f) + { + if(mat[8] != 0.0f || (xfmem.dualTexTrans.enabled && postMat[8] != 0.0f) || + mat[9] != 0.0f || (xfmem.dualTexTrans.enabled && postMat[9] != 0.0f)) + { + // TODO test this case more + dst->x = 0.0f; + dst->y = 0.0f; + } + else + { + dst->x = MathUtil::Clamp(dst->x / 2.0f, -1.0f, 1.0f); + dst->y = MathUtil::Clamp(dst->y / 2.0f, -1.0f, 1.0f); + } + } } struct LightPointer -- cgit v1.2.3 From 8f69de51ca35a0bf484687393bbf9b0dee31e131 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Tue, 29 Mar 2016 05:49:15 -0400 Subject: inputform ABC1's q value is defaulting to 0 This is causing the 0 divide case to run when source row is using tex0-7 and inputform is ABC1. --- .../Core/VideoBackends/Software/TransformUnit.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 0ab93ce106..6be3142534 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -106,24 +106,26 @@ void TransformNormal(const InputVertexData* src, bool nbt, OutputVertexData* dst static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bool specialCase, const InputVertexData* srcVertex, OutputVertexData* dstVertex) { - const Vec3* src; + Vec3 src; switch (texinfo.sourcerow) { case XF_SRCGEOM_INROW: - src = &srcVertex->position; + src = srcVertex->position; break; case XF_SRCNORMAL_INROW: - src = &srcVertex->normal[0]; + src = srcVertex->normal[0]; break; case XF_SRCBINORMAL_T_INROW: - src = &srcVertex->normal[1]; + src = srcVertex->normal[1]; break; case XF_SRCBINORMAL_B_INROW: - src = &srcVertex->normal[2]; + src = srcVertex->normal[2]; break; default: _assert_(texinfo.sourcerow >= XF_SRCTEX0_INROW && texinfo.sourcerow <= XF_SRCTEX7_INROW); - src = (Vec3*)srcVertex->texCoords[texinfo.sourcerow - XF_SRCTEX0_INROW]; + src.x = srcVertex->texCoords[texinfo.sourcerow - XF_SRCTEX0_INROW][0]; + src.y = srcVertex->texCoords[texinfo.sourcerow - XF_SRCTEX0_INROW][1]; + src.z = 1.0f; break; } @@ -133,18 +135,18 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo if (texinfo.projection == XF_TEXPROJ_ST) { if (texinfo.inputform == XF_TEXINPUT_AB11 || specialCase) - MultiplyVec2Mat24(*src, mat, *dst); + MultiplyVec2Mat24(src, mat, *dst); else - MultiplyVec3Mat24(*src, mat, *dst); + MultiplyVec3Mat24(src, mat, *dst); } else // texinfo.projection == XF_TEXPROJ_STQ { _assert_(!specialCase); if (texinfo.inputform == XF_TEXINPUT_AB11) - MultiplyVec2Mat34(*src, mat, *dst); + MultiplyVec2Mat34(src, mat, *dst); else - MultiplyVec3Mat34(*src, mat, *dst); + MultiplyVec3Mat34(src, mat, *dst); } // normalize -- cgit v1.2.3 From e0a1ab90274ac09d8164883c5d577f1e2778d14d Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Sat, 23 Jul 2016 06:15:03 -0500 Subject: lint fix --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 6be3142534..baddcb2529 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -181,10 +181,10 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo } // TODO write comment - if(dst->z == 0.0f) + if (dst->z == 0.0f) { - if(mat[8] != 0.0f || (xfmem.dualTexTrans.enabled && postMat[8] != 0.0f) || - mat[9] != 0.0f || (xfmem.dualTexTrans.enabled && postMat[9] != 0.0f)) + if (mat[8] != 0.0f || (xfmem.dualTexTrans.enabled && postMat[8] != 0.0f) || mat[9] != 0.0f || + (xfmem.dualTexTrans.enabled && postMat[9] != 0.0f)) { // TODO test this case more dst->x = 0.0f; -- cgit v1.2.3 From 89b1d613cceb60fa69ce48c53037c08807c45cfc Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Sat, 23 Jul 2016 21:30:39 -0500 Subject: Remove else in software renderer --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index baddcb2529..6e590dd2e9 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -183,18 +183,8 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo // TODO write comment if (dst->z == 0.0f) { - if (mat[8] != 0.0f || (xfmem.dualTexTrans.enabled && postMat[8] != 0.0f) || mat[9] != 0.0f || - (xfmem.dualTexTrans.enabled && postMat[9] != 0.0f)) - { - // TODO test this case more - dst->x = 0.0f; - dst->y = 0.0f; - } - else - { - dst->x = MathUtil::Clamp(dst->x / 2.0f, -1.0f, 1.0f); - dst->y = MathUtil::Clamp(dst->y / 2.0f, -1.0f, 1.0f); - } + dst->x = MathUtil::Clamp(dst->x / 2.0f, -1.0f, 1.0f); + dst->y = MathUtil::Clamp(dst->y / 2.0f, -1.0f, 1.0f); } } -- cgit v1.2.3 From e6ccd0729f80a54b29069de5b72ee558e04fb964 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Wed, 31 Aug 2016 02:14:51 -0500 Subject: Revert postMat movement --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 6e590dd2e9..3283bdaf51 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -149,14 +149,14 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo MultiplyVec3Mat34(src, mat, *dst); } - // normalize - const PostMtxInfo& postInfo = xfmem.postMtxInfo[coordNum]; - const float* postMat = &xfmem.postMatrices[postInfo.index * 4]; - if (xfmem.dualTexTrans.enabled) { Vec3 tempCoord; + // normalize + const PostMtxInfo& postInfo = xfmem.postMtxInfo[coordNum]; + const float* postMat = &xfmem.postMatrices[postInfo.index * 4]; + if (specialCase) { // no normalization -- cgit v1.2.3 From 94cbe0c12ade07c5ae2a1eaf980ecea1829d0bf5 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Wed, 31 Aug 2016 02:44:36 -0500 Subject: Comments --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 3283bdaf51..38734fa17c 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -180,7 +180,9 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo } } - // TODO write comment + // When q is 0, the GameCube appears to have a special case + // This can be seen in devkitPro's neheGX Lesson08 example for Wii + // Makes differences in Rogue Squadron 3 (Hoth sky) and The Last Story (shadow culling) if (dst->z == 0.0f) { dst->x = MathUtil::Clamp(dst->x / 2.0f, -1.0f, 1.0f); -- cgit v1.2.3