diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index f04d8f9390..3ceb142b69 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -442,6 +442,7 @@ void GLRenderManager::BeginFrame() { // In GL, we have to do deletes on the submission thread. insideFrame_ = true; + renderStepOffset_ = 0; } void GLRenderManager::Finish() { @@ -565,6 +566,8 @@ void GLRenderManager::Run(int frame) { void GLRenderManager::FlushSync() { // TODO: Reset curRenderStep_? + renderStepOffset_ += (int)steps_.size(); + int curFrame = curFrame_; FrameData &frameData = frameData_[curFrame]; { diff --git a/ext/native/thin3d/GLRenderManager.h b/ext/native/thin3d/GLRenderManager.h index a31ab31b23..eac80eac6f 100644 --- a/ext/native/thin3d/GLRenderManager.h +++ b/ext/native/thin3d/GLRenderManager.h @@ -940,7 +940,7 @@ public: // Gets a frame-unique ID of the current step being recorded. Can be used to figure out // when the current step has changed, which means the caller will need to re-record its state. int GetCurrentStepId() const { - return (int)steps_.size(); + return renderStepOffset_ + (int)steps_.size(); } private: @@ -989,6 +989,8 @@ private: // Submission time state bool insideFrame_ = false; + // This is the offset within this frame, in case of a mid-frame sync. + int renderStepOffset_ = 0; GLRStep *curRenderStep_ = nullptr; std::vector steps_; std::vector initSteps_; diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index d85af88469..7addb203a9 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -422,6 +422,7 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling) { vulkan_->BeginFrame(); insideFrame_ = true; + renderStepOffset_ = 0; frameData.profile.timestampDescriptions.clear(); if (frameData_->profilingEnabled_) { @@ -1173,6 +1174,8 @@ void VulkanRenderManager::EndSyncFrame(int frame) { void VulkanRenderManager::FlushSync() { // TODO: Reset curRenderStep_? + renderStepOffset_ += (int)steps_.size(); + int curFrame = vulkan_->GetCurFrame(); FrameData &frameData = frameData_[curFrame]; if (!useThread_) { diff --git a/ext/native/thin3d/VulkanRenderManager.h b/ext/native/thin3d/VulkanRenderManager.h index fc4b3fc7da..391d559f61 100644 --- a/ext/native/thin3d/VulkanRenderManager.h +++ b/ext/native/thin3d/VulkanRenderManager.h @@ -254,7 +254,7 @@ public: // Gets a frame-unique ID of the current step being recorded. Can be used to figure out // when the current step has changed, which means the caller will need to re-record its state. int GetCurrentStepId() const { - return (int)steps_.size(); + return renderStepOffset_ + (int)steps_.size(); } void CreateBackbuffers(); @@ -341,6 +341,8 @@ private: int curWidth_ = -1; int curHeight_ = -1; bool insideFrame_ = false; + // This is the offset within this frame, in case of a mid-frame sync. + int renderStepOffset_ = 0; VKRStep *curRenderStep_ = nullptr; bool curStepHasViewport_ = false; bool curStepHasScissor_ = false;