From 2cff4c9c34c15ef4ed7ba99d85613e3abc4e7dcb Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Sat, 17 Aug 2024 11:15:34 -0700 Subject: [PATCH] video_core: Fix shader-interpreter conditional-code initialization Rather than reserving the incoming state of the conditional codes, the shader-interpreter was setting them both to false. In pretty much all cases, the initial state of a shaderunit can be zero-initialized statically. Just running the interpreter shouldn't necessarily reset the conditional codes though. The JIT loads incoming conditional codes while the shader-interpreter resets them to false. This makes the interpreter match the behavior of the shader-jit. --- src/video_core/pica/shader_unit.cpp | 5 +---- src/video_core/pica/shader_unit.h | 10 +++++----- src/video_core/shader/shader_interpreter.cpp | 3 --- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/video_core/pica/shader_unit.cpp b/src/video_core/pica/shader_unit.cpp index cac3ecd4a..5d81f857a 100644 --- a/src/video_core/pica/shader_unit.cpp +++ b/src/video_core/pica/shader_unit.cpp @@ -9,10 +9,7 @@ namespace Pica { -ShaderUnit::ShaderUnit(GeometryEmitter* emitter) : emitter_ptr{emitter} { - const Common::Vec4 temp_vec{f24::Zero(), f24::Zero(), f24::Zero(), f24::One()}; - temporary.fill(temp_vec); -} +ShaderUnit::ShaderUnit(GeometryEmitter* emitter) : emitter_ptr{emitter} {} ShaderUnit::~ShaderUnit() = default; diff --git a/src/video_core/pica/shader_unit.h b/src/video_core/pica/shader_unit.h index 4fa9a1496..b847c0699 100644 --- a/src/video_core/pica/shader_unit.h +++ b/src/video_core/pica/shader_unit.h @@ -46,11 +46,11 @@ struct ShaderUnit { } public: - s32 address_registers[3]; - bool conditional_code[2]; - alignas(16) std::array, 16> input; - alignas(16) std::array, 16> temporary; - alignas(16) std::array, 16> output; + s32 address_registers[3] = {}; + bool conditional_code[2] = {}; + alignas(16) std::array, 16> input = {}; + alignas(16) std::array, 16> temporary = {}; + alignas(16) std::array, 16> output = {}; GeometryEmitter* emitter_ptr; private: diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 04d9446f1..bf19c037f 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -52,9 +52,6 @@ static void RunInterpreter(const ShaderSetup& setup, ShaderUnit& state, boost::circular_buffer loop_stack(4); u32 program_counter = entry_point; - state.conditional_code[0] = false; - state.conditional_code[1] = false; - const auto do_if = [&](Instruction instr, bool condition) { if (condition) { if_stack.push_back({