From ea9f522c0c844e63fdd54e04da6d31eb64971b5f Mon Sep 17 00:00:00 2001 From: Wunk Date: Sun, 3 Dec 2023 05:07:21 -0800 Subject: [PATCH] shader_jit_a64: Use LDP/STP for address registers (#7225) Move `address_registers` to be earlier in the `UnitState` structure to allow LDP/STP's 7-bit offset to reach these members. Follow-up of https://github.com/citra-emu/citra/pull/7002#discussion_r1367270804 --- src/video_core/shader/shader.h | 13 +++++++------ src/video_core/shader/shader_jit_a64_compiler.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index b2f137274..1b564de59 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -132,6 +132,13 @@ static_assert(std::is_standard_layout::value, "GSEmitter is not stand */ struct UnitState { explicit UnitState(GSEmitter* emitter = nullptr); + + // Two Address registers and one loop counter + // TODO: How many bits do these actually have? + s32 address_registers[3]; + + bool conditional_code[2]; + struct Registers { // The registers are accessed by the shader JIT using SSE instructions, and are therefore // required to be 16-byte aligned. @@ -150,12 +157,6 @@ struct UnitState { } registers; static_assert(std::is_trivial_v, "Structure is not POD"); - bool conditional_code[2]; - - // Two Address registers and one loop counter - // TODO: How many bits do these actually have? - s32 address_registers[3]; - GSEmitter* emitter_ptr; static std::size_t InputOffset(s32 register_index) { diff --git a/src/video_core/shader/shader_jit_a64_compiler.cpp b/src/video_core/shader/shader_jit_a64_compiler.cpp index ea6ac55c1..2afc30a3d 100644 --- a/src/video_core/shader/shader_jit_a64_compiler.cpp +++ b/src/video_core/shader/shader_jit_a64_compiler.cpp @@ -632,8 +632,8 @@ void JitShader::Compile_END(Instruction instr) { STRB(COND1.toW(), STATE, u32(offsetof(UnitState, conditional_code[1]))); // Save address/loop registers - STR(ADDROFFS_REG_0.toW(), STATE, u32(offsetof(UnitState, address_registers[0]))); - STR(ADDROFFS_REG_1.toW(), STATE, u32(offsetof(UnitState, address_registers[1]))); + STP(ADDROFFS_REG_0.toW(), ADDROFFS_REG_1.toW(), STATE, + u32(offsetof(UnitState, address_registers))); STR(LOOPCOUNT_REG.toW(), STATE, u32(offsetof(UnitState, address_registers[2]))); ABI_PopRegisters(*this, ABI_ALL_CALLEE_SAVED, 16); @@ -942,8 +942,8 @@ void JitShader::Compile(const std::array* program_ MOV(STATE, ABI_PARAM2); // Load address/loop registers - LDR(ADDROFFS_REG_0.toW(), STATE, u32(offsetof(UnitState, address_registers[0]))); - LDR(ADDROFFS_REG_1.toW(), STATE, u32(offsetof(UnitState, address_registers[1]))); + LDP(ADDROFFS_REG_0.toW(), ADDROFFS_REG_1.toW(), STATE, + u32(offsetof(UnitState, address_registers))); LDR(LOOPCOUNT_REG.toW(), STATE, u32(offsetof(UnitState, address_registers[2]))); //// Load conditional code