diff options
| -rw-r--r-- | src/common/math_util.h | 5 | ||||
| -rw-r--r-- | src/core/perf_stats.cpp | 3 | ||||
| -rw-r--r-- | src/input_common/motion_emu.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 25 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 8 |
5 files changed, 22 insertions, 24 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h index 45a1ed367..c6a83c953 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h | |||
| @@ -17,11 +17,6 @@ inline bool IntervalsIntersect(unsigned start0, unsigned length0, unsigned start | |||
| 17 | return (std::max(start0, start1) < std::min(start0 + length0, start1 + length1)); | 17 | return (std::max(start0, start1) < std::min(start0 + length0, start1 + length1)); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | template <typename T> | ||
| 21 | inline T Clamp(const T val, const T& min, const T& max) { | ||
| 22 | return std::max(min, std::min(max, val)); | ||
| 23 | } | ||
| 24 | |||
| 25 | template <class T> | 20 | template <class T> |
| 26 | struct Rectangle { | 21 | struct Rectangle { |
| 27 | T left; | 22 | T left; |
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index ad3b56fcc..5f53b16d3 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <chrono> | 6 | #include <chrono> |
| 6 | #include <mutex> | 7 | #include <mutex> |
| 7 | #include <thread> | 8 | #include <thread> |
| @@ -87,7 +88,7 @@ void FrameLimiter::DoFrameLimiting(u64 current_system_time_us) { | |||
| 87 | frame_limiting_delta_err += microseconds(current_system_time_us - previous_system_time_us); | 88 | frame_limiting_delta_err += microseconds(current_system_time_us - previous_system_time_us); |
| 88 | frame_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime); | 89 | frame_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime); |
| 89 | frame_limiting_delta_err = | 90 | frame_limiting_delta_err = |
| 90 | MathUtil::Clamp(frame_limiting_delta_err, -MAX_LAG_TIME_US, MAX_LAG_TIME_US); | 91 | std::clamp(frame_limiting_delta_err, -MAX_LAG_TIME_US, MAX_LAG_TIME_US); |
| 91 | 92 | ||
| 92 | if (frame_limiting_delta_err > microseconds::zero()) { | 93 | if (frame_limiting_delta_err > microseconds::zero()) { |
| 93 | std::this_thread::sleep_for(frame_limiting_delta_err); | 94 | std::this_thread::sleep_for(frame_limiting_delta_err); |
diff --git a/src/input_common/motion_emu.cpp b/src/input_common/motion_emu.cpp index 59a035e70..caffe48cb 100644 --- a/src/input_common/motion_emu.cpp +++ b/src/input_common/motion_emu.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <chrono> | 6 | #include <chrono> |
| 6 | #include <mutex> | 7 | #include <mutex> |
| 7 | #include <thread> | 8 | #include <thread> |
| @@ -43,8 +44,8 @@ public: | |||
| 43 | tilt_angle = 0; | 44 | tilt_angle = 0; |
| 44 | } else { | 45 | } else { |
| 45 | tilt_direction = mouse_move.Cast<float>(); | 46 | tilt_direction = mouse_move.Cast<float>(); |
| 46 | tilt_angle = MathUtil::Clamp(tilt_direction.Normalize() * sensitivity, 0.0f, | 47 | tilt_angle = |
| 47 | MathUtil::PI * 0.5f); | 48 | std::clamp(tilt_direction.Normalize() * sensitivity, 0.0f, MathUtil::PI * 0.5f); |
| 48 | } | 49 | } |
| 49 | } | 50 | } |
| 50 | } | 51 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 13e2a77ce..170548528 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <memory> | 6 | #include <memory> |
| 6 | #include <string> | 7 | #include <string> |
| 7 | #include <tuple> | 8 | #include <tuple> |
| @@ -290,18 +291,18 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 290 | : (depth_surface == nullptr ? 1u : depth_surface->res_scale); | 291 | : (depth_surface == nullptr ? 1u : depth_surface->res_scale); |
| 291 | 292 | ||
| 292 | MathUtil::Rectangle<u32> draw_rect{ | 293 | MathUtil::Rectangle<u32> draw_rect{ |
| 293 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) + | 294 | static_cast<u32>( |
| 294 | viewport_rect.left * res_scale, | 295 | std::clamp<s32>(static_cast<s32>(surfaces_rect.left) + viewport_rect.left * res_scale, |
| 295 | surfaces_rect.left, surfaces_rect.right)), // Left | 296 | surfaces_rect.left, surfaces_rect.right)), // Left |
| 296 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + | 297 | static_cast<u32>( |
| 297 | viewport_rect.top * res_scale, | 298 | std::clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + viewport_rect.top * res_scale, |
| 298 | surfaces_rect.bottom, surfaces_rect.top)), // Top | 299 | surfaces_rect.bottom, surfaces_rect.top)), // Top |
| 299 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) + | 300 | static_cast<u32>( |
| 300 | viewport_rect.right * res_scale, | 301 | std::clamp<s32>(static_cast<s32>(surfaces_rect.left) + viewport_rect.right * res_scale, |
| 301 | surfaces_rect.left, surfaces_rect.right)), // Right | 302 | surfaces_rect.left, surfaces_rect.right)), // Right |
| 302 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + | 303 | static_cast<u32>(std::clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + |
| 303 | viewport_rect.bottom * res_scale, | 304 | viewport_rect.bottom * res_scale, |
| 304 | surfaces_rect.bottom, surfaces_rect.top))}; // Bottom | 305 | surfaces_rect.bottom, surfaces_rect.top))}; // Bottom |
| 305 | 306 | ||
| 306 | // Bind the framebuffer surfaces | 307 | // Bind the framebuffer surfaces |
| 307 | BindFramebufferSurfaces(color_surface, depth_surface, has_stencil); | 308 | BindFramebufferSurfaces(color_surface, depth_surface, has_stencil); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 561c6913d..6c1c6775a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -1086,10 +1086,10 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( | |||
| 1086 | } | 1086 | } |
| 1087 | 1087 | ||
| 1088 | MathUtil::Rectangle<u32> viewport_clamped{ | 1088 | MathUtil::Rectangle<u32> viewport_clamped{ |
| 1089 | static_cast<u32>(MathUtil::Clamp(viewport.left, 0, static_cast<s32>(config.width))), | 1089 | static_cast<u32>(std::clamp(viewport.left, 0, static_cast<s32>(config.width))), |
| 1090 | static_cast<u32>(MathUtil::Clamp(viewport.top, 0, static_cast<s32>(config.height))), | 1090 | static_cast<u32>(std::clamp(viewport.top, 0, static_cast<s32>(config.height))), |
| 1091 | static_cast<u32>(MathUtil::Clamp(viewport.right, 0, static_cast<s32>(config.width))), | 1091 | static_cast<u32>(std::clamp(viewport.right, 0, static_cast<s32>(config.width))), |
| 1092 | static_cast<u32>(MathUtil::Clamp(viewport.bottom, 0, static_cast<s32>(config.height)))}; | 1092 | static_cast<u32>(std::clamp(viewport.bottom, 0, static_cast<s32>(config.height)))}; |
| 1093 | 1093 | ||
| 1094 | // get color and depth surfaces | 1094 | // get color and depth surfaces |
| 1095 | SurfaceParams color_params; | 1095 | SurfaceParams color_params; |