fix(WebGPU): apply projection once in ImageMapper and refresh imageData textures#3547
Open
sedghi wants to merge 2 commits into
Open
fix(WebGPU): apply projection once in ImageMapper and refresh imageData textures#3547sedghi wants to merge 2 commits into
sedghi wants to merge 2 commits into
Conversation
The generated vertex shader multiplied by rendererUBO.SCPCMatrix twice (regression from 7fbc87a), pushing the doubly-projected slice quad outside the clip volume for close-in cameras, and stored a clip-space position in vertexSC, which clip planes expect in stabilized coordinates. Capture vertexSC before projecting and project once. Adds a WebGPU regression test and enables the WebGPU adapter for headless Chromium test runs.
getTextureForImageData keyed the texture cache on the scalar array mtime alone, so consumers that write scalars in place and signal the change with imageData.modified() (the pattern the OpenGL backend keys its texture rebuilds on) kept getting the stale texture. Key the cache on the newest of the imageData and scalar array mtimes. Adds a WebGPU regression test.
daker
approved these changes
Jul 10, 2026
daker
left a comment
Collaborator
There was a problem hiding this comment.
+1 it will fix MultiSliceImageMapper example
6 tasks
Contributor
Author
5 tasks
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.


Context
The WebGPU
ImageMappervertex shader appliesrendererUBO.SCPCMatrixtwice (regression from 7fbc87a). With close-in cameras — e.g. a parallel camera one unit in front of the slice, as medical viewers set up — the doubly-projected quad falls outside the clip volume and the slice silently renders nothing. The same commit also stores a clip-space position invertexSC, which the clip-plane code expects in stabilized coordinates.Separately,
TextureManager.getTextureForImageDatakeys its texture cache on the scalar array mtime alone, so writing scalars in place and signaling withimageData.modified()(the invalidation the OpenGL backend keys texture rebuilds on) keeps returning the stale texture.Both were found while rendering image stacks on the WebGPU view API from Cornerstone3D.
Results
ImageMapperexample and?viewAPI=WebGPU).ImageMapperare evaluated in stabilized coordinates again.imageData.modified()is called.Changes
WebGPU/ImageMapper: capturevertexSCbefore projecting, applySCPCMatrixonce (matchesImageResliceMapper/ImageCPRMapper).WebGPU/TextureManager: key thegetTextureForImageDatacache on the newest of the imageData and scalar array mtimes.vitest.config.js: pass--enable-unsafe-webgputo headless Chromium forWEBGPU=1runs (plus the SwiftShader WebGPU adapter on CI) so the WebGPU tests can acquire an adapter.PR and Code Checklist
npm run reformatto have correctly formatted codeTesting
Two regression tests, one per fix; both fail without the fixes: