Skip to content

vello_hybrid: Support extend modes for external texture rects - #1813

Merged
LaurenzV merged 3 commits into
mainfrom
laurenz/texture_rect
Aug 13, 2026
Merged

vello_hybrid: Support extend modes for external texture rects#1813
LaurenzV merged 3 commits into
mainfrom
laurenz/texture_rect

Conversation

@LaurenzV

Copy link
Copy Markdown
Collaborator

Based on #1812.

Context

The main reason for opening this PR is that currently, the external texture rect API has no way of supporting other extend modes. This PR proposes tweaking the existing API for drawing external texture rects such that this use case can be accommodated.

Implementation

It took me a while to figure out what the best way of implementing this is. Ultimately, I arrived at the conclusion that we should change the existing draw_texture_rects API to instead have a single draw_texture_rect API. I presume the original motivation for having the ability to submit multiple texture rectangles at once is performance. However, if you look at the actual implementation, the bulk of the work happens inside of the loop that iterates over each rectangles. Only very little work is lifted outside of the loop, so I don’t see any performance benefit in having a batched method for this. On the other hand, by making the API only take a single texture rect, we can make it more consistent with how other methods work and more easily add support for the missing features. For example, the Scene::paint_transform field now actually serves a purpose for external textures.

In order to get what we need, I also changed the API to taking two different rectangles: A source and a destination rectangle. The source rectangle defines what the area is we want to sample, and the destination (as well as path/paint transform) how it’s mapped into the actual scene. Any pixel that would fall outside of the source region but still be visible in the destination region is sampled according to the extend mode.

This PR was done with assistance of GPT 5.6 Sol.

Also CC @tomcur since he designed the original API.

@LaurenzV
LaurenzV requested a review from grebmeg August 11, 2026 15:56
Base automatically changed from laurenz/opaque_external_textures to main August 12, 2026 10:50
Comment on lines +19 to +22
pub source_region: RectU16,

/// Destination rectangle in local scene coordinates.
pub destination_rect: Rect,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename these to source_rect and destination_rect for consistency, since both values are rectangles? src_rect and dst_rect would also be concise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up doing dest instead.

Comment thread sparse_strips/vello_hybrid/src/scene.rs
@LaurenzV
LaurenzV enabled auto-merge August 13, 2026 05:05
@LaurenzV
LaurenzV added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit 08576de Aug 13, 2026
20 checks passed
@LaurenzV
LaurenzV deleted the laurenz/texture_rect branch August 13, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants