mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
fix undouse
This commit is contained in:
parent
6036cc8f79
commit
c4d47ff48d
@ -116,7 +116,7 @@ void Inst::SetArg(size_t index, Value value) {
|
||||
}
|
||||
const IR::Value arg{Arg(index)};
|
||||
if (!arg.IsImmediate()) {
|
||||
UndoUse(arg.Inst());
|
||||
UndoUse(arg.Inst(), index);
|
||||
}
|
||||
if (!value.IsImmediate()) {
|
||||
Use(value.Inst(), index);
|
||||
@ -153,17 +153,19 @@ void Inst::Invalidate() {
|
||||
|
||||
void Inst::ClearArgs() {
|
||||
if (op == Opcode::Phi) {
|
||||
for (auto& pair : phi_args) {
|
||||
for (auto i = 0; i < phi_args.size(); i++) {
|
||||
auto& pair = phi_args[i];
|
||||
IR::Value& value{pair.second};
|
||||
if (!value.IsImmediate()) {
|
||||
UndoUse(value.Inst());
|
||||
UndoUse(value.Inst(), i);
|
||||
}
|
||||
}
|
||||
phi_args.clear();
|
||||
} else {
|
||||
for (auto& value : args) {
|
||||
for (auto i = 0; i < args.size(); i++) {
|
||||
auto& value = args[i];
|
||||
if (!value.IsImmediate()) {
|
||||
UndoUse(value.Inst());
|
||||
UndoUse(value.Inst(), i);
|
||||
}
|
||||
}
|
||||
// Reset arguments to null
|
||||
@ -198,8 +200,9 @@ void Inst::Use(Inst* used, u32 operand) {
|
||||
used->uses.emplace_front(this, operand);
|
||||
}
|
||||
|
||||
void Inst::UndoUse(Inst* used) {
|
||||
used->uses.remove_if([this](const IR::Use& use) { return use.user == this; });
|
||||
void Inst::UndoUse(Inst* used, u32 operand) {
|
||||
IR::Use use(this, operand);
|
||||
used->uses.remove(use);
|
||||
}
|
||||
|
||||
} // namespace Shader::IR
|
||||
|
@ -109,6 +109,11 @@ public:
|
||||
struct Use {
|
||||
Inst* user;
|
||||
u32 operand;
|
||||
|
||||
Use() = default;
|
||||
Use(Inst* user_, u32 operand_) : user(user_), operand(operand_) {}
|
||||
Use(const Use&) = default;
|
||||
bool operator==(const Use&) const noexcept = default;
|
||||
};
|
||||
|
||||
class Inst : public boost::intrusive::list_base_hook<> {
|
||||
@ -207,7 +212,7 @@ private:
|
||||
};
|
||||
|
||||
void Use(Inst* used, u32 operand);
|
||||
void UndoUse(Inst* used);
|
||||
void UndoUse(Inst* used, u32 operand);
|
||||
|
||||
IR::Opcode op{};
|
||||
u32 flags{};
|
||||
|
Loading…
Reference in New Issue
Block a user