mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Replace MathUtil::Clamp with std::clamp
This commit is contained in:
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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"
|
||||
|
||||
|
Reference in New Issue
Block a user