vello_gpu: Optimize full-sized texture sampling - #1964
Draft
laurenz-canva wants to merge 1 commit into
Draft
laurenz-canva wants to merge 1 commit into
laurenz-canva wants to merge 1 commit into
Conversation
laurenz-canva
marked this pull request as draft
September 29, 2026 14:58
laurenz-canva
added this pull request to stack #1965
September 29, 2026 14:59
laurenz-canva
force-pushed
the
laurenz/test_image_fast_path
branch
from
September 29, 2026 15:08
048b162 to
42ba050
Compare
LaurenzV
force-pushed
the
laurenz/test_image_fast_path
branch
from
September 30, 2026 06:18
42ba050 to
bfec171
Compare
laurenz-canva
force-pushed
the
laurenz/test_image_fast_path
branch
2 times, most recently
from
September 30, 2026 07:09
5b66f7a to
9eaef9e
Compare
laurenz-canva
force-pushed
the
laurenz/test_image_fast_path
branch
from
September 30, 2026 07:47
9eaef9e to
c31e48a
Compare
laurenz-canva
force-pushed
the
laurenz/test_image_fast_path
branch
2 times, most recently
from
September 30, 2026 08:42
fa12eb3 to
597aa52
Compare
LaurenzV
reviewed
Sep 30, 2026
Comment on lines
+83
to
+90
| /// **It is important that the provided width and height match the actual dimensions of the | ||
| /// texture, otherwise, rendering might be corrupted!** | ||
| Full { | ||
| /// Width of the bound texture view. | ||
| width: u16, | ||
| /// Height of the bound texture view. | ||
| height: u16, | ||
| }, |
Collaborator
There was a problem hiding this comment.
In theory, we could derive that information ourselves using textureDimensions in the shader. However, I faintly remember this being a performance footgun. Hence why I think it's better to require that information to be passed along.
| ); | ||
| out.sample_xy = get_native_image_translate(image_texel1) | ||
| + get_native_image_transform(image_texel0) * pos; | ||
| out.payload = get_native_image_opacity(image_texel1); |
Collaborator
There was a problem hiding this comment.
Bit annoying to abuse the payload like this. 😅 But it avoids having to do another texture sample in the fragment shader, as all the metadata we need is passed directly.
LaurenzV
marked this pull request as ready for review
September 30, 2026 08:58
LaurenzV
reviewed
Oct 1, 2026
| (paint_and_rect_flag >> EXTERNAL_TEXTURE_SLOT_SHIFT) & 0x3u; | ||
|
|
||
| if external_texture_slot == 0u { | ||
| final_color = paint_alpha * textureSampleLevel(external_texture_0, external_sampler_0, sample_xy, 0.0); |
LaurenzV
marked this pull request as draft
October 1, 2026 09:30
laurenz-canva
force-pushed
the
laurenz/test_image_fast_path
branch
from
October 1, 2026 10:58
597aa52 to
340a2ca
Compare
laurenz-canva
removed this pull request from stack #1965
October 1, 2026 10:59
laurenz-canva
added this pull request to stack #1969
October 1, 2026 11:00
This branch has not been deployed
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.
This PR adds a fast path for images where we want to sample the whole texture. When this is the case, we can make use of WebGL sampler objects to define whether to use NN/bilinear sampling as well as which extend mode to use, without us having to reimplement these operations in software! This is much faster, see this video and compare to the FPS numbers from #1963 instead:
IMG_1298.MOV
The only two downsides are that
ImageQuality::Low.Once this (and the preceding PR) have been approved, I will make sure to rerun tests on other devices to ensure we are not creating any regressions by making the shader bigger.