diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index 3ed3caa91a..8aff55c8e7 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -3056,48 +3056,42 @@ bool GSState::SpriteDrawWithoutGaps() GSState::NoGapsType GSState::PrimitiveCoversWithoutGaps() { - if (m_primitive_covers_without_gaps.has_value()) - return m_primitive_covers_without_gaps.value(); + if (m_primitive_covers_without_gaps != Uninitialized) + return m_primitive_covers_without_gaps; - bool issue_found = false; + m_primitive_covers_without_gaps = FullCover; // Draw shouldn't be offset. if (((m_r.eq32(GSVector4i::zero())).mask() & 0xff) != 0xff) { - issue_found = true; + m_primitive_covers_without_gaps = GapsFound; } if (m_vt.m_primclass == GS_POINT_CLASS) { - m_primitive_covers_without_gaps = (m_vertex.next < 2) ? FullCover : GapsFound; + m_primitive_covers_without_gaps = (m_vertex.next < 2) ? m_primitive_covers_without_gaps : GapsFound; - return m_primitive_covers_without_gaps.value(); + return m_primitive_covers_without_gaps; } else if (m_vt.m_primclass == GS_TRIANGLE_CLASS) { - m_primitive_covers_without_gaps = (m_index.tail == 6 && TrianglesAreQuads()) ? FullCover : GapsFound; + m_primitive_covers_without_gaps = (m_index.tail == 6 && TrianglesAreQuads()) ? m_primitive_covers_without_gaps : GapsFound; - return m_primitive_covers_without_gaps.value(); + return m_primitive_covers_without_gaps; } else if (m_vt.m_primclass != GS_SPRITE_CLASS) { m_primitive_covers_without_gaps = GapsFound; - return m_primitive_covers_without_gaps.value(); + return m_primitive_covers_without_gaps; } // Simple case: one sprite. - if (issue_found == false && m_index.tail == 2) + if (m_primitive_covers_without_gaps != GapsFound && m_index.tail == 2) { - m_primitive_covers_without_gaps = FullCover; - return m_primitive_covers_without_gaps.value(); + return m_primitive_covers_without_gaps; } - if (issue_found) - m_primitive_covers_without_gaps = GapsFound; - else - m_primitive_covers_without_gaps = FullCover; - - const NoGapsType result = SpriteDrawWithoutGaps() ? (issue_found ? SpriteNoGaps : m_primitive_covers_without_gaps.value()) : GapsFound; + const NoGapsType result = SpriteDrawWithoutGaps() ? (m_primitive_covers_without_gaps == GapsFound ? SpriteNoGaps : m_primitive_covers_without_gaps) : GapsFound; m_primitive_covers_without_gaps = result; return result; diff --git a/pcsx2/GS/GSState.h b/pcsx2/GS/GSState.h index d3fae58888..abfe4ec4fa 100644 --- a/pcsx2/GS/GSState.h +++ b/pcsx2/GS/GSState.h @@ -202,7 +202,8 @@ public: enum NoGapsType { - GapsFound = 0, + Uninitialized = 0, + GapsFound, SpriteNoGaps, FullCover, }; @@ -227,7 +228,7 @@ public: u32 m_dirty_gs_regs = 0; int m_backed_up_ctx = 0; std::vector m_draw_transfers; - std::optional m_primitive_covers_without_gaps; + NoGapsType m_primitive_covers_without_gaps; GSVector4i m_r = {}; GSVector4i m_r_no_scissor = {}; diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 6ecf137e2f..0ca92b1ab4 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -1251,7 +1251,7 @@ bool GSRendererHW::IsSplitClearActive() const bool GSRendererHW::IsStartingSplitClear() { // Shouldn't have gaps. - if (m_vt.m_eq.rgba != 0xFFFF || (!m_cached_ctx.ZBUF.ZMSK && !m_vt.m_eq.z) || PrimitiveCoversWithoutGaps() == NoGapsType::GapsFound) + if (m_vt.m_eq.rgba != 0xFFFF || (!m_cached_ctx.ZBUF.ZMSK && !m_vt.m_eq.z) || PrimitiveCoversWithoutGaps() != NoGapsType::FullCover) return false; // Limit to only single page wide tall draws for now. Too many false positives otherwise (e.g. NFSU). @@ -1289,7 +1289,7 @@ bool GSRendererHW::ContinueSplitClear() return false; // Shouldn't have gaps. - if (m_vt.m_eq.rgba != 0xFFFF || (!m_cached_ctx.ZBUF.ZMSK && !m_vt.m_eq.z) || PrimitiveCoversWithoutGaps() == NoGapsType::GapsFound) + if (m_vt.m_eq.rgba != 0xFFFF || (!m_cached_ctx.ZBUF.ZMSK && !m_vt.m_eq.z) || PrimitiveCoversWithoutGaps() != NoGapsType::FullCover) return false; // Remove any targets which are directly at the start, since we checked this draw in the last. @@ -1998,7 +1998,7 @@ void GSRendererHW::Draw() m_cached_ctx.TEST = context->TEST; m_cached_ctx.FRAME = context->FRAME; m_cached_ctx.ZBUF = context->ZBUF; - m_primitive_covers_without_gaps.reset(); + m_primitive_covers_without_gaps = NoGapsType::Uninitialized; if (IsBadFrame()) { @@ -2620,7 +2620,7 @@ void GSRendererHW::Draw() m_r = m_r.rintersect(t_size_rect); float target_scale = GetTextureScaleFactor(); - int scale_draw = IsScalingDraw(src, no_gaps != NoGapsType::GapsFound); + int scale_draw = IsScalingDraw(src, no_gaps != NoGapsType::GapsFound); if (target_scale > 1.0f && scale_draw > 0) { // 1 == Downscale, so we need to reduce the size of the target also. @@ -3006,7 +3006,7 @@ void GSRendererHW::Draw() if (!m_texture_shuffle && !m_channel_shuffle) { // Try to turn blits in to single sprites, saves upscaling problems when striped clears/blits. - if (m_vt.m_primclass == GS_SPRITE_CLASS && no_gaps != NoGapsType::GapsFound && m_index.tail > 2 && (!PRIM->TME || TextureCoversWithoutGapsNotEqual()) && m_vt.m_eq.rgba == 0xFFFF) + if (m_vt.m_primclass == GS_SPRITE_CLASS && no_gaps == NoGapsType::FullCover && m_index.tail > 2 && (!PRIM->TME || TextureCoversWithoutGapsNotEqual()) && m_vt.m_eq.rgba == 0xFFFF) { // Full final framebuffer only. const GSVector2i fb_size = PCRTCDisplays.GetFramebufferSize(-1);