From 5a6b876dbdc056d6a29229e24a6e8bfeee1b8334 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Fri, 4 Mar 2016 02:57:44 -0500 Subject: [PATCH 1/7] Hardware renderer fix --- Source/Core/VideoCommon/VertexShaderGen.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index a42f090716..469f273d89 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -381,6 +381,14 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da i, i, i, i); } + // TODO write comment + // TODO check if it only affects XF_TEXGEN_REGULAR more + if (texinfo.texgentype == XF_TEXGEN_REGULAR) + { + out.Write("if(o.tex%d.z == 0.0f)\n", i); + out.Write("\to.tex%d.xy = clamp(o.tex%d.xy / 2.0f, float2(-1.0f), float2(1.0f));\n", i, i); + } + out.Write("}\n"); } From 767f56d7c8294e0af6163065714f46d9794d9002 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Sun, 13 Mar 2016 03:38:44 -0400 Subject: [PATCH 2/7] Software renderer fix --- .../VideoBackends/Software/TransformUnit.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) 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 From 8f69de51ca35a0bf484687393bbf9b0dee31e131 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Tue, 29 Mar 2016 05:49:15 -0400 Subject: [PATCH 3/7] 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. --- .../VideoBackends/Software/TransformUnit.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 From e0a1ab90274ac09d8164883c5d577f1e2778d14d Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Sat, 23 Jul 2016 06:15:03 -0500 Subject: [PATCH 4/7] lint fix --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; From 89b1d613cceb60fa69ce48c53037c08807c45cfc Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Sat, 23 Jul 2016 21:30:39 -0500 Subject: [PATCH 5/7] Remove else in software renderer --- .../Core/VideoBackends/Software/TransformUnit.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) 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); } } From e6ccd0729f80a54b29069de5b72ee558e04fb964 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Wed, 31 Aug 2016 02:14:51 -0500 Subject: [PATCH 6/7] Revert postMat movement --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 From 94cbe0c12ade07c5ae2a1eaf980ecea1829d0bf5 Mon Sep 17 00:00:00 2001 From: Preston Smith Date: Wed, 31 Aug 2016 02:44:36 -0500 Subject: [PATCH 7/7] Comments --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 4 +++- Source/Core/VideoCommon/VertexShaderGen.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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); diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 469f273d89..5c516e0053 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -381,8 +381,10 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da i, i, i, i); } - // TODO write comment - // TODO check if it only affects XF_TEXGEN_REGULAR more + // 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) + // TODO: check if this only affects XF_TEXGEN_REGULAR if (texinfo.texgentype == XF_TEXGEN_REGULAR) { out.Write("if(o.tex%d.z == 0.0f)\n", i);