mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[util] Implement fclamp for fp special cases
This commit is contained in:
parent
ec197b49f9
commit
9280818a57
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
constexpr size_t CACHE_LINE_SIZE = 64;
|
constexpr size_t CACHE_LINE_SIZE = 64;
|
||||||
@ -16,4 +18,12 @@ namespace dxvk {
|
|||||||
return (what + to - 1) & ~(to - 1);
|
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