From f722bdf7f1ab5913d035f257ff82865a686b08d6 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 20:57:38 -0700 Subject: [PATCH] VertexLoaderX64: Refactor so that zfreeze is only in one place (Specifically, the copy for VertexLoaderManager::position_cache. The position matrix index happens elsewhere, and the float path still has special logic to copy to scratch3.) --- Source/Core/VideoCommon/VertexLoaderX64.cpp | 32 +++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp index 7a4929361d..734fa0819c 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp @@ -114,6 +114,17 @@ int VertexLoaderX64::ReadVertex(OpArg data, VertexComponentFormat attribute, Com X64Reg coords = XMM0; + const auto write_zfreeze = [&]() { // zfreeze + if (native_format == &m_native_vtx_decl.position) + { + CMP(32, R(count_reg), Imm8(3)); + FixupBranch dont_store = J_CC(CC_A); + LEA(32, scratch3, MScaled(count_reg, SCALE_4, -4)); + MOVUPS(MPIC(VertexLoaderManager::position_cache, scratch3, SCALE_4), coords); + SetJumpTarget(dont_store); + } + }; + int elem_size = GetElementSize(format); int load_bytes = elem_size * count_in; OpArg dest = MDisp(dst_reg, m_dst_ofs); @@ -217,16 +228,7 @@ int VertexLoaderX64::ReadVertex(OpArg data, VertexComponentFormat attribute, Com } } - // zfreeze - if (native_format == &m_native_vtx_decl.position) - { - CMP(32, R(count_reg), Imm8(3)); - FixupBranch dont_store = J_CC(CC_A); - LEA(32, scratch3, MScaled(count_reg, SCALE_4, -4)); - MOVUPS(MPIC(VertexLoaderManager::position_cache, scratch3, SCALE_4), coords); - SetJumpTarget(dont_store); - } - return load_bytes; + write_zfreeze(); } } @@ -251,15 +253,7 @@ int VertexLoaderX64::ReadVertex(OpArg data, VertexComponentFormat attribute, Com break; } - // zfreeze - if (native_format == &m_native_vtx_decl.position) - { - CMP(32, R(count_reg), Imm8(3)); - FixupBranch dont_store = J_CC(CC_A); - LEA(32, scratch3, MScaled(count_reg, SCALE_4, -4)); - MOVUPS(MPIC(VertexLoaderManager::position_cache, scratch3, SCALE_4), coords); - SetJumpTarget(dont_store); - } + write_zfreeze(); return load_bytes; }