From e1d36f91fc72c4e0b0ff5c8fea01ee60276c20ff Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 27 Feb 2016 22:45:05 -0600 Subject: [PATCH 1/3] Fix a few asserts in the VertexShaderGen. Removes a couple asserts in the vertex shader gen when dealing with the input form. Typically input form ABC1 is used, so it'll pull in the first three elements and always set the fourth to 1.0 The other input form available is AB11, which sets the last two components to 1.0 (Theoretically). No titles actually use this input form that we know of except for Project M, but it can have some fairly drastic visual differences. Confirmed correct by hardware test --- Source/Core/VideoCommon/VertexShaderGen.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index feb94bfa5d..c613e237d0 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -198,15 +198,12 @@ static T GenerateVertexShader(API_TYPE api_type) switch (texinfo.sourcerow) { case XF_SRCGEOM_INROW: - // The following assert was triggered in Super Smash Bros. Project M 3.6. - //_assert_(texinfo.inputform == XF_TEXINPUT_ABC1); - out.Write("coord = rawpos;\n"); // pos.w is 1 + out.Write("coord.xyz = rawpos.xyz;\n"); break; case XF_SRCNORMAL_INROW: if (components & VB_HAS_NRM0) { - _assert_(texinfo.inputform == XF_TEXINPUT_ABC1); - out.Write("coord = float4(rawnorm0.xyz, 1.0);\n"); + out.Write("coord.xyz = rawnorm0.xyz;\n"); } break; case XF_SRCCOLORS_INROW: @@ -215,15 +212,13 @@ static T GenerateVertexShader(API_TYPE api_type) case XF_SRCBINORMAL_T_INROW: if (components & VB_HAS_NRM1) { - _assert_(texinfo.inputform == XF_TEXINPUT_ABC1); - out.Write("coord = float4(rawnorm1.xyz, 1.0);\n"); + out.Write("coord.xyz = rawnorm1.xyz;\n"); } break; case XF_SRCBINORMAL_B_INROW: if (components & VB_HAS_NRM2) { - _assert_(texinfo.inputform == XF_TEXINPUT_ABC1); - out.Write("coord = float4(rawnorm2.xyz, 1.0);\n"); + out.Write("coord.xyz = rawnorm2.xyz;\n"); } break; default: @@ -232,6 +227,12 @@ static T GenerateVertexShader(API_TYPE api_type) out.Write("coord = float4(tex%d.x, tex%d.y, 1.0, 1.0);\n", texinfo.sourcerow - XF_SRCTEX0_INROW, texinfo.sourcerow - XF_SRCTEX0_INROW); break; } + // An input form other than ABC1 or AB11 doesn't exist + // But the hardware has it as a two bit field + _assert_(texinfo.inputform == XF_TEXINPUT_ABC1 || texinfo.inputform == XF_TEXINPUT_AB11); + uid_data->texMtxInfo[i].inputform = xfmem.texMtxInfo[i].inputform; + if (texinfo.inputform == XF_TEXINPUT_AB11) + out.Write("coord.z = 1.0;\n"); // first transformation uid_data->texMtxInfo[i].texgentype = xfmem.texMtxInfo[i].texgentype; From 92e9382e6192fb0a696876b60a5f112a5a450b55 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 29 Feb 2016 11:52:25 -0600 Subject: [PATCH 2/3] Confirm with hardware test that the high bit of the input form is ignored. Thanks to Ornox for testing --- Source/Core/VideoCommon/VertexShaderGen.cpp | 4 +--- Source/Core/VideoCommon/XFMemory.h | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index c613e237d0..313d1bc5f7 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -227,9 +227,7 @@ static T GenerateVertexShader(API_TYPE api_type) out.Write("coord = float4(tex%d.x, tex%d.y, 1.0, 1.0);\n", texinfo.sourcerow - XF_SRCTEX0_INROW, texinfo.sourcerow - XF_SRCTEX0_INROW); break; } - // An input form other than ABC1 or AB11 doesn't exist - // But the hardware has it as a two bit field - _assert_(texinfo.inputform == XF_TEXINPUT_ABC1 || texinfo.inputform == XF_TEXINPUT_AB11); + // Input form of AB11 sets z element to 1.0 uid_data->texMtxInfo[i].inputform = xfmem.texMtxInfo[i].inputform; if (texinfo.inputform == XF_TEXINPUT_AB11) out.Write("coord.z = 1.0;\n"); diff --git a/Source/Core/VideoCommon/XFMemory.h b/Source/Core/VideoCommon/XFMemory.h index 006383df89..99d01f2d45 100644 --- a/Source/Core/VideoCommon/XFMemory.h +++ b/Source/Core/VideoCommon/XFMemory.h @@ -178,7 +178,8 @@ union TexMtxInfo { u32 unknown : 1; u32 projection : 1; // XF_TEXPROJ_X - u32 inputform : 2; // XF_TEXINPUT_X + u32 inputform : 1; // XF_TEXINPUT_X + u32 unknown2 : 1; u32 texgentype : 3; // XF_TEXGEN_X u32 sourcerow : 5; // XF_SRCGEOM_X u32 embosssourceshift : 3; // what generated texcoord to use From a8c37e5d6b5cb2deddfab180193768ad0d469db6 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 29 Feb 2016 16:26:30 -0600 Subject: [PATCH 3/3] Remove two more asserts in VertexShaderGen. As confirmed by a hardware test if we are using the texgen type of COLOR_STRGBC0/STRGBC1 then it sets the texture coordinates to those values regardless of what the input form or source row is. Thanks to Ornox for testing again --- Source/Core/VideoCommon/VertexShaderGen.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 313d1bc5f7..83e1d34d6c 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -256,11 +256,9 @@ static T GenerateVertexShader(API_TYPE api_type) break; case XF_TEXGEN_COLOR_STRGBC0: - _assert_(texinfo.sourcerow == XF_SRCCOLORS_INROW); out.Write("o.tex%d.xyz = float3(o.colors_0.x, o.colors_0.y, 1);\n", i); break; case XF_TEXGEN_COLOR_STRGBC1: - _assert_(texinfo.sourcerow == XF_SRCCOLORS_INROW); out.Write("o.tex%d.xyz = float3(o.colors_1.x, o.colors_1.y, 1);\n", i); break; case XF_TEXGEN_REGULAR: