Fix incorrect clamping in SWRenderer.

A previous PR changed a whole lot of min/maxes to std::min/std::max
but made a mistake here and used a templated min which cast it's
arguments to unsigned instead of casting return value.

This resulted in glitchy artifacts in bright areas (See issue 7439)

I rewrote the code to use a proper clamping function so it's cleaner
to read.
This commit is contained in:
Scott Mansell
2014-07-15 00:42:33 +12:00
parent 3ac4e9f171
commit b8695a57da
3 changed files with 20 additions and 20 deletions

View File

@ -20,6 +20,14 @@ inline void Clamp(T* val, const T& min, const T& max)
*val = max;
}
template<class T>
inline T Clamp(const T val, const T& min, const T& max)
{
T ret = val;
Clamp(&ret, min, max);
return ret;
}
// The most significant bit of the fraction is an is-quiet bit on all architectures we care about.
static const u64 DOUBLE_SIGN = 0x8000000000000000ULL,