render target: allow an off-screen pass to keep multisampling - #4
Open
shadowcodex wants to merge 1 commit into
Open
render target: allow an off-screen pass to keep multisampling#4shadowcodex 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.
createRenderer(canvas, { antialias: true })gives a scene 4x MSAA on screen. The moment that same scene renders into a render target, it silently drops to one sample:That line is not wrong on its own, and it took me a while to see why. The target texture is single-sampled, and a pipeline must match its attachment, so
1was the only valid value. Raising it alone just fails pipeline validation. The missing piece is the multisampled attachment, not the number.Why it matters
Adopting any off-screen pass — an HDR buffer before tone mapping, a post-processing chain, bloom — costs all anti-aliasing, on every silhouette edge, with no warning. It reads as "my post-processing made everything jaggy", which is a confusing place to end up when the cause is in the runtime rather than in the effect.
The on-screen path already does the right thing (
webgpu.ts, thepresentbranch): it allocates a multisampled colour texture, renders into it, and resolves into the swapchain view. The off-screen path just had no equivalent.What changed
samples?: numberonRenderTargetOptions, defaulting to1so nothing changes for existing callers. When it is greater than 1:TARGET_FORMATis allocated as the pass's colour attachment, resolving into the target texture (storeOp: 'discard', since it has no use after the resolve);sampleCount, because a pass requires its attachments to agree;internals.passSamplescarries the target's count instead of a hard-coded1.The target texture itself stays single-sampled and receives the resolve, so sampling it afterwards is unchanged.
Tests
A check added to
scripts/gpu/entry.ts, following that file's rule that assertions read pixels back. A diagonal edge is drawn into an off-screen target and magnified, and the distinct values along one scanline are counted:It reuses the existing
gpu-target-readfixture rather than adding another, since that fixture's blue channel already carries the stored value straight out of the target.Both pass on Chrome/WebGPU. Node suite unchanged at 318 passing,
npm run typecheckclean. WebKit did not run locally —playwright-core install webkitwas missing in my environment, unrelated to this change.Notes
samplesis anumberrather than a1 | 4union because supported counts are a device capability. Validating it against the device would be a reasonable addition; I left it out rather than guess at the API you would want.Independent of the render-target filtering PR — either can land without the other. Both were found while building an HDR pipeline on 0.17.2, and we are carrying them as local patches over the published package meanwhile, so there is no urgency from our side.
Over to you
Genuine questions, not politeness: