GPU/ShaderGen: Round normalized colours before converting to integer

Fixes broken rendering/precision issues on Intel Ivy Bridge GPUs.

Many thanks to linkmauve from Dolphin for the idea - seems Dolphin also
had a similar problem a few years ago.
This commit is contained in:
Connor McLaughlin 2020-06-26 21:40:50 +10:00
parent 16ca214d09
commit b94de1924d

View file

@ -203,9 +203,9 @@ uint fixYCoord(uint y)
uint RGBA8ToRGBA5551(float4 v)
{
uint r = uint(v.r * 255.0) >> 3;
uint g = uint(v.g * 255.0) >> 3;
uint b = uint(v.b * 255.0) >> 3;
uint r = uint(roundEven(v.r * 255.0)) >> 3;
uint g = uint(roundEven(v.g * 255.0)) >> 3;
uint b = uint(roundEven(v.b * 255.0)) >> 3;
uint a = (v.a != 0.0) ? 1u : 0u;
return (r) | (g << 5) | (b << 10) | (a << 15);
}