fix: preserve image atlas across patchless resolves#1664
Conversation
|
This was done with the assistance of Codex (GPT 5.5, xhigh). It was found while updating This was a result of changes that I introduced for Vello 0.8. We should do a 0.9.1 release with this fix. (And let's see if there are other fixes...) |
Vello's renderer keeps a persistent GPU image atlas, while the resolver tracks logical atlas residency and dirty image uploads. Patchless resolves used to return Images::default(), which made the renderer treat an image-free frame as a 0x0 atlas and replace a previously populated atlas with a fresh 1x1 texture. The resolver still kept resident image entries marked clean. If a later scene reused the same image, it returned cached atlas coordinates but scheduled no upload. When the renderer grew the atlas back to its previous size, that new GPU texture did not contain the resident image, so image brushes, including glyph image brushes, sampled blank content. Patchless resolves now begin an image-cache resolve and return the cache's resident atlas state when there are resident images. That clears the per-resolve upload list while preserving the GPU atlas those clean images sample from. Fresh patchless resolves with no resident images still report no atlas, so image-free frames do not allocate the default image atlas just to draw solid content. Shader hot reload had the same class of failure: it dropped the GPU atlas by replacing the engine while keeping clean resolver residency. Reset resolver state when reloading shaders, and carry image overrides into the new engine so the next image frame uploads into the fresh atlas. Add focused coverage for the root invariant and the failing GPU sequence: image brush glyphs rendered before and after an image-free frame with the same renderer.
86e61e2 to
4d1a949
Compare
|
I kicked off a group of adversarial subagents and it found a couple of further things wrong. PR updated. |
raphlinus
left a comment
There was a problem hiding this comment.
Sorry for the delay in reviewing; even though it's not a big patch, I needed to get my head back around the issues. I can see now what it fixes, and the tests capture that. A couple of nits in the comments which don't block landing, just possible opportunities to clean up tests.
| use peniko::{Blob, ImageAlphaType, ImageBrush, ImageFormat}; | ||
| use std::sync::Arc; | ||
|
|
||
| fn image(id_byte: u8, width: u32, height: u32) -> ImageData { |
There was a problem hiding this comment.
Name "id_byte" is confusing to me, it's not an id, it seems to be the image contents.
|
|
||
| #[test] | ||
| #[cfg_attr(skip_gpu_tests, ignore)] | ||
| fn glyph_image_brush_survives_image_free_render() { |
There was a problem hiding this comment.
This seems to be doing an awful lot of the harness work from scratch as opposed to using existing harnesses. In particular, it seems to duplicate a lot of logic in get_scene_image(). Is there a particular reason that wasn't reused?
Vello's renderer keeps a persistent GPU image atlas, while the resolver tracks logical atlas residency and dirty image uploads. Patchless resolves used to return Images::default(), which made the renderer treat an image-free frame as a 0x0 atlas and replace a previously populated atlas with a fresh 1x1 texture.
The resolver still kept resident image entries marked clean. If a later scene reused the same image, it returned cached atlas coordinates but scheduled no upload. When the renderer grew the atlas back to its previous size, that new GPU texture did not contain the resident image, so image brushes, including glyph image brushes, sampled blank content.
Patchless resolves now begin an image-cache resolve and return the cache's resident atlas state when there are resident images. That clears the per-resolve upload list while preserving the GPU atlas those clean images sample from. Fresh patchless resolves with no resident images still report no atlas, so image-free frames do not allocate the default image atlas just to draw solid content.
Shader hot reload had the same class of failure: it dropped the GPU atlas by replacing the engine while keeping clean resolver residency. Reset resolver state when reloading shaders, and carry image overrides into the new engine so the next image frame uploads into the fresh atlas.