Skip to content

Commit

Permalink
Re-delete bitfield's copy-assignment operator
Browse files Browse the repository at this point in the history
Now, the move-assignment operator is provided so that unions can be assigned to with the CGX defaults.
  • Loading branch information
Pokechu22 committed Apr 20, 2022
1 parent 2967cdc commit 5c524b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions common/BitField.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,22 @@ struct BitField
// Force default constructor to be created
// so that we can use this within unions
constexpr BitField() = default;
constexpr BitField(const BitField&) = default;
constexpr BitField(BitField&&) = default;

// Warning! This copies ALL storage bits, not just the bits represented by this bitfield.
// This exists so that unions can be copyable.
BitField& operator=(const BitField&) = default;
// We explicitly delete the copy assignment operator here, because the
// default copy assignment would copy the full storage value, rather than
// just the bits relevant to this particular bit field.
// Ideally, we would just implement the copy assignment to copy only the
// relevant bits, but we're prevented from doing that because the savestate
// code expects that this class is trivially copyable.
BitField& operator=(const BitField&) = delete;
// The move-assignment operator is still supplied so that unions can be
// assigned to. This still copies the full storage value, but that's the
// desired behavior when assigning to unions, so there's no issue with that.
// Note that this is still functions as a copy-assignment operator; the other
// bitfield is not modified.
BitField& operator=(BitField&&) = default;

BitField& operator=(T val)
{
Expand Down
2 changes: 1 addition & 1 deletion gxtest/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Vec4<int> GetTevOutput(const GenMode& genmode, const TevStageCombiner::ColorComb
// Uses three additional TEV stages which shift the previous result
// three bits to the right. This is necessary to read off the 5 upper bits,
// 3 of which got masked off when writing to the EFB in the first pass.
gm = genmode;
gm.hex = genmode.hex;
gm.numtevstages = previous_stage + 3; // three additional stages
CGX_LOAD_BP_REG(gm.hex);

Expand Down

0 comments on commit 5c524b9

Please sign in to comment.