diff options
| author | Connor McLaughlin <stenzek@gmail.com> | 2021-05-29 17:00:14 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-29 17:00:14 +1000 |
| commit | b31d4400e31503861cce0bb0ccff6da71bddf277 (patch) | |
| tree | 492f8395eecd2bc65566033783a32f9456affefb /Source/Core/VideoCommon | |
| parent | 7b2b05cc219c1591ab328fefabd9435aff748c08 (diff) | |
| parent | a24e78b3cf07e8d169d97a2e4c3635b9efbdba35 (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')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 19 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 26 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.h | 10 |
3 files changed, 18 insertions, 37 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 }} diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 0ff5b52902..93f8fa2279 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -185,32 +185,6 @@ void Renderer::ReinterpretPixelData(EFBReinterpretType convtype) g_framebuffer_manager->ReinterpretPixelData(convtype); } -u16 Renderer::BBoxRead(int 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) -{ - BBoxWriteImpl(index, value); -} - -void Renderer::BBoxFlush() -{ - BBoxFlushImpl(); -} - u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) { if (type == EFBAccessType::PeekColor) diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 1deedd4f76..48cef0bdad 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -211,9 +211,9 @@ public: virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data); virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points); - u16 BBoxRead(int index); - void BBoxWrite(int index, u16 value); - void BBoxFlush(); + virtual u16 BBoxRead(int index) = 0; + virtual void BBoxWrite(int index, u16 value) = 0; + virtual void BBoxFlush() {} virtual void Flush() {} virtual void WaitForGPUIdle() {} @@ -301,10 +301,6 @@ protected: // Should be called with the ImGui lock held. void DrawImGui(); - virtual u16 BBoxReadImpl(int index) = 0; - virtual void BBoxWriteImpl(int index, u16 value) = 0; - virtual void BBoxFlushImpl() {} - AbstractFramebuffer* m_current_framebuffer = nullptr; const AbstractPipeline* m_current_pipeline = nullptr; |
