From f0d3f251b4e00ae635ee88a958bd74730ce5dc57 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Mon, 6 Apr 2026 14:27:47 +0800 Subject: [PATCH] Fix editor startup gray flash --- editor/src/Platform/Win32EditorHost.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/editor/src/Platform/Win32EditorHost.h b/editor/src/Platform/Win32EditorHost.h index 2046ee41..d07e7f0a 100644 --- a/editor/src/Platform/Win32EditorHost.h +++ b/editor/src/Platform/Win32EditorHost.h @@ -96,15 +96,24 @@ inline int RunEditor(HINSTANCE hInstance, int nCmdShow) { SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast(wc.hIconSm)); } - ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); - if (!Application::Get().Initialize(hwnd)) { DestroyWindow(hwnd); UnregisterClassW(wc.lpszClassName, wc.hInstance); return 1; } + // Warm up a few hidden frames first. On D3D12 flip-model swap chains the first visible + // presents can otherwise show only the host clear color while the UI/render backend settles. + constexpr int kBootstrapFrameCount = 3; + for (int frameIndex = 0; frameIndex < kBootstrapFrameCount; ++frameIndex) { + Application::Get().Render(); + } + + // Show the window only after the swap chain already contains composed editor frames. + ShowWindow(hwnd, nCmdShow); + Application::Get().Render(); + UpdateWindow(hwnd); + MSG msg = {}; while (msg.message != WM_QUIT) { if (PeekMessageW(&msg, nullptr, 0U, 0U, PM_REMOVE)) {