Repository navigation
Keep dropped images in the atlas until the next draw - #19
Open
katulevskiy wants to merge 4 commits into
Open
katulevskiy wants to merge 4 commits into
katulevskiy wants to merge 4 commits into
Conversation
A producer that tracks damage, like an embedded browser, uploads only what changed into an image it already painted instead of a whole new image per frame: `Window::update_image` overwrites a region of the image's tile, and `RenderImage::blank` with `Window::insert_blank_image` gives a frame-sized tile without uploading blank pixels. On Linux, a dma-buf another process renders into is imported into the Vulkan device once (`Window::import_dmabuf`) and its damaged regions are copied on the GPU, so frames never touch the CPU. The device opens with VK_EXT_image_drm_format_modifier when the GPU has it, so tiled layouts import too: GPUs whose EGL renders only to tiled layouts (NVIDIA) share frames as well. `Window::dmabuf_target` names the render node and the layouts the atlas imports: uncompressed ones only, since wgpu moves an imported image out of an undefined layout without acquiring it from the producer's queue, which may reinitialize compression metadata. `on_complete` runs exactly once, outside the atlas lock, after the GPU has finished all work queued before it, errors included, so a producer can recycle a buffer as soon as the GPU stops reading it. Pixel uploads land before the frame's copies and drop the copies they cover. A lost device runs the pending completions and drops the imports; producers import again.
An inactive window slows its frame callbacks to ~30 fps to save energy. Content that follows the display, such as video or a web page, asks for the next frame with `Window::on_next_display_frame` instead: the window keeps the display's rate for that callback, and slows down again once such requests stop.
A frame callback requests the next one, which only a commit sends. A draw forced outside the frame loop left `renderer_presented` set, so the next frame that drew nothing skipped that commit: the compositor never answered and frames stopped. Reset it with each frame callback.
A window can present its last frame again without redrawing it (a present from high-rate input, a forced present on Wayland). `Window::drop_image` freed the image's tiles at once, and when they were the last ones in their atlas texture the texture went too: re-presenting the old scene then hit "texture must exist" in `WgpuAtlas::get_texture_info` and aborted the process, since the swapchain's destructor panicked during the unwind. Dropped tiles now stay until the next draw replaces the frame that may sample them. The wgpu renderer no longer panics when a scene still names a freed texture (a cached view replaying a dropped image, a cleared atlas): it skips the batch and asks for a full redraw.
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.
Stacked on #18: review only the last commit,
15ee708.A Linux user's window aborted on Zeron 0.2.138 (zui
b564a34):Cause.
Window::drop_imagefreed the image's tiles right away. When they were the last tiles in their atlas texture, the texture was freed too. A window can present its last frame again without redrawing it: during high-rate input, withrequire_presentation, or on a forced present on Wayland. That frame still names the freed texture, soget_texture_infopanicked. A second panic in the swapchain's destructor during the unwind then aborted the process.Fix.
Window::drop_imagequeues the image's atlas keys. The nextdraw()removes them before painting, once the frame that might sample them is being replaced. This change is platform independent.WgpuAtlas::get_texture_inforeturnsOption. When a scene still names a freed texture (a cached view replaying a dropped image, or a cleared atlas), the renderer skips that batch and setsneeds_redraw. Wayland and X11 then run a forced render that bypasses cached views. This replaces the panic.Tests.
window::tests::dropped_image_stays_in_the_atlas_until_the_next_drawfails before the fix and passes after it.wgpu_atlas::tests::texture_info_of_a_freed_texture_is_nonewas run on an Intel Arc (Vulkan) device.cargo test -p gpui --lib: 230 passed.cargo test -p gpui_wgpu --lib: 34 passed, 2 ignored.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.