From b94de1924de55b4a75b0c44f22f0358d8c11848d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 26 Jun 2020 21:40:50 +1000 Subject: [PATCH] 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. --- src/core/gpu_hw_shadergen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index a0702b2e8..2cdb956bc 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -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); }