summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2021-05-29 17:00:14 +1000
committerGitHub <noreply@github.com>2021-05-29 17:00:14 +1000
commitb31d4400e31503861cce0bb0ccff6da71bddf277 (patch)
tree492f8395eecd2bc65566033783a32f9456affefb /Source/Core/VideoCommon/PixelShaderGen.cpp
parent7b2b05cc219c1591ab328fefabd9435aff748c08 (diff)
parenta24e78b3cf07e8d169d97a2e4c3635b9efbdba35 (diff)
Merge pull request #9765 from Techjar/bbox-pixel-quads-2-electric-boogaloo
VideoCommon: Move bounding box pixel quads rounding to shader
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index a2bc73257e..16fb7766e9 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -492,19 +492,30 @@ void UpdateBoundingBox(float2 rawpos) {{
// such that width = right - left + 1. This has been verified on hardware.
int2 pos = iround(rawpos * cefbscale + offset);
+ // 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.
+#ifdef API_OPENGL
+ // Need to flip the operands for Y on OpenGL because of lower-left origin.
+ int2 pos_tl = int2(pos.x & ~1, pos.y | 1);
+ int2 pos_br = int2(pos.x | 1, pos.y & ~1);
+#else
+ int2 pos_tl = pos & ~1;
+ int2 pos_br = pos | 1;
+#endif
+
#ifdef SUPPORTS_SUBGROUP_REDUCTION
if (CAN_USE_SUBGROUP_REDUCTION) {{
- int2 min_pos = IS_HELPER_INVOCATION ? int2(2147483647, 2147483647) : pos;
- int2 max_pos = IS_HELPER_INVOCATION ? int2(-2147483648, -2147483648) : pos;
+ int2 min_pos = IS_HELPER_INVOCATION ? int2(2147483647, 2147483647) : pos_tl;
+ int2 max_pos = IS_HELPER_INVOCATION ? int2(-2147483648, -2147483648) : pos_br;
SUBGROUP_MIN(min_pos);
SUBGROUP_MAX(max_pos);
if (IS_FIRST_ACTIVE_INVOCATION)
UpdateBoundingBoxBuffer(min_pos, max_pos);
}} else {{
- UpdateBoundingBoxBuffer(pos, pos);
+ UpdateBoundingBoxBuffer(pos_tl, pos_br);
}}
#else
- UpdateBoundingBoxBuffer(pos, pos);
+ UpdateBoundingBoxBuffer(pos_tl, pos_br);
#endif
}}