From b8b1105ba5cc146033bbd4b5dbfb25ab0b91a780 Mon Sep 17 00:00:00 2001 From: wyc <1104749580@qq.com> Date: Mon, 17 Aug 2026 22:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kernel/src/renderive/scene/base/Scene_Base.cpp | 11 ++++++++--- Kernel/src/renderive/scene/base/Scene_Base.inl | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Kernel/src/renderive/scene/base/Scene_Base.cpp b/Kernel/src/renderive/scene/base/Scene_Base.cpp index b22a4eb..9c40f9b 100644 --- a/Kernel/src/renderive/scene/base/Scene_Base.cpp +++ b/Kernel/src/renderive/scene/base/Scene_Base.cpp @@ -496,8 +496,10 @@ Scene_Edit_Error Scene_Base::Renderable_Editor::clear_dependency_parent( } void Scene_Base::Renderable_Editor::replace_frame_control_strategy( std::shared_ptr strategy) { - scene_.d_func().frame_control().replace_frame_control_strategy( + auto& implementation = scene_.d_func(); + implementation.frame_control().replace_frame_control_strategy( std::move(strategy)); + implementation.refresh_interval_reset_pending_ = true; } Scene_Edit_Error Scene_Base::Edit_Operation::wait() const { if (!result_.valid()) ::renderive::error::unexpected("scene edit operation is invalid"); @@ -679,8 +681,11 @@ Scene_Render_Result Scene_Base::Impl::submit_render(Abstract_Frame* frame) { ? frame->state_->published_snapshot.exchange({}, std::memory_order_acq_rel) : nullptr; if (!snapshot) snapshot = capture_live_frame(); - snapshot->next_refresh_interval_ns_ = - strategy->next_refresh_interval_ns(); + // Strategy replacement is a refresh-timing boundary. The snapshot interval defaults + // to 0, so a boundary frame that may have been published by the previous strategy + // cannot inherit runtime cadence across the switch; later submissions use the current strategy. + if (std::exchange(refresh_interval_reset_pending_, false)) snapshot->next_refresh_interval_ns_ = {}; + else snapshot->next_refresh_interval_ns_ = strategy->next_refresh_interval_ns(); if (render_sequence_ == std::numeric_limits::max()) ::renderive::error::unexpected("render sequence exhausted"); snapshot->render_sequence = ++render_sequence_; auto task = std::make_shared(); diff --git a/Kernel/src/renderive/scene/base/Scene_Base.inl b/Kernel/src/renderive/scene/base/Scene_Base.inl index fa50e60..05d65bb 100644 --- a/Kernel/src/renderive/scene/base/Scene_Base.inl +++ b/Kernel/src/renderive/scene/base/Scene_Base.inl @@ -143,6 +143,7 @@ public: std::shared_ptr current_completion_; std::exception_ptr pending_exception_; std::size_t deferred_render_count_{}; + bool refresh_interval_reset_pending_{}; std::uint64_t render_sequence_{}; std::size_t pending_operations_{}; bool runtime_started_{};