From 6f1350ae51fec828c3440721588d10cccd893998 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 17:03:53 -0700 Subject: VertexLoaderARM64: Fix z-freeze position matrix index Before, it would always write to index 0 (which is unused). Now it writes to the correct index. --- Source/Core/VideoCommon/VertexLoaderARM64.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VertexLoaderARM64.cpp') diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index 330deef548..7c47f153a6 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -423,7 +423,7 @@ void VertexLoaderARM64::GenerateVertexLoader() CMP(count_reg, 3); FixupBranch dont_store = B(CC_GT); MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index); - STR(IndexType::Unsigned, scratch1_reg, EncodeRegTo64(scratch2_reg), 0); + STR(scratch1_reg, EncodeRegTo64(scratch2_reg), ArithOption(count_reg, true)); SetJumpTarget(dont_store); m_native_vtx_decl.posmtx.components = 4; -- cgit v1.2.3 From 97d0ff58c8dbe374a1b87e1a72f1f245ed27ed96 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 16:12:53 -0700 Subject: Convert vertex loader position cache to std::array --- Source/Core/VideoCommon/VertexLoaderARM64.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoaderARM64.cpp') diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index 7c47f153a6..a191dbb2c8 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -211,10 +211,11 @@ int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentForm { CMP(count_reg, 3); FixupBranch dont_store = B(CC_GT); - MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_cache); + MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_cache.data()); ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch2_reg), EncodeRegTo64(count_reg), ArithOption(EncodeRegTo64(count_reg), ShiftType::LSL, 4)); - m_float_emit.STUR(write_size, coords, EncodeRegTo64(scratch1_reg), -16); + m_float_emit.STUR(write_size, coords, EncodeRegTo64(scratch1_reg), + -int(sizeof(decltype(VertexLoaderManager::position_cache[0])))); SetJumpTarget(dont_store); } @@ -422,7 +423,7 @@ void VertexLoaderARM64::GenerateVertexLoader() // Z-Freeze CMP(count_reg, 3); FixupBranch dont_store = B(CC_GT); - MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index); + MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index_cache.data()); STR(scratch1_reg, EncodeRegTo64(scratch2_reg), ArithOption(count_reg, true)); SetJumpTarget(dont_store); -- cgit v1.2.3 From 39b2854b981aadec1576254ad5e4d91dc21c9709 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Thu, 14 Apr 2022 12:01:57 -0700 Subject: VertexLoader: Convert count register to remaining register This more accurately represents what's going on, and also ends at 0 instead of 1, making some indexing operations easier. This also changes it so that position_matrix_index_cache actually starts from index 0 instead of index 1. --- Source/Core/VideoCommon/VertexLoaderARM64.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoaderARM64.cpp') diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index a191dbb2c8..ab9ced5d8a 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -14,7 +14,7 @@ using namespace Arm64Gen; constexpr ARM64Reg src_reg = ARM64Reg::X0; constexpr ARM64Reg dst_reg = ARM64Reg::X1; -constexpr ARM64Reg count_reg = ARM64Reg::W2; +constexpr ARM64Reg remaining_reg = ARM64Reg::W2; constexpr ARM64Reg skipped_reg = ARM64Reg::W17; constexpr ARM64Reg scratch1_reg = ARM64Reg::W16; constexpr ARM64Reg scratch2_reg = ARM64Reg::W15; @@ -209,13 +209,10 @@ int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentForm // Z-Freeze if (native_format == &m_native_vtx_decl.position) { - CMP(count_reg, 3); - FixupBranch dont_store = B(CC_GT); + CMP(remaining_reg, 3); + FixupBranch dont_store = B(CC_GE); MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_cache.data()); - ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch2_reg), EncodeRegTo64(count_reg), - ArithOption(EncodeRegTo64(count_reg), ShiftType::LSL, 4)); - m_float_emit.STUR(write_size, coords, EncodeRegTo64(scratch1_reg), - -int(sizeof(decltype(VertexLoaderManager::position_cache[0])))); + m_float_emit.STR(128, coords, EncodeRegTo64(scratch2_reg), ArithOption(remaining_reg, true)); SetJumpTarget(dont_store); } @@ -404,7 +401,7 @@ void VertexLoaderARM64::GenerateVertexLoader() AlignCode16(); if (IsIndexed(m_VtxDesc.low.Position)) MOV(skipped_reg, ARM64Reg::WZR); - MOV(saved_count, count_reg); + ADD(saved_count, remaining_reg, 1); MOVP2R(stride_reg, g_main_cp_state.array_strides.data()); MOVP2R(arraybase_reg, VertexLoaderManager::cached_arraybases.data()); @@ -421,10 +418,10 @@ void VertexLoaderARM64::GenerateVertexLoader() STR(IndexType::Unsigned, scratch1_reg, dst_reg, m_dst_ofs); // Z-Freeze - CMP(count_reg, 3); - FixupBranch dont_store = B(CC_GT); + CMP(remaining_reg, 3); + FixupBranch dont_store = B(CC_GE); MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index_cache.data()); - STR(scratch1_reg, EncodeRegTo64(scratch2_reg), ArithOption(count_reg, true)); + STR(scratch1_reg, EncodeRegTo64(scratch2_reg), ArithOption(remaining_reg, true)); SetJumpTarget(dont_store); m_native_vtx_decl.posmtx.components = 4; @@ -584,8 +581,8 @@ void VertexLoaderARM64::GenerateVertexLoader() const u8* cont = GetCodePtr(); ADD(src_reg, src_reg, m_src_ofs); - SUB(count_reg, count_reg, 1); - CBNZ(count_reg, loop_start); + SUBS(remaining_reg, remaining_reg, 1); + B(CCFlags::CC_GE, loop_start); if (IsIndexed(m_VtxDesc.low.Position)) { @@ -612,5 +609,5 @@ int VertexLoaderARM64::RunVertices(DataReader src, DataReader dst, int count) { m_numLoadedVertices += count; return ((int (*)(u8 * src, u8 * dst, int count)) region)(src.GetPointer(), dst.GetPointer(), - count); + count - 1); } -- cgit v1.2.3 From 2a5c77f43ff1d69e78f12f13435a38c5eb2ed854 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 22:03:34 -0700 Subject: VideoCommon: Handle emboss texgen with only a single normal Fixes a large number of effects in Rogue Squadron 2 and 3. --- Source/Core/VideoCommon/VertexLoaderARM64.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Source/Core/VideoCommon/VertexLoaderARM64.cpp') diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index ab9ced5d8a..eff8a29993 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -215,6 +215,20 @@ int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentForm m_float_emit.STR(128, coords, EncodeRegTo64(scratch2_reg), ArithOption(remaining_reg, true)); SetJumpTarget(dont_store); } + else if (native_format == &m_native_vtx_decl.normals[1]) + { + FixupBranch dont_store = CBNZ(remaining_reg); + MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::tangent_cache.data()); + m_float_emit.STR(128, IndexType::Unsigned, coords, EncodeRegTo64(scratch2_reg), 0); + SetJumpTarget(dont_store); + } + else if (native_format == &m_native_vtx_decl.normals[2]) + { + FixupBranch dont_store = CBNZ(remaining_reg); + MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::binormal_cache.data()); + m_float_emit.STR(128, IndexType::Unsigned, coords, EncodeRegTo64(scratch2_reg), 0); + SetJumpTarget(dont_store); + } native_format->components = count_out; native_format->enable = true; -- cgit v1.2.3