fix: avoid editor viewport resize deadlock

This commit is contained in:
2026-03-28 17:16:25 +08:00
parent 3b652ac1db
commit 2b255751b6
2 changed files with 21 additions and 3 deletions

View File

@@ -155,6 +155,23 @@ public:
RecreateBackBufferViews();
}
bool BeginFrame() {
auto* d3d12Queue = GetD3D12CommandQueue();
auto* d3d12CommandList = GetD3D12CommandList();
if (m_swapChain == nullptr ||
d3d12Queue == nullptr ||
d3d12CommandList == nullptr ||
m_srvHeap == nullptr) {
return false;
}
// Viewport panels can resize and recreate render targets while building ImGui.
// Make sure the previous frame is fully retired before any CPU-side resource destruction.
d3d12Queue->WaitForPreviousFrame();
m_commandList->Reset();
return true;
}
void Render(
UI::ImGuiBackendBridge& imguiBackend,
const float clearColor[4],
@@ -168,9 +185,6 @@ public:
return;
}
d3d12Queue->WaitForPreviousFrame();
m_commandList->Reset();
if (beforeUiRender) {
beforeUiRender(GetRenderContext());
}