mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-03 06:39:33 +00:00
use constexpr for some compile-time expressions
This commit is contained in:
parent
79f5ea0474
commit
938fd4e438
3 changed files with 5 additions and 5 deletions
|
@ -208,7 +208,7 @@ static void CopyDescriptorToBuffer(std::vector<u8>* buffer, T descriptor)
|
||||||
descriptor.Swap();
|
descriptor.Swap();
|
||||||
buffer->insert(buffer->end(), reinterpret_cast<const u8*>(&descriptor),
|
buffer->insert(buffer->end(), reinterpret_cast<const u8*>(&descriptor),
|
||||||
reinterpret_cast<const u8*>(&descriptor) + size);
|
reinterpret_cast<const u8*>(&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);
|
buffer->insert(buffer->end(), number_of_padding_bytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ template <typename SType>
|
||||||
SType ScaleAndClamp(double ps, u32 stScale)
|
SType ScaleAndClamp(double ps, u32 stScale)
|
||||||
{
|
{
|
||||||
float convPS = (float)ps * m_quantizeTable[stScale];
|
float convPS = (float)ps * m_quantizeTable[stScale];
|
||||||
float min = (float)std::numeric_limits<SType>::min();
|
constexpr float min = (float)std::numeric_limits<SType>::min();
|
||||||
float max = (float)std::numeric_limits<SType>::max();
|
constexpr float max = (float)std::numeric_limits<SType>::max();
|
||||||
|
|
||||||
return (SType)std::clamp(convPS, min, max);
|
return (SType)std::clamp(convPS, min, max);
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,10 +195,10 @@ void VertexManager::UploadAllConstants()
|
||||||
{
|
{
|
||||||
// We are free to re-use parts of the buffer now since we're uploading all constants.
|
// 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 pixel_constants_offset = 0;
|
||||||
const u32 vertex_constants_offset =
|
constexpr u32 vertex_constants_offset =
|
||||||
Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants),
|
Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants),
|
||||||
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
|
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
|
||||||
const u32 geometry_constants_offset =
|
constexpr u32 geometry_constants_offset =
|
||||||
Common::AlignUp(vertex_constants_offset + sizeof(VertexShaderConstants),
|
Common::AlignUp(vertex_constants_offset + sizeof(VertexShaderConstants),
|
||||||
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
|
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
|
||||||
const u32 allocation_size = geometry_constants_offset + sizeof(GeometryShaderConstants);
|
const u32 allocation_size = geometry_constants_offset + sizeof(GeometryShaderConstants);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue