fix: avoid editor viewport resize deadlock
This commit is contained in:
@@ -96,6 +96,10 @@ void Application::ShutdownEditorContext() {
|
||||
|
||||
void Application::RenderEditorFrame() {
|
||||
static constexpr float kClearColor[4] = { 0.22f, 0.22f, 0.22f, 1.0f };
|
||||
if (!m_windowRenderer.BeginFrame()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_imguiBackend.BeginFrame();
|
||||
m_viewportHostService.BeginFrame();
|
||||
m_layerStack.onImGuiRender();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user