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)};
|
const IR::Value arg{Arg(index)};
|
||||||
if (!arg.IsImmediate()) {
|
if (!arg.IsImmediate()) {
|
||||||
UndoUse(arg.Inst());
|
UndoUse(arg.Inst(), index);
|
||||||
}
|
}
|
||||||
if (!value.IsImmediate()) {
|
if (!value.IsImmediate()) {
|
||||||
Use(value.Inst(), index);
|
Use(value.Inst(), index);
|
||||||
@ -153,17 +153,19 @@ void Inst::Invalidate() {
|
|||||||
|
|
||||||
void Inst::ClearArgs() {
|
void Inst::ClearArgs() {
|
||||||
if (op == Opcode::Phi) {
|
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};
|
IR::Value& value{pair.second};
|
||||||
if (!value.IsImmediate()) {
|
if (!value.IsImmediate()) {
|
||||||
UndoUse(value.Inst());
|
UndoUse(value.Inst(), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
phi_args.clear();
|
phi_args.clear();
|
||||||
} else {
|
} else {
|
||||||
for (auto& value : args) {
|
for (auto i = 0; i < args.size(); i++) {
|
||||||
|
auto& value = args[i];
|
||||||
if (!value.IsImmediate()) {
|
if (!value.IsImmediate()) {
|
||||||
UndoUse(value.Inst());
|
UndoUse(value.Inst(), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reset arguments to null
|
// Reset arguments to null
|
||||||
@ -198,8 +200,9 @@ void Inst::Use(Inst* used, u32 operand) {
|
|||||||
used->uses.emplace_front(this, operand);
|
used->uses.emplace_front(this, operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inst::UndoUse(Inst* used) {
|
void Inst::UndoUse(Inst* used, u32 operand) {
|
||||||
used->uses.remove_if([this](const IR::Use& use) { return use.user == this; });
|
IR::Use use(this, operand);
|
||||||
|
used->uses.remove(use);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Shader::IR
|
} // namespace Shader::IR
|
||||||
|
@ -109,6 +109,11 @@ public:
|
|||||||
struct Use {
|
struct Use {
|
||||||
Inst* user;
|
Inst* user;
|
||||||
u32 operand;
|
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<> {
|
class Inst : public boost::intrusive::list_base_hook<> {
|
||||||
@ -207,7 +212,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void Use(Inst* used, u32 operand);
|
void Use(Inst* used, u32 operand);
|
||||||
void UndoUse(Inst* used);
|
void UndoUse(Inst* used, u32 operand);
|
||||||
|
|
||||||
IR::Opcode op{};
|
IR::Opcode op{};
|
||||||
u32 flags{};
|
u32 flags{};
|
||||||
|
Loading…
Reference in New Issue
Block a user