yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

shader: Use memset to reset instruction arguments

This commit is contained in:
ReinUsesLisp 2021-04-21 02:43:44 -03:00 committed by ameerj
parent c84bbd9e44
commit f66851e376
2 changed files with 7 additions and 4 deletions

View File

@ -279,8 +279,10 @@ void Inst::ClearArgs() {
if (!value.IsImmediate()) { if (!value.IsImmediate()) {
UndoUse(value); UndoUse(value);
} }
value = {};
} }
// Reset arguments to null
// std::memset was measured to be faster on MSVC than std::ranges:fill
std::memset(&args, 0, sizeof(args));
} }
} }

View File

@ -34,7 +34,7 @@ struct AssociatedInsts;
class Value { class Value {
public: public:
Value() noexcept : type{IR::Type::Void}, inst{nullptr} {} Value() noexcept = default;
explicit Value(IR::Inst* value) noexcept; explicit Value(IR::Inst* value) noexcept;
explicit Value(IR::Block* value) noexcept; explicit Value(IR::Block* value) noexcept;
explicit Value(IR::Reg value) noexcept; explicit Value(IR::Reg value) noexcept;
@ -78,9 +78,9 @@ public:
private: private:
void ValidateAccess(IR::Type expected) const; void ValidateAccess(IR::Type expected) const;
IR::Type type; IR::Type type{};
union { union {
IR::Inst* inst; IR::Inst* inst{};
IR::Block* label; IR::Block* label;
IR::Reg reg; IR::Reg reg;
IR::Pred pred; IR::Pred pred;
@ -95,6 +95,7 @@ private:
f64 imm_f64; f64 imm_f64;
}; };
}; };
static_assert(static_cast<u32>(IR::Type::Void) == 0, "memset relies on IR::Type being zero");
static_assert(std::is_trivially_copyable_v<Value>); static_assert(std::is_trivially_copyable_v<Value>);
template <IR::Type type_> template <IR::Type type_>