From 45e13b03f372230dbf780f3fa87dd88f388af605 Mon Sep 17 00:00:00 2001 From: arades79 Date: Sat, 11 Feb 2023 13:28:03 -0500 Subject: add static lifetime to constexpr values to force compile time evaluation where possible Signed-off-by: arades79 --- src/video_core/engines/fermi_2d.cpp | 2 +- src/video_core/engines/maxwell_3d.cpp | 2 +- src/video_core/engines/sw_blitter/converter.cpp | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/video_core/engines') diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index a126c359c..40176821b 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp @@ -72,7 +72,7 @@ void Fermi2D::Blit() { UNIMPLEMENTED_IF_MSG(regs.clip_enable != 0, "Clipped blit enabled"); const auto& args = regs.pixels_from_memory; - constexpr s64 null_derivate = 1ULL << 32; + constexpr static s64 null_derivate = 1ULL << 32; Surface src = regs.src; const auto bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(src.format)); const bool delegate_to_gpu = src.width > 512 && src.height > 512 && bytes_per_pixel <= 8 && diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index ae9da6290..3c1af92c4 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -258,7 +258,7 @@ u32 Maxwell3D::GetMaxCurrentVertices() { size_t Maxwell3D::EstimateIndexBufferSize() { GPUVAddr start_address = regs.index_buffer.StartAddress(); GPUVAddr end_address = regs.index_buffer.EndAddress(); - constexpr std::array max_sizes = { + constexpr static std::array max_sizes = { std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()}; const size_t byte_size = regs.index_buffer.FormatSizeInBytes(); diff --git a/src/video_core/engines/sw_blitter/converter.cpp b/src/video_core/engines/sw_blitter/converter.cpp index 2419b5632..11674c748 100644 --- a/src/video_core/engines/sw_blitter/converter.cpp +++ b/src/video_core/engines/sw_blitter/converter.cpp @@ -694,16 +694,16 @@ private: }; const auto force_to_fp16 = [](f32 base_value) { u32 tmp = Common::BitCast(base_value); - constexpr size_t fp32_mantissa_bits = 23; - constexpr size_t fp16_mantissa_bits = 10; - constexpr size_t mantissa_mask = + constexpr static size_t fp32_mantissa_bits = 23; + constexpr static size_t fp16_mantissa_bits = 10; + constexpr static size_t mantissa_mask = ~((1ULL << (fp32_mantissa_bits - fp16_mantissa_bits)) - 1ULL); tmp = tmp & static_cast(mantissa_mask); // TODO: force the exponent within the range of half float. Not needed in UNORM / SNORM return Common::BitCast(tmp); }; const auto from_fp_n = [&sign_extend](u32 base_value, size_t bits, size_t mantissa) { - constexpr size_t fp32_mantissa_bits = 23; + constexpr static size_t fp32_mantissa_bits = 23; size_t shift_towards = fp32_mantissa_bits - mantissa; const u32 new_value = static_cast(sign_extend(base_value, bits) << shift_towards) & (~(1U << 31)); @@ -770,7 +770,7 @@ private: component_mask[which_component]; }; const auto to_fp_n = [](f32 base_value, size_t bits, size_t mantissa) { - constexpr size_t fp32_mantissa_bits = 23; + constexpr static size_t fp32_mantissa_bits = 23; u32 tmp_value = Common::BitCast(std::max(base_value, 0.0f)); size_t shift_towards = fp32_mantissa_bits - mantissa; return tmp_value >> shift_towards; -- cgit v1.2.3