mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 20:52:10 +01:00
[util] Implement fclamp for fp special cases
This commit is contained in:
parent
ec197b49f9
commit
9280818a57
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
constexpr size_t CACHE_LINE_SIZE = 64;
|
||||
@ -15,5 +17,13 @@ namespace dxvk {
|
||||
constexpr T align(T what, U to) {
|
||||
return (what + to - 1) & ~(to - 1);
|
||||
}
|
||||
|
||||
// Equivalent of std::clamp for use with floating point numbers
|
||||
// Handles (-){INFINITY,NAN} cases.
|
||||
// Will return min in cases of NAN, etc.
|
||||
inline float fclamp(float value, float min, float max) {
|
||||
return std::fmin(
|
||||
std::fmax(value, min), max);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user