Fix lighting volume WGSL depth texture binding#18658
Open
matthargett wants to merge 1 commit into
Open
Conversation
LightingVolume binds the shadow generator's shadow map depthStencilTexture - a depth-format texture - as the shadowMap input of the lightingVolume compute shader. Declare that binding as texture_depth_2d instead of texture_2d<f32>, and drop the .r swizzle on the textureLoad result since textureLoad on texture_depth_2d returns a scalar f32. The loaded value is the same depth that .r previously carried, so far-plane fitting results are unchanged. This completes the compute depth sample-type support introduced in PR BabylonJS#18460: _GetComputeTextureSampleType classifies this texture as bind group layout sampleType "depth", and WebGPU validation requires a texture_depth_2d WGSL declaration for a "depth" layout entry. With the previous texture_2d<f32> declaration, createComputePipeline fails validation (observed in Chromium and wgpu-native) as soon as the lighting volume compute shaders run with an explicit pipeline layout. The change is also safe with the default auto layout: texture_depth_2d derives sampleType "depth", which is valid for the depth-aspect view Babylon binds, so behavior is identical there. This came from the Hill Valley GLTF/NativeXR AR Portal validation pass. (cherry picked from commit a81ccfb)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a WebGPU/WGSL binding-type mismatch for the lighting volume compute shader by declaring the shadow map input as a depth texture, matching the pipeline layout’s inferred sample type (Depth) and avoiding validation failures when using explicit pipeline layouts.
Changes:
- Declare
shadowMapastexture_depth_2dinlightingVolume.compute.fxto align with depth-texture bind group layout requirements. - Update
textureLoadusage to consume the scalarf32result returned by depth textures (remove the.rswizzle).
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.
Replaces #18564 after it was closed while I was on summer holidays.
Rebased on latest
master; the change is still limited to treating the lighting volume shadow map as a WGSL depth texture and reading it withtextureLoad.Local validation:
npx nx build babylonjs --outputStyle=staticnpx nx build babylonjs-gui --outputStyle=staticnpm run check:treeshaking