From 48fba47ee61214ae87a356bcc89ddc7fb6120ec8 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 4 Apr 2020 00:10:41 +1000 Subject: [PATCH] GPU: Implement skip-drawing-to-active-field for interlaced mode Currently only in the software renderer. --- src/core/gpu.cpp | 2 +- src/core/gpu.h | 6 ++++++ src/core/gpu_commands.cpp | 3 +++ src/core/gpu_sw.cpp | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 4b74b66bc..9a4a60aa6 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -240,7 +240,7 @@ u32 GPU::ReadRegister(u32 offset) // code can be dependent on the odd/even bit, so update the GPU state when reading. // we can mitigate this slightly by only updating when the raster is actually hitting a new line if (IsRasterScanlinePending()) - m_tick_event->InvokeEarly(true); + Synchronize(); return m_GPUSTAT.bits; } diff --git a/src/core/gpu.h b/src/core/gpu.h index 7e3a01a10..8f6a22416 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -400,6 +400,12 @@ protected: static constexpr u32 MASK = (1 << 19) | (1 << 22); return ((bits & MASK) == MASK); } + bool SkipDrawingToActiveField() const + { + static constexpr u32 MASK = (1 << 19) | (1 << 22) | (1 << 10); + static constexpr u32 ACTIVE = (1 << 19) | (1 << 22); + return ((bits & MASK) == ACTIVE); + } // During transfer/render operations, if ((dst_pixel & mask_and) == 0) { pixel = src_pixel | mask_or } u16 GetMaskAND() const diff --git a/src/core/gpu_commands.cpp b/src/core/gpu_commands.cpp index 08358491b..7cc673223 100644 --- a/src/core/gpu_commands.cpp +++ b/src/core/gpu_commands.cpp @@ -306,6 +306,9 @@ bool GPU::HandleRenderCommand(const u32*& command_ptr, u32 command_size) primitive_names[static_cast(rc.primitive.GetValue())], ZeroExtend32(num_vertices), ZeroExtend32(words_per_vertex)); + if (m_GPUSTAT.SkipDrawingToActiveField() && IsRasterScanlinePending()) + Synchronize(); + DispatchRenderCommand(rc, num_vertices, command_ptr); command_ptr += total_words; m_stats.num_vertices += num_vertices; diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 75c7e0396..d5c29f0ad 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -574,6 +574,9 @@ void GPU_SW::ShadePixel(u32 x, u32 y, u8 color_r, u8 color_g, u8 color_b, u8 tex if ((bg_color.bits & mask_and) != 0) return; + if (m_GPUSTAT.SkipDrawingToActiveField() && BoolToUInt32(m_GPUSTAT.drawing_even_line) != (static_cast(y) & 1u)) + return; + SetPixel(static_cast(x), static_cast(y), color.bits | m_GPUSTAT.GetMaskOR()); }