[common] replace Common::BitCast with libc++ provided one (#2774)
Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2774 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
#include "audio_core/adsp/apps/audio_renderer/command_list_processor.h"
|
||||
#include "audio_core/renderer/command/effect/biquad_filter.h"
|
||||
#include "audio_core/renderer/voice/voice_state.h"
|
||||
#include "common/bit_cast.h"
|
||||
#include <numeric>
|
||||
#include <bit>
|
||||
|
||||
namespace AudioCore::Renderer {
|
||||
/**
|
||||
@@ -30,8 +31,8 @@ void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
|
||||
Common::FixedPoint<50, 14>::from_base(b_[2]).to_double()};
|
||||
std::array<f64, 2> a{Common::FixedPoint<50, 14>::from_base(a_[0]).to_double(),
|
||||
Common::FixedPoint<50, 14>::from_base(a_[1]).to_double()};
|
||||
std::array<f64, 4> s{Common::BitCast<f64>(state.s0), Common::BitCast<f64>(state.s1),
|
||||
Common::BitCast<f64>(state.s2), Common::BitCast<f64>(state.s3)};
|
||||
std::array<f64, 4> s{std::bit_cast<f64>(state.s0), std::bit_cast<f64>(state.s1),
|
||||
std::bit_cast<f64>(state.s2), std::bit_cast<f64>(state.s3)};
|
||||
|
||||
for (u32 i = 0; i < sample_count; i++) {
|
||||
f64 in_sample{static_cast<f64>(input[i])};
|
||||
@@ -45,10 +46,10 @@ void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
|
||||
s[2] = sample;
|
||||
}
|
||||
|
||||
state.s0 = Common::BitCast<s64>(s[0]);
|
||||
state.s1 = Common::BitCast<s64>(s[1]);
|
||||
state.s2 = Common::BitCast<s64>(s[2]);
|
||||
state.s3 = Common::BitCast<s64>(s[3]);
|
||||
state.s0 = std::bit_cast<s64>(s[0]);
|
||||
state.s1 = std::bit_cast<s64>(s[1]);
|
||||
state.s2 = std::bit_cast<s64>(s[2]);
|
||||
state.s3 = std::bit_cast<s64>(s[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +64,8 @@ void ApplyBiquadFilterFloat2(std::span<s32> output, std::span<const s32> input,
|
||||
std::array<f64, 3> b_double{static_cast<f64>(b[0]), static_cast<f64>(b[1]),
|
||||
static_cast<f64>(b[2])};
|
||||
std::array<f64, 2> a_double{static_cast<f64>(a[0]), static_cast<f64>(a[1])};
|
||||
std::array<f64, 4> s{Common::BitCast<f64>(state.s0), Common::BitCast<f64>(state.s1),
|
||||
Common::BitCast<f64>(state.s2), Common::BitCast<f64>(state.s3)};
|
||||
std::array<f64, 4> s{std::bit_cast<f64>(state.s0), std::bit_cast<f64>(state.s1),
|
||||
std::bit_cast<f64>(state.s2), std::bit_cast<f64>(state.s3)};
|
||||
|
||||
for (u32 i = 0; i < sample_count; i++) {
|
||||
f64 in_sample{static_cast<f64>(input[i])};
|
||||
@@ -79,10 +80,10 @@ void ApplyBiquadFilterFloat2(std::span<s32> output, std::span<const s32> input,
|
||||
s[2] = sample;
|
||||
}
|
||||
|
||||
state.s0 = Common::BitCast<s64>(s[0]);
|
||||
state.s1 = Common::BitCast<s64>(s[1]);
|
||||
state.s2 = Common::BitCast<s64>(s[2]);
|
||||
state.s3 = Common::BitCast<s64>(s[3]);
|
||||
state.s0 = std::bit_cast<s64>(s[0]);
|
||||
state.s1 = std::bit_cast<s64>(s[1]);
|
||||
state.s2 = std::bit_cast<s64>(s[2]);
|
||||
state.s3 = std::bit_cast<s64>(s[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,6 @@ add_library(
|
||||
assert.h
|
||||
atomic_helpers.h
|
||||
atomic_ops.h
|
||||
bit_cast.h
|
||||
bit_field.h
|
||||
bit_util.h
|
||||
bounded_threadsafe_queue.h
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <version>
|
||||
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
#include <bit>
|
||||
#endif
|
||||
|
||||
namespace Common {
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr inline To BitCast(const From& from) {
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
return std::bit_cast<To>(from);
|
||||
#else
|
||||
return __builtin_bit_cast(To, from);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
#include "bit_cast.h"
|
||||
#include <numeric>
|
||||
#include <bit>
|
||||
|
||||
namespace Common {
|
||||
|
||||
@@ -16,11 +17,9 @@ template <typename T>
|
||||
requires(std::is_integral_v<T> && std::is_signed_v<T>)
|
||||
inline T WrappingAdd(T lhs, T rhs) {
|
||||
using U = std::make_unsigned_t<T>;
|
||||
|
||||
U lhs_u = BitCast<U>(lhs);
|
||||
U rhs_u = BitCast<U>(rhs);
|
||||
|
||||
return BitCast<T>(lhs_u + rhs_u);
|
||||
U lhs_u = std::bit_cast<U>(lhs);
|
||||
U rhs_u = std::bit_cast<U>(rhs);
|
||||
return std::bit_cast<T>(lhs_u + rhs_u);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2023 merryhime <https://mary.rs>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <numeric>
|
||||
#include "core/arm/nce/interpreter_visitor.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <numeric>
|
||||
#include <bit>
|
||||
#include "common/arm64/native_clock.h"
|
||||
#include "common/bit_cast.h"
|
||||
#include "common/literals.h"
|
||||
#include "core/arm/nce/arm_nce.h"
|
||||
#include "core/arm/nce/guest_context.h"
|
||||
@@ -435,7 +436,7 @@ void Patcher::WriteMsrHandler(ModuleDestLabel module_dest, oaknut::XReg src_reg)
|
||||
void Patcher::WriteCntpctHandler(ModuleDestLabel module_dest, oaknut::XReg dest_reg) {
|
||||
static Common::Arm64::NativeClock clock{};
|
||||
const auto factor = clock.GetGuestCNTFRQFactor();
|
||||
const auto raw_factor = Common::BitCast<std::array<u64, 2>>(factor);
|
||||
const auto raw_factor = std::bit_cast<std::array<u64, 2>>(factor);
|
||||
|
||||
const auto use_x2_x3 = dest_reg.index() == 0 || dest_reg.index() == 1;
|
||||
oaknut::XReg scratch0 = use_x2_x3 ? X2 : X0;
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
#include <ranges>
|
||||
#include <bit>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include <ranges>
|
||||
#include "common/settings.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/internal_network/emu_net_state.h"
|
||||
@@ -123,8 +124,8 @@ std::vector<Network::NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||
// Just use 0 as the gateway address
|
||||
result.emplace_back(Network::NetworkInterface{
|
||||
.name{ifa->ifa_name},
|
||||
.ip_address{Common::BitCast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr},
|
||||
.subnet_mask{Common::BitCast<struct sockaddr_in>(*ifa->ifa_netmask).sin_addr},
|
||||
.ip_address{std::bit_cast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr},
|
||||
.subnet_mask{std::bit_cast<struct sockaddr_in>(*ifa->ifa_netmask).sin_addr},
|
||||
.gateway{in_addr{.s_addr = 0}}
|
||||
});
|
||||
#else
|
||||
@@ -139,8 +140,8 @@ std::vector<Network::NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||
gateway_0.s_addr = gateway;
|
||||
result.emplace_back(Network::NetworkInterface{
|
||||
.name = ifa->ifa_name,
|
||||
.ip_address = Common::BitCast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr,
|
||||
.subnet_mask = Common::BitCast<struct sockaddr_in>(*ifa->ifa_netmask).sin_addr,
|
||||
.ip_address = std::bit_cast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr,
|
||||
.subnet_mask = std::bit_cast<struct sockaddr_in>(*ifa->ifa_netmask).sin_addr,
|
||||
.gateway = gateway_0
|
||||
});
|
||||
continue;
|
||||
@@ -191,8 +192,8 @@ std::vector<Network::NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||
gateway_0.s_addr = gateway;
|
||||
result.emplace_back(Network::NetworkInterface{
|
||||
.name = ifa->ifa_name,
|
||||
.ip_address = Common::BitCast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr,
|
||||
.subnet_mask = Common::BitCast<struct sockaddr_in>(*ifa->ifa_netmask).sin_addr,
|
||||
.ip_address = std::bit_cast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr,
|
||||
.subnet_mask = std::bit_cast<struct sockaddr_in>(*ifa->ifa_netmask).sin_addr,
|
||||
.gateway = gateway_0
|
||||
});
|
||||
#endif // ANDROID
|
||||
|
||||
@@ -7,18 +7,8 @@
|
||||
#ifdef __AVX__
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
||||
// NetBSD apparently still needs these... ugh
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
#include <numeric>
|
||||
#include <bit>
|
||||
template <typename To, typename From> constexpr inline To BitCast(const From& from) {
|
||||
return std::bit_cast<To>(from);
|
||||
}
|
||||
#else
|
||||
template <typename To, typename From> constexpr inline To BitCast(const From& from) {
|
||||
return __builtin_bit_cast(To, from);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename F>
|
||||
void CheckedRun(F&& fn) {
|
||||
@@ -48,18 +38,18 @@ void CheckedRun(F&& fn) {
|
||||
, "+x"(xmm8), "+x"(xmm9), "+x"(xmm10), "+x"(xmm11)
|
||||
:
|
||||
);
|
||||
CHECK(BitCast<std::uint64_t>(xmm0[0]) == 0);
|
||||
CHECK(BitCast<std::uint64_t>(xmm1[0]) == 1);
|
||||
CHECK(BitCast<std::uint64_t>(xmm2[0]) == 2);
|
||||
CHECK(BitCast<std::uint64_t>(xmm3[0]) == 3);
|
||||
CHECK(BitCast<std::uint64_t>(xmm4[0]) == 4);
|
||||
CHECK(BitCast<std::uint64_t>(xmm5[0]) == 5);
|
||||
CHECK(BitCast<std::uint64_t>(xmm6[0]) == 6);
|
||||
CHECK(BitCast<std::uint64_t>(xmm7[0]) == 7);
|
||||
CHECK(BitCast<std::uint64_t>(xmm8[0]) == 8);
|
||||
CHECK(BitCast<std::uint64_t>(xmm9[0]) == 9);
|
||||
CHECK(BitCast<std::uint64_t>(xmm10[0]) == 10);
|
||||
CHECK(BitCast<std::uint64_t>(xmm11[0]) == 11);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm0[0]) == 0);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm1[0]) == 1);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm2[0]) == 2);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm3[0]) == 3);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm4[0]) == 4);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm5[0]) == 5);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm6[0]) == 6);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm7[0]) == 7);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm8[0]) == 8);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm9[0]) == 9);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm10[0]) == 10);
|
||||
CHECK(std::bit_cast<std::uint64_t>(xmm11[0]) == 11);
|
||||
#else
|
||||
fn();
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include <bit>
|
||||
#include "shader_recompiler/backend/glasm/reg_alloc.h"
|
||||
#include "shader_recompiler/exception.h"
|
||||
#include "shader_recompiler/frontend/ir/value.h"
|
||||
@@ -78,7 +78,7 @@ Value RegAlloc::MakeImm(const IR::Value& value) {
|
||||
break;
|
||||
case IR::Type::F32:
|
||||
ret.type = Type::U32;
|
||||
ret.imm_u32 = Common::BitCast<u32>(value.F32());
|
||||
ret.imm_u32 = std::bit_cast<u32>(value.F32());
|
||||
break;
|
||||
case IR::Type::U64:
|
||||
ret.type = Type::U64;
|
||||
@@ -86,7 +86,7 @@ Value RegAlloc::MakeImm(const IR::Value& value) {
|
||||
break;
|
||||
case IR::Type::F64:
|
||||
ret.type = Type::U64;
|
||||
ret.imm_u64 = Common::BitCast<u64>(value.F64());
|
||||
ret.imm_u64 = std::bit_cast<u64>(value.F64());
|
||||
break;
|
||||
default:
|
||||
throw NotImplementedException("Immediate type {}", value.Type());
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include <bit>
|
||||
#include <fmt/ranges.h>
|
||||
#include <numeric>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "shader_recompiler/exception.h"
|
||||
@@ -272,7 +275,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF32> {
|
||||
case Shader::Backend::GLASM::Type::Register:
|
||||
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
|
||||
case Shader::Backend::GLASM::Type::U32:
|
||||
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f32>(value.imm_u32));
|
||||
return fmt::format_to(ctx.out(), "{}", std::bit_cast<f32>(value.imm_u32));
|
||||
case Shader::Backend::GLASM::Type::U64:
|
||||
break;
|
||||
}
|
||||
@@ -295,7 +298,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF64> {
|
||||
case Shader::Backend::GLASM::Type::U32:
|
||||
break;
|
||||
case Shader::Backend::GLASM::Type::U64:
|
||||
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f64>(value.imm_u64));
|
||||
return fmt::format_to(ctx.out(), "{}", std::bit_cast<f64>(value.imm_u64));
|
||||
}
|
||||
throw Shader::InvalidArgument("Invalid value type {}", value.type);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -7,10 +10,10 @@
|
||||
#include <map>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include <boost/intrusive/list.hpp>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include "common/common_types.h"
|
||||
#include "shader_recompiler/frontend/ir/condition.h"
|
||||
#include "shader_recompiler/frontend/ir/value.h"
|
||||
@@ -70,13 +73,13 @@ public:
|
||||
/// Intrusively store the host definition of this instruction.
|
||||
template <typename DefinitionType>
|
||||
void SetDefinition(DefinitionType def) {
|
||||
definition = Common::BitCast<u32>(def);
|
||||
definition = std::bit_cast<u32>(def);
|
||||
}
|
||||
|
||||
/// Return the intrusively stored host definition of this instruction.
|
||||
template <typename DefinitionType>
|
||||
[[nodiscard]] DefinitionType Definition() const noexcept {
|
||||
return Common::BitCast<DefinitionType>(definition);
|
||||
return std::bit_cast<DefinitionType>(definition);
|
||||
}
|
||||
|
||||
void SetSsaRegValue(IR::Reg reg, const Value& value) noexcept {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <numeric>
|
||||
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||
#include "shader_recompiler/frontend/ir/value.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -14,7 +17,7 @@
|
||||
#include <boost/intrusive/list.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/bit_cast.h"
|
||||
#include <numeric>
|
||||
#include "common/common_types.h"
|
||||
#include "shader_recompiler/exception.h"
|
||||
#include "shader_recompiler/frontend/ir/attribute.h"
|
||||
@@ -206,13 +209,13 @@ public:
|
||||
/// Intrusively store the host definition of this instruction.
|
||||
template <typename DefinitionType>
|
||||
void SetDefinition(DefinitionType def) {
|
||||
definition = Common::BitCast<u32>(def);
|
||||
definition = std::bit_cast<u32>(def);
|
||||
}
|
||||
|
||||
/// Return the intrusively stored host definition of this instruction.
|
||||
template <typename DefinitionType>
|
||||
[[nodiscard]] DefinitionType Definition() const noexcept {
|
||||
return Common::BitCast<DefinitionType>(definition);
|
||||
return std::bit_cast<DefinitionType>(definition);
|
||||
}
|
||||
|
||||
/// Destructively remove one reference count from the instruction
|
||||
|
||||
@@ -204,7 +204,7 @@ IR::F32 TranslatorVisitor::GetFloatImm20(u64 insn) {
|
||||
} const imm{insn};
|
||||
const u32 sign_bit{static_cast<u32>(imm.is_negative != 0 ? (1ULL << 31) : 0)};
|
||||
const u32 value{static_cast<u32>(imm.value) << 12};
|
||||
return ir.Imm32(Common::BitCast<f32>(value | sign_bit));
|
||||
return ir.Imm32(std::bit_cast<f32>(value | sign_bit));
|
||||
}
|
||||
|
||||
IR::F64 TranslatorVisitor::GetDoubleImm20(u64 insn) {
|
||||
@@ -215,7 +215,7 @@ IR::F64 TranslatorVisitor::GetDoubleImm20(u64 insn) {
|
||||
} const imm{insn};
|
||||
const u64 sign_bit{imm.is_negative != 0 ? (1ULL << 63) : 0};
|
||||
const u64 value{imm.value << 44};
|
||||
return ir.Imm64(Common::BitCast<f64>(value | sign_bit));
|
||||
return ir.Imm64(std::bit_cast<f64>(value | sign_bit));
|
||||
}
|
||||
|
||||
IR::U64 TranslatorVisitor::GetPackedImm20(u64 insn) {
|
||||
@@ -236,7 +236,7 @@ IR::F32 TranslatorVisitor::GetFloatImm32(u64 insn) {
|
||||
u64 raw;
|
||||
BitField<20, 32, u64> value;
|
||||
} const imm{insn};
|
||||
return ir.Imm32(Common::BitCast<f32>(static_cast<u32>(imm.value)));
|
||||
return ir.Imm32(std::bit_cast<f32>(static_cast<u32>(imm.value)));
|
||||
}
|
||||
|
||||
void TranslatorVisitor::SetZFlag(const IR::U1& value) {
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include "shader_recompiler/environment.h"
|
||||
#include "shader_recompiler/exception.h"
|
||||
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||
@@ -536,7 +536,7 @@ template <IR::Opcode op, typename Dest, typename Source>
|
||||
void FoldBitCast(IR::Inst& inst, IR::Opcode reverse) {
|
||||
const IR::Value value{inst.Arg(0)};
|
||||
if (value.IsImmediate()) {
|
||||
inst.ReplaceUsesWith(IR::Value{Common::BitCast<Dest>(Arg<Source>(value))});
|
||||
inst.ReplaceUsesWith(IR::Value{std::bit_cast<Dest>(Arg<Source>(value))});
|
||||
return;
|
||||
}
|
||||
IR::Inst* const arg_inst{value.InstRecursive()};
|
||||
@@ -674,7 +674,7 @@ void FoldFSwizzleAdd(IR::Block& block, IR::Inst& inst) {
|
||||
if (!value_2.IsImmediate() || !value_3.IsImmediate()) {
|
||||
return;
|
||||
}
|
||||
if (Common::BitCast<u32>(value_2.F32()) != value_3.U32()) {
|
||||
if (std::bit_cast<u32>(value_2.F32()) != value_3.U32()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -821,7 +821,7 @@ bool FindGradient3DDerivatives(std::array<IR::Value, 3>& results, IR::Value coor
|
||||
void ConvertDerivatives(std::array<IR::Value, 3>& results, IR::IREmitter& ir) {
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
if (results[i].Type() == IR::Type::U32) {
|
||||
results[i] = results[i].IsImmediate() ? ir.Imm32(Common::BitCast<f32>(results[i].U32()))
|
||||
results[i] = results[i].IsImmediate() ? ir.Imm32(std::bit_cast<f32>(results[i].U32()))
|
||||
: ir.BitCast<IR::F32>(IR::U32(results[i]));
|
||||
}
|
||||
}
|
||||
@@ -927,7 +927,7 @@ void FoldDriverConstBuffer(Environment& env, IR::Block& block, IR::Inst& inst, u
|
||||
inst.ReplaceUsesWith(IR::Value{env.ReadCbufValue(bank_value, offset_value)});
|
||||
} else {
|
||||
inst.ReplaceUsesWith(
|
||||
IR::Value{Common::BitCast<f32>(env.ReadCbufValue(bank_value, offset_value))});
|
||||
IR::Value{std::bit_cast<f32>(env.ReadCbufValue(bank_value, offset_value))});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <cmath>
|
||||
#include <span>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include "common/assert.h"
|
||||
#include "common/bit_cast.h"
|
||||
#include "video_core/engines/sw_blitter/converter.h"
|
||||
#include "video_core/surface.h"
|
||||
#include "video_core/textures/decoders.h"
|
||||
@@ -696,21 +696,21 @@ private:
|
||||
return shifted_value >> shift_amount;
|
||||
};
|
||||
const auto force_to_fp16 = [](f32 base_value) {
|
||||
u32 tmp = Common::BitCast<u32>(base_value);
|
||||
u32 tmp = std::bit_cast<u32>(base_value);
|
||||
constexpr size_t fp32_mantissa_bits = 23;
|
||||
constexpr size_t fp16_mantissa_bits = 10;
|
||||
constexpr size_t mantissa_mask =
|
||||
~((1ULL << (fp32_mantissa_bits - fp16_mantissa_bits)) - 1ULL);
|
||||
tmp = tmp & static_cast<u32>(mantissa_mask);
|
||||
// TODO: force the exponent within the range of half float. Not needed in UNORM / SNORM
|
||||
return Common::BitCast<f32>(tmp);
|
||||
return std::bit_cast<f32>(tmp);
|
||||
};
|
||||
const auto from_fp_n = [&sign_extend](u32 base_value, size_t bits, size_t mantissa) {
|
||||
constexpr size_t fp32_mantissa_bits = 23;
|
||||
size_t shift_towards = fp32_mantissa_bits - mantissa;
|
||||
const u32 new_value =
|
||||
static_cast<u32>(sign_extend(base_value, bits) << shift_towards) & (~(1U << 31));
|
||||
return Common::BitCast<f32>(new_value);
|
||||
return std::bit_cast<f32>(new_value);
|
||||
};
|
||||
const auto calculate_snorm = [&]() {
|
||||
return static_cast<f32>(
|
||||
@@ -740,11 +740,11 @@ private:
|
||||
out_component = force_to_fp16(out_component);
|
||||
} else if constexpr (component_types[which_component] == ComponentType::FLOAT) {
|
||||
if constexpr (component_sizes[which_component] == 32) {
|
||||
out_component = Common::BitCast<f32>(value);
|
||||
out_component = std::bit_cast<f32>(value);
|
||||
} else if constexpr (component_sizes[which_component] == 16) {
|
||||
static constexpr u32 sign_mask = 0x8000;
|
||||
static constexpr u32 mantissa_mask = 0x8000;
|
||||
out_component = Common::BitCast<f32>(((value & sign_mask) << 16) |
|
||||
out_component = std::bit_cast<f32>(((value & sign_mask) << 16) |
|
||||
(((value & 0x7c00) + 0x1C000) << 13) |
|
||||
((value & mantissa_mask) << 13));
|
||||
} else {
|
||||
@@ -774,7 +774,7 @@ private:
|
||||
};
|
||||
const auto to_fp_n = [](f32 base_value, size_t bits, size_t mantissa) {
|
||||
constexpr size_t fp32_mantissa_bits = 23;
|
||||
u32 tmp_value = Common::BitCast<u32>((std::max)(base_value, 0.0f));
|
||||
u32 tmp_value = std::bit_cast<u32>((std::max)(base_value, 0.0f));
|
||||
size_t shift_towards = fp32_mantissa_bits - mantissa;
|
||||
return tmp_value >> shift_towards;
|
||||
};
|
||||
@@ -802,13 +802,13 @@ private:
|
||||
insert_to_word(tmp_word);
|
||||
} else if constexpr (component_types[which_component] == ComponentType::FLOAT) {
|
||||
if constexpr (component_sizes[which_component] == 32) {
|
||||
u32 tmp_word = Common::BitCast<u32>(in_component);
|
||||
u32 tmp_word = std::bit_cast<u32>(in_component);
|
||||
insert_to_word(tmp_word);
|
||||
} else if constexpr (component_sizes[which_component] == 16) {
|
||||
static constexpr u32 sign_mask = 0x8000;
|
||||
static constexpr u32 mantissa_mask = 0x03ff;
|
||||
static constexpr u32 exponent_mask = 0x7c00;
|
||||
const u32 tmp_word = Common::BitCast<u32>(in_component);
|
||||
const u32 tmp_word = std::bit_cast<u32>(in_component);
|
||||
const u32 half = ((tmp_word >> 16) & sign_mask) |
|
||||
((((tmp_word & 0x7f800000) - 0x38000000) >> 13) & exponent_mask) |
|
||||
((tmp_word >> 13) & mantissa_mask);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cmath>
|
||||
#include <bit>
|
||||
#include "video_core/fsr.h"
|
||||
|
||||
namespace FSR {
|
||||
@@ -95,7 +99,7 @@ u32 AU1_AH1_AF1(f32 f) {
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18,
|
||||
};
|
||||
const u32 u = Common::BitCast<u32>(f);
|
||||
const u32 u = std::bit_cast<u32>(f);
|
||||
const u32 i = u >> 23;
|
||||
return base[i] + ((u & 0x7fffff) >> shift[i]);
|
||||
}
|
||||
@@ -107,20 +111,20 @@ u32 AU1_AH2_AF2(f32 a[2]) {
|
||||
void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], f32 inputViewportInPixelsX,
|
||||
f32 inputViewportInPixelsY, f32 inputSizeInPixelsX, f32 inputSizeInPixelsY,
|
||||
f32 outputSizeInPixelsX, f32 outputSizeInPixelsY) {
|
||||
con0[0] = Common::BitCast<u32>(inputViewportInPixelsX / outputSizeInPixelsX);
|
||||
con0[1] = Common::BitCast<u32>(inputViewportInPixelsY / outputSizeInPixelsY);
|
||||
con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f);
|
||||
con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f);
|
||||
con1[0] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX);
|
||||
con1[1] = Common::BitCast<u32>(1.0f / inputSizeInPixelsY);
|
||||
con1[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX);
|
||||
con1[3] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsY);
|
||||
con2[0] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsX);
|
||||
con2[1] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY);
|
||||
con2[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX);
|
||||
con2[3] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY);
|
||||
con3[0] = Common::BitCast<u32>(0.0f / inputSizeInPixelsX);
|
||||
con3[1] = Common::BitCast<u32>(4.0f / inputSizeInPixelsY);
|
||||
con0[0] = std::bit_cast<u32>(inputViewportInPixelsX / outputSizeInPixelsX);
|
||||
con0[1] = std::bit_cast<u32>(inputViewportInPixelsY / outputSizeInPixelsY);
|
||||
con0[2] = std::bit_cast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f);
|
||||
con0[3] = std::bit_cast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f);
|
||||
con1[0] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX);
|
||||
con1[1] = std::bit_cast<u32>(1.0f / inputSizeInPixelsY);
|
||||
con1[2] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX);
|
||||
con1[3] = std::bit_cast<u32>(-1.0f / inputSizeInPixelsY);
|
||||
con2[0] = std::bit_cast<u32>(-1.0f / inputSizeInPixelsX);
|
||||
con2[1] = std::bit_cast<u32>(2.0f / inputSizeInPixelsY);
|
||||
con2[2] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX);
|
||||
con2[3] = std::bit_cast<u32>(2.0f / inputSizeInPixelsY);
|
||||
con3[0] = std::bit_cast<u32>(0.0f / inputSizeInPixelsX);
|
||||
con3[1] = std::bit_cast<u32>(4.0f / inputSizeInPixelsY);
|
||||
con3[2] = con3[3] = 0;
|
||||
}
|
||||
} // Anonymous namespace
|
||||
@@ -131,16 +135,16 @@ void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4],
|
||||
f32 outputSizeInPixelsY, f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) {
|
||||
FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY,
|
||||
inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY);
|
||||
con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f +
|
||||
con0[2] = std::bit_cast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f +
|
||||
inputOffsetInPixelsX);
|
||||
con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f +
|
||||
con0[3] = std::bit_cast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f +
|
||||
inputOffsetInPixelsY);
|
||||
}
|
||||
|
||||
void FsrRcasCon(u32* con, f32 sharpness) {
|
||||
sharpness = std::exp2f(-sharpness);
|
||||
f32 hSharp[2]{sharpness, sharpness};
|
||||
con[0] = Common::BitCast<u32>(sharpness);
|
||||
con[0] = std::bit_cast<u32>(sharpness);
|
||||
con[1] = AU1_AH2_AF2(hSharp);
|
||||
con[2] = 0;
|
||||
con[3] = 0;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <numeric>
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace FSR {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include "common/cityhash.h"
|
||||
#include "common/settings.h" // for enum class Settings::ShaderBackend
|
||||
#include "video_core/renderer_opengl/gl_compute_pipeline.h"
|
||||
@@ -229,8 +233,8 @@ void ComputePipeline::Configure() {
|
||||
}
|
||||
}
|
||||
if (info.uses_rescaling_uniform) {
|
||||
const f32 float_texture_scaling_mask{Common::BitCast<f32>(texture_scaling_mask)};
|
||||
const f32 float_image_scaling_mask{Common::BitCast<f32>(image_scaling_mask)};
|
||||
const f32 float_texture_scaling_mask{std::bit_cast<f32>(texture_scaling_mask)};
|
||||
const f32 float_image_scaling_mask{std::bit_cast<f32>(image_scaling_mask)};
|
||||
if (assembly_program.handle != 0) {
|
||||
glProgramLocalParameter4fARB(GL_COMPUTE_PROGRAM_NV, 0, float_texture_scaling_mask,
|
||||
float_image_scaling_mask, 0.0f, 0.0f);
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include "common/settings.h" // for enum class Settings::ShaderBackend
|
||||
#include "common/thread_worker.h"
|
||||
#include "shader_recompiler/shader_info.h"
|
||||
@@ -511,8 +512,8 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
}
|
||||
}
|
||||
if (info.uses_rescaling_uniform) {
|
||||
const f32 float_texture_scaling_mask{Common::BitCast<f32>(texture_scaling_mask)};
|
||||
const f32 float_image_scaling_mask{Common::BitCast<f32>(image_scaling_mask)};
|
||||
const f32 float_texture_scaling_mask{std::bit_cast<f32>(texture_scaling_mask)};
|
||||
const f32 float_image_scaling_mask{std::bit_cast<f32>(image_scaling_mask)};
|
||||
const bool is_rescaling{texture_cache.IsRescaling()};
|
||||
const f32 config_down_factor{Settings::values.resolution_info.down_factor};
|
||||
const f32 down_factor{is_rescaling ? config_down_factor : 1.0f};
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include <ranges>
|
||||
#include "common/cityhash.h"
|
||||
#include "common/common_types.h"
|
||||
#include <ranges>
|
||||
#include "video_core/engines/draw_manager.h"
|
||||
#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
|
||||
#include "video_core/renderer_vulkan/vk_state_tracker.h"
|
||||
@@ -98,8 +98,8 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
|
||||
for (size_t i = 0; i < regs.rt.size(); ++i) {
|
||||
color_formats[i] = static_cast<u8>(regs.rt[i].format);
|
||||
}
|
||||
alpha_test_ref = Common::BitCast<u32>(regs.alpha_test_ref);
|
||||
point_size = Common::BitCast<u32>(regs.point_size);
|
||||
alpha_test_ref = std::bit_cast<u32>(regs.alpha_test_ref);
|
||||
point_size = std::bit_cast<u32>(regs.point_size);
|
||||
|
||||
if (maxwell3d.dirty.flags[Dirty::VertexInput]) {
|
||||
if (features.has_dynamic_vertex_input) {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include "common/cityhash.h"
|
||||
#include "common/fs/fs.h"
|
||||
#include "common/fs/path_util.h"
|
||||
@@ -160,7 +160,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program
|
||||
const Shader::Stage stage{program.stage};
|
||||
const bool has_geometry{key.unique_hashes[4] != 0 && !programs[4].is_geometry_passthrough};
|
||||
const bool gl_ndc{key.state.ndc_minus_one_to_one != 0};
|
||||
const float point_size{Common::BitCast<float>(key.state.point_size)};
|
||||
const float point_size{std::bit_cast<float>(key.state.point_size)};
|
||||
switch (stage) {
|
||||
case Shader::Stage::VertexB:
|
||||
if (!has_geometry) {
|
||||
@@ -228,7 +228,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program
|
||||
case Shader::Stage::Fragment:
|
||||
info.alpha_test_func = MaxwellToCompareFunction(
|
||||
key.state.UnpackComparisonOp(key.state.alpha_test_func.Value()));
|
||||
info.alpha_test_reference = Common::BitCast<float>(key.state.alpha_test_ref);
|
||||
info.alpha_test_reference = std::bit_cast<float>(key.state.alpha_test_ref);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <bit>
|
||||
#include <numeric>
|
||||
#include "common/bit_util.h"
|
||||
#include "common/settings.h"
|
||||
|
||||
@@ -2216,7 +2216,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT,
|
||||
.pNext = nullptr,
|
||||
// TODO: Make use of std::bit_cast once libc++ supports it.
|
||||
.customBorderColor = Common::BitCast<VkClearColorValue>(color),
|
||||
.customBorderColor = std::bit_cast<VkClearColorValue>(color),
|
||||
.format = VK_FORMAT_UNDEFINED,
|
||||
};
|
||||
const void* pnext = nullptr;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -6,7 +9,7 @@
|
||||
#include <algorithm>
|
||||
#include <span>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include <numeric>
|
||||
#include "video_core/texture_cache/types.h"
|
||||
|
||||
namespace VideoCommon {
|
||||
@@ -41,8 +44,8 @@ struct hash<VideoCommon::RenderTargets> {
|
||||
for (const ImageViewId color_buffer_id : rt.color_buffer_ids) {
|
||||
value ^= std::hash<ImageViewId>{}(color_buffer_id);
|
||||
}
|
||||
value ^= Common::BitCast<u64>(rt.draw_buffers);
|
||||
value ^= Common::BitCast<u64>(rt.size);
|
||||
value ^= std::bit_cast<u64>(rt.draw_buffers);
|
||||
value ^= std::bit_cast<u64>(rt.size);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user