From be6b000bec8f37fd4440dfcfdeb7630ccd7bfec8 Mon Sep 17 00:00:00 2001 From: Techjar Date: Sat, 22 May 2021 01:13:55 -0400 Subject: [PATCH] VideoCommon: Account for pixel quads in bounding box calculation The GC/Wii GPU rasterizes in 2x2 pixel groups, so bounding box values will be rounded to the extents of these groups, rather than the exact pixel. To account for this, we'll round the top/left down to even and the bottom/right up to odd. I have verified that the values resulting from this change exactly match a real Wii. --- Source/Core/VideoCommon/RenderBase.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index f93d498fc6..0ff5b52902 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -187,7 +187,18 @@ void Renderer::ReinterpretPixelData(EFBReinterpretType convtype) u16 Renderer::BBoxRead(int index) { - return BBoxReadImpl(index); + u16 value = BBoxReadImpl(index); + + // The GC/Wii GPU rasterizes in 2x2 pixel groups, so bounding box values will be rounded to the + // extents of these groups, rather than the exact pixel. + // This would have been handled in the pixel shader, but all attempts to do so did not work on + // OpenGL/NVIDIA, due to presumably mystical driver behavior with atomics. + if (index == 0 || index == 2) + value &= ~1; + else + value |= 1; + + return value; } void Renderer::BBoxWrite(int index, u16 value)