diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-01-20 02:36:24 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-01-20 02:36:24 +0100 |
| commit | cb26ea154c9eedc5fd8dae33a39cd86ca1d927ab (patch) | |
| tree | 5addebc8590651657622d8dd25ed71dcef866183 /src/shader_recompiler/ir_opt/identity_removal_pass.cpp | |
| parent | 86639135109f69b780c3cd3e9734c950798932cc (diff) | |
[vk, ogl/IR, dynarmic/IR] friendlier IR identity pointer chasing, inline AA passes (#3250)
Only merge once we find out wth is causing the crashes [we know it's fsr]
This reverts commit 82f9d489e7916318b56dac59fc52efc46fe0df7e.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3250
Reviewed-by: DraVee <dravee@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/shader_recompiler/ir_opt/identity_removal_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/identity_removal_pass.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/shader_recompiler/ir_opt/identity_removal_pass.cpp b/src/shader_recompiler/ir_opt/identity_removal_pass.cpp index 951534bbf2..cac0d20e78 100644 --- a/src/shader_recompiler/ir_opt/identity_removal_pass.cpp +++ b/src/shader_recompiler/ir_opt/identity_removal_pass.cpp @@ -1,7 +1,11 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include <vector> +#include <boost/container/small_vector.hpp> #include "shader_recompiler/frontend/ir/basic_block.h" #include "shader_recompiler/frontend/ir/value.h" @@ -10,28 +14,30 @@ namespace Shader::Optimization { void IdentityRemovalPass(IR::Program& program) { - std::vector<IR::Inst*> to_invalidate; + boost::container::small_vector<IR::Inst*, 16> to_invalidate; for (IR::Block* const block : program.blocks) { - for (auto inst = block->begin(); inst != block->end();) { - const size_t num_args{inst->NumArgs()}; + for (auto it = block->begin(); it != block->end();) { + const size_t num_args{it->NumArgs()}; for (size_t i = 0; i < num_args; ++i) { - IR::Value arg; - while ((arg = inst->Arg(i)).IsIdentity()) { - inst->SetArg(i, arg.Inst()->Arg(0)); + IR::Value arg = it->Arg(i); + if (arg.IsIdentity()) { + do { // Pointer chasing (3-derefs) + arg = arg.Inst()->Arg(0); + } while (arg.IsIdentity()); + it->SetArg(i, arg); } } - if (inst->GetOpcode() == IR::Opcode::Identity || - inst->GetOpcode() == IR::Opcode::Void) { - to_invalidate.push_back(&*inst); - inst = block->Instructions().erase(inst); + + if (it->GetOpcode() == IR::Opcode::Identity || it->GetOpcode() == IR::Opcode::Void) { + to_invalidate.push_back(&*it); + it = block->Instructions().erase(it); } else { - ++inst; + ++it; } } } - for (IR::Inst* const inst : to_invalidate) { + for (IR::Inst* const inst : to_invalidate) inst->Invalidate(); - } } } // namespace Shader::Optimization |
