Replace Common::BitCast with std::bit_cast

This commit is contained in:
Pokechu22
2022-08-05 21:10:17 -07:00
parent 57c890d4fc
commit fbbfea8e8e
36 changed files with 177 additions and 215 deletions

View File

@ -3,7 +3,7 @@
#include "VideoCommon/BPMemory.h"
#include "Common/BitUtils.h"
#include <bit>
// BP state
// STATE_TO_SAVE
@ -50,14 +50,14 @@ float FogParam0::FloatValue() const
{
// scale mantissa from 11 to 23 bits
const u32 integral = (sign << 31) | (exp << 23) | (mant << 12);
return Common::BitCast<float>(integral);
return std::bit_cast<float>(integral);
}
float FogParam3::FloatValue() const
{
// scale mantissa from 11 to 23 bits
const u32 integral = (c_sign << 31) | (c_exp << 23) | (c_mant << 12);
return Common::BitCast<float>(integral);
return std::bit_cast<float>(integral);
}
float FogParams::GetA() const

View File

@ -113,7 +113,7 @@ public:
// Some games (e.g. Donkey Kong Country Returns) have a few draws that contain NaN.
// Since NaN != NaN, we need to compare the bits instead.
const auto bit_equal = [](float val_a, float val_b) {
return Common::BitCast<u32>(val_a) == Common::BitCast<u32>(val_b);
return std::bit_cast<u32>(val_a) == std::bit_cast<u32>(val_b);
};
// The last element is allowed to be garbage for SIMD overwrites.

View File

@ -3,7 +3,8 @@
#include "VideoCommon/XFStructs.h"
#include "Common/BitUtils.h"
#include <bit>
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
@ -379,42 +380,42 @@ std::pair<std::string, std::string> GetXFRegInfo(u32 address, u32 value)
case XFMEM_SETVIEWPORT:
return std::make_pair(RegName(XFMEM_SETVIEWPORT + 0),
fmt::format("Viewport width: {}", Common::BitCast<float>(value)));
fmt::format("Viewport width: {}", std::bit_cast<float>(value)));
case XFMEM_SETVIEWPORT + 1:
return std::make_pair(RegName(XFMEM_SETVIEWPORT + 1),
fmt::format("Viewport height: {}", Common::BitCast<float>(value)));
fmt::format("Viewport height: {}", std::bit_cast<float>(value)));
case XFMEM_SETVIEWPORT + 2:
return std::make_pair(RegName(XFMEM_SETVIEWPORT + 2),
fmt::format("Viewport z range: {}", Common::BitCast<float>(value)));
fmt::format("Viewport z range: {}", std::bit_cast<float>(value)));
case XFMEM_SETVIEWPORT + 3:
return std::make_pair(RegName(XFMEM_SETVIEWPORT + 3),
fmt::format("Viewport x origin: {}", Common::BitCast<float>(value)));
fmt::format("Viewport x origin: {}", std::bit_cast<float>(value)));
case XFMEM_SETVIEWPORT + 4:
return std::make_pair(RegName(XFMEM_SETVIEWPORT + 4),
fmt::format("Viewport y origin: {}", Common::BitCast<float>(value)));
fmt::format("Viewport y origin: {}", std::bit_cast<float>(value)));
case XFMEM_SETVIEWPORT + 5:
return std::make_pair(RegName(XFMEM_SETVIEWPORT + 5),
fmt::format("Viewport far z: {}", Common::BitCast<float>(value)));
fmt::format("Viewport far z: {}", std::bit_cast<float>(value)));
break;
case XFMEM_SETPROJECTION:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 0),
fmt::format("Projection[0]: {}", Common::BitCast<float>(value)));
fmt::format("Projection[0]: {}", std::bit_cast<float>(value)));
case XFMEM_SETPROJECTION + 1:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 1),
fmt::format("Projection[1]: {}", Common::BitCast<float>(value)));
fmt::format("Projection[1]: {}", std::bit_cast<float>(value)));
case XFMEM_SETPROJECTION + 2:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 2),
fmt::format("Projection[2]: {}", Common::BitCast<float>(value)));
fmt::format("Projection[2]: {}", std::bit_cast<float>(value)));
case XFMEM_SETPROJECTION + 3:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 3),
fmt::format("Projection[3]: {}", Common::BitCast<float>(value)));
fmt::format("Projection[3]: {}", std::bit_cast<float>(value)));
case XFMEM_SETPROJECTION + 4:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 4),
fmt::format("Projection[4]: {}", Common::BitCast<float>(value)));
fmt::format("Projection[4]: {}", std::bit_cast<float>(value)));
case XFMEM_SETPROJECTION + 5:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 5),
fmt::format("Projection[5]: {}", Common::BitCast<float>(value)));
fmt::format("Projection[5]: {}", std::bit_cast<float>(value)));
case XFMEM_SETPROJECTION + 6:
return std::make_pair(RegName(XFMEM_SETPROJECTION + 6),
fmt::to_string(static_cast<ProjectionType>(value)));
@ -546,7 +547,7 @@ std::string GetXFMemDescription(u32 address, u32 value)
(address >= XFMEM_POSTMATRICES && address < XFMEM_POSTMATRICES_END))
{
// The matrices all use floats
return fmt::format("{} = {}", GetXFMemName(address), Common::BitCast<float>(value));
return fmt::format("{} = {}", GetXFMemName(address), std::bit_cast<float>(value));
}
else if (address >= XFMEM_LIGHTS && address < XFMEM_LIGHTS_END)
{
@ -560,7 +561,7 @@ std::string GetXFMemDescription(u32 address, u32 value)
else
{
// Everything else is a float
return fmt::format("{} = {}", GetXFMemName(address), Common::BitCast<float>(value));
return fmt::format("{} = {}", GetXFMemName(address), std::bit_cast<float>(value));
}
}
else