From a510de0e4c8ad5712d5f30f37378c77d39887c9b Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Sat, 17 Aug 2024 12:42:38 -0700 Subject: [PATCH] shader_jit_x64: Fix conditional evaluation extended-bit hazard The unit test seems to have identified a bug in the x64 jit too. The x64 jit was doing 32-bit comparisons despite the condition flags being 8-bit values and is sensitive to garbage being in the upper 24 bits of the register. This is fixed by using the proper 8-bit register types rather than the 32-bit ones(`eax,`ebx` -> `al`, `bl`). --- .../shader/shader_jit_x64_compiler.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/video_core/shader/shader_jit_x64_compiler.cpp b/src/video_core/shader/shader_jit_x64_compiler.cpp index f04492eeb..ae80b694f 100644 --- a/src/video_core/shader/shader_jit_x64_compiler.cpp +++ b/src/video_core/shader/shader_jit_x64_compiler.cpp @@ -401,29 +401,29 @@ void JitShader::Compile_EvaluateCondition(Instruction instr) { // Note: NXOR is used below to check for equality switch (instr.flow_control.op) { case Instruction::FlowControlType::Or: - mov(eax, COND0); - mov(ebx, COND1); - xor_(eax, (instr.flow_control.refx.Value() ^ 1)); - xor_(ebx, (instr.flow_control.refy.Value() ^ 1)); - or_(eax, ebx); + mov(al, COND0.cvt8()); + mov(bl, COND1.cvt8()); + xor_(al, (instr.flow_control.refx.Value() ^ 1)); + xor_(bl, (instr.flow_control.refy.Value() ^ 1)); + or_(al, bl); break; case Instruction::FlowControlType::And: - mov(eax, COND0); - mov(ebx, COND1); - xor_(eax, (instr.flow_control.refx.Value() ^ 1)); - xor_(ebx, (instr.flow_control.refy.Value() ^ 1)); - and_(eax, ebx); + mov(al, COND0); + mov(bl, COND1); + xor_(al, (instr.flow_control.refx.Value() ^ 1)); + xor_(bl, (instr.flow_control.refy.Value() ^ 1)); + and_(al, bl); break; case Instruction::FlowControlType::JustX: - mov(eax, COND0); - xor_(eax, (instr.flow_control.refx.Value() ^ 1)); + mov(al, COND0); + xor_(al, (instr.flow_control.refx.Value() ^ 1)); break; case Instruction::FlowControlType::JustY: - mov(eax, COND1); - xor_(eax, (instr.flow_control.refy.Value() ^ 1)); + mov(al, COND1); + xor_(al, (instr.flow_control.refy.Value() ^ 1)); break; } }