From eb9d457eb0101b8e15773024307d806b2a37cc13 Mon Sep 17 00:00:00 2001 From: Enik Land Date: Tue, 16 Sep 2025 20:37:28 -0300 Subject: [PATCH] Move switching of screen's current bitmap to after layout updates --- src/emu/screen.cpp | 25 ++++++++++++++++++++++--- src/emu/screen.h | 1 + src/emu/video.cpp | 17 +++++++++++++++++ src/emu/video.h | 1 + 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index 849c1dff8bb1c..3c49a6d5e6766 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -1779,7 +1779,6 @@ bool screen_device::update_quads() } m_texture[m_curbitmap]->set_bitmap(m_bitmap[m_curbitmap], m_visarea, m_bitmap[m_curbitmap].texformat()); m_curtexture = m_curbitmap; - m_curbitmap = 1 - m_curbitmap; } // brightness adjusted render color @@ -1791,10 +1790,30 @@ bool screen_device::update_quads() } } + return m_changed; +} + + +//------------------------------------------------- +// switch current bitmap +//------------------------------------------------- + +void screen_device::switch_current_bitmap() +{ + // only updated if live + if (machine().render().is_live(*this)) + { + // only updated if empty and not a vector game; otherwise assume the driver did it directly + if (m_type != SCREEN_TYPE_VECTOR && (m_video_attributes & VIDEO_SELF_RENDER) == 0) + { + // if we're not skipping the frame and if the screen actually changed, then switch the bitmap + if (!machine().video().skip_this_frame() && m_changed) + m_curbitmap = 1 - m_curbitmap; + } + } + // reset the screen changed flags - bool result = m_changed; m_changed = false; - return result; } diff --git a/src/emu/screen.h b/src/emu/screen.h index ddc7510d8f722..00e1b7f08875c 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -415,6 +415,7 @@ class screen_device : public device_t // internal to the video system bool update_quads(); + void switch_current_bitmap(); void update_burnin(); // globally accessible constants diff --git a/src/emu/video.cpp b/src/emu/video.cpp index 75ba128df91fe..c540aab3e40bf 100644 --- a/src/emu/video.cpp +++ b/src/emu/video.cpp @@ -244,6 +244,10 @@ void video_manager::frame_update(bool from_debugger) machine().osd().update(!from_debugger && skipped_it); } + // prepare screens for next frame + if (update_screens) + post_screen_updates(); + // we synchronize after rendering instead of before, if low latency mode is enabled if (!from_debugger && phase > machine_phase::INIT && m_low_latency && effective_throttle()) update_throttle(current_time); @@ -655,6 +659,19 @@ bool video_manager::finish_screen_updates() } +//------------------------------------------------- +// post_screen_updates - prepare screens for next +// frame +//------------------------------------------------- + +void video_manager::post_screen_updates() +{ + screen_device_enumerator iter(machine().root_device()); + + for (screen_device &screen : iter) + screen.switch_current_bitmap(); +} + //------------------------------------------------- // update_throttle - throttle to the game's diff --git a/src/emu/video.h b/src/emu/video.h index 6517c90d170bf..1579277585810 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -101,6 +101,7 @@ class video_manager // speed and throttling helpers int original_speed_setting() const; bool finish_screen_updates(); + void post_screen_updates(); void update_throttle(attotime emutime); osd_ticks_t throttle_until_ticks(osd_ticks_t target_ticks); void update_frameskip();