Replace MathUtil::Clamp with std::clamp

This commit is contained in:
Léo Lam
2017-12-26 00:38:44 +01:00
parent 6f84984b7b
commit ab9ece9bca
31 changed files with 101 additions and 109 deletions

View File

@ -4,6 +4,7 @@
#include "VideoBackends/D3D/Render.h"
#include <algorithm>
#include <array>
#include <cinttypes>
#include <cmath>

View File

@ -514,7 +514,7 @@ static u32 GammaCorrection(u32 color, const float gamma_rcp)
for (int i = BLU_C; i <= RED_C; i++)
{
out_color[i] = static_cast<u8>(
MathUtil::Clamp(std::pow(in_colors[i] / 255.0f, gamma_rcp) * 255.0f, 0.0f, 255.0f));
std::clamp(std::pow(in_colors[i] / 255.0f, gamma_rcp) * 255.0f, 0.0f, 255.0f));
}
u32 out_color32;

View File

@ -77,7 +77,7 @@ static void Draw(s32 x, s32 y, s32 xi, s32 yi)
float dx = vertexOffsetX + (float)(x - vertex0X);
float dy = vertexOffsetY + (float)(y - vertex0Y);
s32 z = (s32)MathUtil::Clamp<float>(ZSlope.GetValue(dx, dy), 0.0f, 16777215.0f);
s32 z = (s32)std::clamp<float>(ZSlope.GetValue(dx, dy), 0.0f, 16777215.0f);
if (bpmem.UseEarlyDepthTest() && g_ActiveConfig.bZComploc)
{

View File

@ -2,11 +2,11 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include <cmath>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
#include "VideoBackends/Software/DebugUtil.h"
#include "VideoBackends/Software/EfbInterface.h"
#include "VideoBackends/Software/Tev.h"
@ -777,7 +777,7 @@ void Tev::Draw()
// Based on that, choose the index such that points which are far away from the z-axis use the
// 10th "k" value and such that central points use the first value.
float floatindex = 9.f - std::abs(offset) * 9.f;
floatindex = MathUtil::Clamp(floatindex, 0.f, 9.f); // TODO: This shouldn't be necessary!
floatindex = std::clamp(floatindex, 0.f, 9.f); // TODO: This shouldn't be necessary!
// Get the two closest integer indices, look up the corresponding samples
const int indexlower = (int)floatindex;
@ -798,7 +798,7 @@ void Tev::Draw()
ze -= bpmem.fog.GetC();
// clamp 0 to 1
float fog = MathUtil::Clamp(ze, 0.f, 1.f);
float fog = std::clamp(ze, 0.f, 1.f);
switch (bpmem.fog.c_proj_fsel.fsel)
{

View File

@ -12,7 +12,6 @@
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
@ -192,8 +191,8 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo
// Makes differences in Rogue Squadron 3 (Hoth sky) and The Last Story (shadow culling)
if (dst->z == 0.0f)
{
dst->x = MathUtil::Clamp(dst->x / 2.0f, -1.0f, 1.0f);
dst->y = MathUtil::Clamp(dst->y / 2.0f, -1.0f, 1.0f);
dst->x = std::clamp(dst->x / 2.0f, -1.0f, 1.0f);
dst->y = std::clamp(dst->y / 2.0f, -1.0f, 1.0f);
}
}
@ -359,9 +358,9 @@ void TransformColor(const InputVertexData* src, OutputVertexData* dst)
LightColor(dst->mvPosition, dst->normal[0], i, colorchan, lightCol);
}
int light_x = MathUtil::Clamp(static_cast<int>(lightCol.x), 0, 255);
int light_y = MathUtil::Clamp(static_cast<int>(lightCol.y), 0, 255);
int light_z = MathUtil::Clamp(static_cast<int>(lightCol.z), 0, 255);
int light_x = std::clamp(static_cast<int>(lightCol.x), 0, 255);
int light_y = std::clamp(static_cast<int>(lightCol.y), 0, 255);
int light_z = std::clamp(static_cast<int>(lightCol.z), 0, 255);
chancolor[1] = (matcolor[1] * (light_x + (light_x >> 7))) >> 8;
chancolor[2] = (matcolor[2] * (light_y + (light_y >> 7))) >> 8;
chancolor[3] = (matcolor[3] * (light_z + (light_z >> 7))) >> 8;
@ -393,7 +392,7 @@ void TransformColor(const InputVertexData* src, OutputVertexData* dst)
LightAlpha(dst->mvPosition, dst->normal[0], i, alphachan, lightCol);
}
int light_a = MathUtil::Clamp(static_cast<int>(lightCol), 0, 255);
int light_a = std::clamp(static_cast<int>(lightCol), 0, 255);
chancolor[0] = (matcolor[0] * (light_a + (light_a >> 7))) >> 8;
}
else

View File

@ -267,10 +267,10 @@ bool SwapChain::CreateSwapChain()
size.width = std::max(g_renderer->GetBackbufferWidth(), 1);
size.height = std::max(g_renderer->GetBackbufferHeight(), 1);
}
size.width = MathUtil::Clamp(size.width, surface_capabilities.minImageExtent.width,
surface_capabilities.maxImageExtent.width);
size.height = MathUtil::Clamp(size.height, surface_capabilities.minImageExtent.height,
surface_capabilities.maxImageExtent.height);
size.width = std::clamp(size.width, surface_capabilities.minImageExtent.width,
surface_capabilities.maxImageExtent.width);
size.height = std::clamp(size.height, surface_capabilities.minImageExtent.height,
surface_capabilities.maxImageExtent.height);
// Prefer identity transform if possible
VkSurfaceTransformFlagBitsKHR transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;