From 16dd1249b715400c94f5959a9e2f944e16881798 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sun, 15 Sep 2019 02:59:26 +0100 Subject: [PATCH] [util] Add alignDown helper --- src/util/util_math.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/util_math.h b/src/util/util_math.h index 29e052f0b..fdb3762b8 100644 --- a/src/util/util_math.h +++ b/src/util/util_math.h @@ -18,6 +18,11 @@ namespace dxvk { return (what + to - 1) & ~(to - 1); } + template + constexpr T alignDown(T what, U to) { + return (what / to) * to; + } + // Equivalent of std::clamp for use with floating point numbers // Handles (-){INFINITY,NAN} cases. // Will return min in cases of NAN, etc.