vello_hybrid: Add render_to_atlas and write_to_atlas APIs for glyph caching#1458
Conversation
ddb4221 to
1ece907
Compare
|
Hmm... What I did is to change add an vello/sparse_strips/vello_hybrid/src/schedule.rs Lines 211 to 230 in b23b634 render method, would that work for you? Otherwise, seems fine at a glance, but it might be worth extracting all of the setup stuff (e.g. for encoded paints) into a wrapper function that does setup/teardown and takes a closure for the "main action". What do you think?
|
4cc5876 to
be7396b
Compare
@laurenz-canva That’s at least what I discovered after looking into |
| let result = self.render_scene( | ||
| scene, | ||
| device, | ||
| queue, | ||
| &mut encoder, | ||
| &atlas_render_size, | ||
| &layer_view, | ||
| ); |
There was a problem hiding this comment.
I think there might be a problem, which I faced when implementing filters: Our current render strips pipeline expects the color attachment to be in the native pixel format, but the atlas texture array is always RGBA8. Therefore, if the system uses a different pixel format (for example BGRA on MacOS), this will crash, right?
The solution I chose is to create two render strips pipelines, one for the native pixel format and one for always RGBA8, and use the latter when rendering into the image atlas array.
There was a problem hiding this comment.
Yes, I think so, and that’s why we pass Rgba8Unorm into the render config explicitly. But I don’t think this issue is new or introduced by the changes here; it seems like something we already had. The better approach is probably to adopt your fix once your PR lands, rather than implementing a parallel solution now.
There was a problem hiding this comment.
it seems like something we already had.
Is it? I'm not sure, because this is the first PR that introduces the ability to draw onto the image atlas texture array, no? Up until now, we've only drawn into the final surface or the slot textures, which always use the native format IIRC. I guess it's fine to ignore for now, but maybe add a TODO?
There was a problem hiding this comment.
I think you’re right. I’ll leave the TODO for now and come back to it later. It might be automatically covered once you introduce the filter effects functionality, but if there are any integration issues, I’ll take care of fixing them if you want.
be7396b to
0284ce9
Compare
0284ce9 to
b861095
Compare
taj-p
left a comment
There was a problem hiding this comment.
LGTM! Just skimmed the code
| let load_op = if clear { LoadOp::Clear } else { LoadOp::Load }; | ||
| ctx.render_strips(&self.fast_path_gpu_strips, 2, load_op); |
There was a problem hiding this comment.
cc @grebmeg - I'm not sure the clear member is honoured in the else branch of this block below on line 302
Adds public APIs to both the wgpu and webgl renderers for rendering
Scenecontent directly into atlas layers and writing pixel data to pre-allocated atlas regions. This enables a glyph caching workflow where vector glyphs are rasterized into the atlas once and reused as cached images in subsequent passes.The key additions are
render_to_atlas, which runs the scheduler targeting a specific atlas layer (using a placeholder dummy texture to avoid read-write hazards), andwrite_to_atlas, extracted fromupload_image, which writes pixel data to an already-allocated region.