summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2017-12-26 00:38:44 +0100
committerLéo Lam <leo@innovatetechnologi.es>2019-05-04 23:12:17 +0200
commitab9ece9bcab8a6d55dbe6f3a904d49231e5f73e1 (patch)
tree3993f73a513f6f80ecddff85882042b73da261da /Source/Core/VideoCommon
parent6f84984b7b0514227327b2e2c5ef10907d150b96 (diff)
Replace MathUtil::Clamp with std::clamp
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/BPFunctions.cpp14
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp5
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp2
-rw-r--r--Source/Core/VideoCommon/TextureDecoder_Common.cpp19
-rw-r--r--Source/Core/VideoCommon/TextureDecoder_x64.cpp1
5 files changed, 21 insertions, 20 deletions
diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp
index 2aa325f8f7..e725927860 100644
--- a/Source/Core/VideoCommon/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/BPFunctions.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include <algorithm>
+
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
@@ -90,8 +92,8 @@ void SetViewport()
{
// There's no way to support oversized depth ranges in this situation. Let's just clamp the
// range to the maximum value supported by the console GPU and hope for the best.
- min_depth = MathUtil::Clamp(min_depth, 0.0f, GX_MAX_DEPTH);
- max_depth = MathUtil::Clamp(max_depth, 0.0f, GX_MAX_DEPTH);
+ min_depth = std::clamp(min_depth, 0.0f, GX_MAX_DEPTH);
+ max_depth = std::clamp(max_depth, 0.0f, GX_MAX_DEPTH);
}
if (g_renderer->UseVertexDepthRange())
@@ -131,10 +133,10 @@ void SetViewport()
{
const float max_width = static_cast<float>(g_renderer->GetCurrentFramebuffer()->GetWidth());
const float max_height = static_cast<float>(g_renderer->GetCurrentFramebuffer()->GetHeight());
- x = MathUtil::Clamp(x, 0.0f, max_width - 1.0f);
- y = MathUtil::Clamp(y, 0.0f, max_height - 1.0f);
- width = MathUtil::Clamp(width, 1.0f, max_width - x);
- height = MathUtil::Clamp(height, 1.0f, max_height - y);
+ x = std::clamp(x, 0.0f, max_width - 1.0f);
+ y = std::clamp(y, 0.0f, max_height - 1.0f);
+ width = std::clamp(width, 1.0f, max_width - x);
+ height = std::clamp(height, 1.0f, max_height - y);
}
// Lower-left flip.
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 523a681884..222b1ba9ab 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -14,6 +14,7 @@
#include "VideoCommon/RenderBase.h"
+#include <algorithm>
#include <cinttypes>
#include <cmath>
#include <memory>
@@ -218,11 +219,11 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
{
// if Z is in 16 bit format you must return a 16 bit integer
- ret = MathUtil::Clamp<u32>(static_cast<u32>(depth * 65536.0f), 0, 0xFFFF);
+ ret = std::clamp<u32>(static_cast<u32>(depth * 65536.0f), 0, 0xFFFF);
}
else
{
- ret = MathUtil::Clamp<u32>(static_cast<u32>(depth * 16777216.0f), 0, 0xFFFFFF);
+ ret = std::clamp<u32>(static_cast<u32>(depth * 16777216.0f), 0, 0xFFFFFF);
}
return ret;
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index d0e12a9171..f6c9fdc407 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -556,7 +556,7 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex,
// distance they kick in at is important to preserve at any resolution.
// Correct this with the upscaling factor of custom textures.
s64 lod_offset = std::log2(g_renderer->GetEFBScale() / custom_tex_scale) * 256.f;
- state.lod_bias = MathUtil::Clamp<s64>(state.lod_bias + lod_offset, -32768, 32767);
+ state.lod_bias = std::clamp<s64>(state.lod_bias + lod_offset, -32768, 32767);
// Anisotropic also pushes mips farther away so it cannot be used either
state.anisotropic_filtering = 0;
diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp
index 5fbe34a098..b80ea9b999 100644
--- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp
+++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp
@@ -7,7 +7,6 @@
#include <cstddef>
#include "Common/CommonTypes.h"
-#include "Common/MathUtil.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
@@ -705,9 +704,9 @@ void TexDecoder_DecodeTexel(u8* dst, const u8* src, int s, int t, int imageWidth
// We do the inverse BT.601 conversion for YCbCr to RGB
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
- u8 R = MathUtil::Clamp(int(1.164f * Y + 1.596f * V), 0, 255);
- u8 G = MathUtil::Clamp(int(1.164f * Y - 0.392f * U - 0.813f * V), 0, 255);
- u8 B = MathUtil::Clamp(int(1.164f * Y + 2.017f * U), 0, 255);
+ u8 R = std::clamp(int(1.164f * Y + 1.596f * V), 0, 255);
+ u8 G = std::clamp(int(1.164f * Y - 0.392f * U - 0.813f * V), 0, 255);
+ u8 B = std::clamp(int(1.164f * Y + 2.017f * U), 0, 255);
dst[t * imageWidth + s] = 0xff000000 | B << 16 | G << 8 | R;
}
break;
@@ -770,13 +769,13 @@ void TexDecoder_DecodeXFB(u8* dst, const u8* src, u32 width, u32 height, u32 str
// We do the inverse BT.601 conversion for YCbCr to RGB
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
- u8 R1 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y1 + 1.596f * V), 0, 255));
- u8 G1 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y1 - 0.392f * U - 0.813f * V), 0, 255));
- u8 B1 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y1 + 2.017f * U), 0, 255));
+ u8 R1 = static_cast<u8>(std::clamp(int(1.164f * Y1 + 1.596f * V), 0, 255));
+ u8 G1 = static_cast<u8>(std::clamp(int(1.164f * Y1 - 0.392f * U - 0.813f * V), 0, 255));
+ u8 B1 = static_cast<u8>(std::clamp(int(1.164f * Y1 + 2.017f * U), 0, 255));
- u8 R2 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y2 + 1.596f * V), 0, 255));
- u8 G2 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y2 - 0.392f * U - 0.813f * V), 0, 255));
- u8 B2 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y2 + 2.017f * U), 0, 255));
+ u8 R2 = static_cast<u8>(std::clamp(int(1.164f * Y2 + 1.596f * V), 0, 255));
+ u8 G2 = static_cast<u8>(std::clamp(int(1.164f * Y2 - 0.392f * U - 0.813f * V), 0, 255));
+ u8 B2 = static_cast<u8>(std::clamp(int(1.164f * Y2 + 2.017f * U), 0, 255));
u32 rgba = 0xff000000 | B1 << 16 | G1 << 8 | R1;
std::memcpy(dst_ptr, &rgba, sizeof(rgba));
diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp
index 7d41dbee53..9d76483656 100644
--- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp
+++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp
@@ -9,7 +9,6 @@
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/Intrinsics.h"
-#include "Common/MathUtil.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"