core: Defer BitmapData.draw into the target's pending GPU batch#23530
Open
jarca0123 wants to merge 2 commits intoruffle-rs:masterfrom
Open
core: Defer BitmapData.draw into the target's pending GPU batch#23530jarca0123 wants to merge 2 commits intoruffle-rs:masterfrom
jarca0123 wants to merge 2 commits intoruffle-rs:masterfrom
Conversation
Add infrastructure on BitmapData so callers can accumulate render commands and flush them as a single render_offscreen call instead of one submit per call. Sub-batches become separate render passes, letting MSAA-overlap cases insert resolve boundaries while non-overlapping draws merge into one pass. Use the infrastructure to keep copyPixels on the GPU when both sides are GPU-resident: - Plain replace (no blend) from a GPU-resident source to a different target uses a raw texture-to-texture copy through the new RenderBackend::copy_pixels_to_texture method. - A blend where the original src_rect covers the full source bitmap and the target is GPU-resident queues a render_bitmap command onto the target's pending batch. Contiguous copyPixels calls merge into one batch and submit as a single render_offscreen at flush time; StageQuality::Low keeps the blit out of MSAA. The CPU path stays as the fallback for same-bitmap copies, backends without offscreen support, partial-source blends, and any case the fast paths reject.
Route draw() through append_gpu_commands instead of calling render_offscreen synchronously at the end. Consecutive draw() calls onto the same target then share one render_offscreen submission at flush time. Without this, scenes that cache a lot of content via bmd.draw() (some games issue tens of thousands of draws per frame) hit the backend's per-frame draw cap repeatedly, causing a fresh command-encoder allocation per submit cycle.
01c3f13 to
a3ae8a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted by Claude Opus 4.7.
Route draw() through append_gpu_commands instead of calling
render_offscreen synchronously at the end. Consecutive draw() calls
onto the same target then share one render_offscreen submission at
flush time.
Without this, scenes that cache a lot of content via bmd.draw() (some
games issue tens of thousands of draws per frame) hit the backend's
per-frame draw cap repeatedly, causing a fresh command-encoder
allocation per submit cycle.