diff options
| author | JMC47 <JMC4789@gmail.com> | 2021-06-11 00:41:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-11 00:41:11 -0400 |
| commit | 0c6e00ce0c8da1d81094bb41fea2eafe6b279891 (patch) | |
| tree | 517080124b8499aa7c5907a0a7b02fb02ab78534 /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | a51d01bb809bddaa2c221b0e9a6d0b935a285bce (diff) | |
| parent | b267f54259c7e1b9d9bd8a5874af559b76925184 (diff) | |
Merge pull request #9801 from Techjar/bbox-rounding-hack
VideoCommon: Only include centered pixels in bounding box
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 567d161565..988e85b199 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -489,9 +489,18 @@ void UpdateBoundingBoxBuffer(int2 min_pos, int2 max_pos) {{ }} void UpdateBoundingBox(float2 rawpos) {{ + // We only want to include coordinates for pixels aligned with the native resolution pixel centers. + // This makes bounding box sizes more accurate (though not perfect) at higher resolutions, + // avoiding EFB copy buffer overflow in affected games. + // + // For a more detailed explanation, see https://dolp.in/pr9801 + int2 int_efb_scale = iround(1 / {efb_scale}.xy); + if (any(int2(rawpos) % int_efb_scale != int_efb_scale >> 1)) // divide by two + return; + // The rightmost shaded pixel is not included in the right bounding box register, // such that width = right - left + 1. This has been verified on hardware. - int2 pos = int2(rawpos * cefbscale); + int2 pos = int2(rawpos * {efb_scale}.xy); #ifdef API_OPENGL // We need to invert the Y coordinate due to OpenGL's lower-left origin @@ -500,8 +509,8 @@ void UpdateBoundingBox(float2 rawpos) {{ // 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. - int2 pos_tl = pos & ~1; - int2 pos_br = pos | 1; + int2 pos_tl = pos & ~1; // round down to even + int2 pos_br = pos | 1; // round up to odd #ifdef SUPPORTS_SUBGROUP_REDUCTION if (CAN_USE_SUBGROUP_REDUCTION) {{ @@ -520,7 +529,7 @@ void UpdateBoundingBox(float2 rawpos) {{ }} )", - fmt::arg("efb_height", EFB_HEIGHT)); + fmt::arg("efb_height", EFB_HEIGHT), fmt::arg("efb_scale", I_EFBSCALE)); } } |
