perf(resize): dedupe the live-resize watcher, early-out DX11 resize
The live-resize event watcher redrew for every resize event, and each resize tore down and recreated the DX11 render target even when the pixel size had not actually changed. A single drag fires both a RESIZED and a PIXEL_SIZE_CHANGED event reporting the same final size, so the work ran twice. - The watcher keys off the real pixel size and returns early when it has not moved since the last pass, collapsing the duplicate event pair into one redraw. It also bails out when called from inside an open ImGui frame, which the caption buttons can trigger. - The DX11 resize now checks the swap chain's current dimensions up front and does nothing when the size already matches and the target is live, skipping the destroy/recreate churn. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1527,6 +1527,20 @@ int main(int argc, char* argv[])
|
||||
if (event->window.windowID != SDL_GetWindowID(ctx->window))
|
||||
return true;
|
||||
|
||||
// Never nest NewFrame() inside an already-open frame — Windows min/max/restore buttons
|
||||
// (renderBorderlessControls) push SDL window events synchronously from inside app.render(). (C146)
|
||||
ImGuiContext* gctx = ImGui::GetCurrentContext();
|
||||
if (!gctx || gctx->WithinFrameScope) return true;
|
||||
|
||||
// Dedupe the RESIZED + PIXEL_SIZE_CHANGED pair: both report the same final pixel size, so render
|
||||
// once. SDL_GetWindowSizeInPixels is a consistent key across both event types (their data1/data2
|
||||
// differ — points vs pixels — and cannot be compared directly).
|
||||
int pw = 0, ph = 0;
|
||||
SDL_GetWindowSizeInPixels(ctx->window, &pw, &ph);
|
||||
static int lastW = 0, lastH = 0;
|
||||
if (pw == lastW && ph == lastH) return true;
|
||||
lastW = pw; lastH = ph;
|
||||
|
||||
// Avoid re-entrancy
|
||||
static bool in_resize_render = false;
|
||||
if (in_resize_render) return true;
|
||||
|
||||
Reference in New Issue
Block a user