From 938fd4e43871d281f5efa185a5b62b8b74fa13f3 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Mon, 17 Aug 2020 17:30:49 -0700 Subject: [PATCH] use constexpr for some compile-time expressions --- Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp | 2 +- .../Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp | 4 ++-- Source/Core/VideoBackends/D3D12/VertexManager.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp index b8513df344..661398b351 100644 --- a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp +++ b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp @@ -208,7 +208,7 @@ static void CopyDescriptorToBuffer(std::vector* buffer, T descriptor) descriptor.Swap(); buffer->insert(buffer->end(), reinterpret_cast(&descriptor), reinterpret_cast(&descriptor) + size); - const size_t number_of_padding_bytes = Common::AlignUp(size, 4) - size; + constexpr size_t number_of_padding_bytes = Common::AlignUp(size, 4) - size; buffer->insert(buffer->end(), number_of_padding_bytes, 0); } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp index a81fae3dc1..5d1a6ed21d 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp @@ -61,8 +61,8 @@ template SType ScaleAndClamp(double ps, u32 stScale) { float convPS = (float)ps * m_quantizeTable[stScale]; - float min = (float)std::numeric_limits::min(); - float max = (float)std::numeric_limits::max(); + constexpr float min = (float)std::numeric_limits::min(); + constexpr float max = (float)std::numeric_limits::max(); return (SType)std::clamp(convPS, min, max); } diff --git a/Source/Core/VideoBackends/D3D12/VertexManager.cpp b/Source/Core/VideoBackends/D3D12/VertexManager.cpp index bdf5fbe8e8..ecaec7c9c1 100644 --- a/Source/Core/VideoBackends/D3D12/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D12/VertexManager.cpp @@ -195,10 +195,10 @@ void VertexManager::UploadAllConstants() { // We are free to re-use parts of the buffer now since we're uploading all constants. const u32 pixel_constants_offset = 0; - const u32 vertex_constants_offset = + constexpr u32 vertex_constants_offset = Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants), D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); - const u32 geometry_constants_offset = + constexpr u32 geometry_constants_offset = Common::AlignUp(vertex_constants_offset + sizeof(VertexShaderConstants), D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); const u32 allocation_size = geometry_constants_offset + sizeof(GeometryShaderConstants);