Skip to content

[Impeller] Release swapchain GPUProbe on fence completion - #197024

Draft
andywolff wants to merge 1 commit into
flutter:masterfrom
andywolff:gpu-tracer-multi-surface
Draft

andywolff wants to merge 1 commit into
flutter:masterfrom
andywolff:gpu-tracer-multi-surface

Conversation

@andywolff

@andywolff andywolff commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of #196834

When a secondary swapchain renders a frame and then goes idle (such as an overlay swapchain when platform views scroll offscreen or no Flutter layers overlap them), it retains its last onscreen command buffer and GPUProbe in its frame-synchronizer ring until that slot is overwritten two presents later on the same swapchain. Because all swapchains on a context share GPUTracerVK's 16-slot trace_states_ ring, those retained probes keep pending_buffers non-zero on that trace state, dropping GPU frame time metrics and triggering the state.pending_buffers == 0u debug assertion once the active swapchain wraps around 16 frames later.

This PR fixes this by transferring ownership of final_cmd_buffer's GPUProbe from AHBSwapchainImplVK and KHRSwapchainImplVK to FenceWaiterVK via a trailing queue fence in GPUTracerVK::ReleaseCommandBufferOnFence whenever GPU tracing is enabled and the probe has an active frame index, so the probe is destroyed as soon as the GPU finishes regardless of whether that swapchain presents again.

This also fixes GPUTracerVK::RecordCmdBufferEnd to index the probe's own trace state slot (*probe.index_) rather than current_state_, and aligns AHBSwapchainImplVK with KHRSwapchainImplVK by calling MarkFrameStart and MarkFrameEnd without #if IMPELLER_DEBUG guards (relying on GPUTracerVK::enabled_).

Pre-launch Checklist

@andywolff
andywolff force-pushed the gpu-tracer-multi-surface branch 2 times, most recently from 365acf6 to 7127b0d Compare November 20, 2026 16:07
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Nov 20, 2026
@andywolff andywolff added the CICD Run CI/CD label Nov 20, 2026
@andywolff
andywolff force-pushed the gpu-tracer-multi-surface branch from 7127b0d to f46d093 Compare November 23, 2026 20:37
@andywolff
andywolff force-pushed the gpu-tracer-multi-surface branch from f46d093 to 7f7504d Compare November 24, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant