render target: allow linear filtering, keep nearest as the default - #3
Open
shadowcodex wants to merge 1 commit into
Open
render target: allow linear filtering, keep nearest as the default#3shadowcodex wants to merge 1 commit into
shadowcodex wants to merge 1 commit into
Conversation
|
@shadowcodex is attempting to deploy a commit to the Eric Rowell's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
Please let me know if this isn't applicable, and if there is an alternative. |
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.
createRenderTargethard-codes its sampler to nearest:The comment above it explains why:
The second half of that is right and this PR keeps it. The first half no longer matches the code:
TARGET_FORMATisrgba16float, which is filterable in core WebGPU with no optional feature, and norgba32floattarget is created anywhere in the runtime. So the hardware constraint the comment cites does not apply to any target that exists.Why it matters
It matters for a target that holds an image rather than state. A bloom downsample chain is the case: each level samples the one above it at half resolution, and with point sampling the result is blocky and crawls under motion. Today the only way to get a smooth downsample is many taps per texel, emulating in the shader the bilinear filter the hardware would do for free.
What changed
filter?: 'nearest' | 'linear'onRenderTargetOptions, defaulting to'nearest'. No existing caller changes behaviour. The doc comment onRenderTargetis updated, since it currently states unfiltered sampling as unconditional.Tests
Two checks added to
scripts/gpu/entry.ts, following that file's rule that every assertion reads pixels back off the canvas. A 2×1 target holding a hard black/white step is magnified across the canvas and probed at 40% across — nearer the left texel's centre:nearestmust return that texel unchangedlinearmust return a blendProbing at exactly 50% would land on the tie-break between the two texels, where nearest is implementation-defined. I got that wrong first time and the test failed for the wrong reason, so the probe position now has a comment saying why it is 40%.
Both pass on Chrome/WebGPU. The node suite is unchanged at 318 passing, and
npm run typecheckis clean. WebKit did not run locally —playwright-core install webkitwas missing in my environment, not related to this change.Context
Found while building an HDR post-processing pipeline on 0.17.2. It is one of two independent runtime fixes, submitted separately so each stands on its own; the sibling is offscreen multisampling. We are carrying both as local patches over the published package in the meantime, so there is no urgency from our side.
Over to you
Genuine questions, not politeness: