-
Notifications
You must be signed in to change notification settings - Fork 260
shader: implement bicubic image sampling #1557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
waywardmonkeys
merged 1 commit into
linebender:main
from
waywardmonkeys:vello-classic-bicubic-sampling
Apr 14, 2026
+187
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outside the scope of this PR, but looking at this, I think I would handle "maybe premul" a bit differently. The atlas would always be premultiplied, so the upload of the image into the atlas would do premultiplication when needed. That would get rid of the branch here, which is especially significant for bicubic because there are so many of them. That said, I see the complication – uploads are currently done with queue.write_texture, which doesn't have any mechanism to perform the premultiplication, so there's an additional pass that would be required in the separate alpha case. I'm thinking about ways to reduce the additional memory traffic, and what comes to mind is uploading the data from the CPU into a staging texture (or buffer; I'm not sure it matters much), then using either a compute shader or a draw call to read from the staging texture and write the premultiplied pixels to the atlas.
More important than the branch, storing the atlas as always-premultiplied opens the door to using textureSample rather than textureLoad, as is being explored in #1547 (and likely other related work). That's a clear win for bilinear filtering, but less so for bicubic as it doesn't work with the negative weights. There are various tricks (Bicubic Filtering in Fewer Taps is one), but not clear it's worth the lift in the bicubic case.
I should probably capture this in an issue, especially because similar considerations apply across hybrid and classic.