Conversation
| vertexPositions: { | ||
| size: 3, | ||
| // Start filling buffer from 1 vertex in | ||
| vertexOffset: 1, |
There was a problem hiding this comment.
Has the vertexOffset: 1 been missed in the WebGPU port?
There was a problem hiding this comment.
On vertexOffset: 1
Good catch. It is preserved semantically in the WebGPU path.
WebGPU does not support the same packed vertexOffset layout we use in the WebGL path, so the port materializes the equivalent neighbor window explicitly in _calculateInterleavedInstancePositions() using offsets [-1, 0, 1, 2]. That reproduces the padded access pattern from vertexOffset: 1 rather than dropping it.
| attributeManager!.addInstanced({ | ||
| instancePositions: { | ||
| size: 12, | ||
| type: 'float32', |
There was a problem hiding this comment.
Is it expected we use float32? WebGL has float64.
There was a problem hiding this comment.
On float32 vs float64
This is still the fp64 path logically, not an intentional downgrade to plain fp32.
WGSL vertex attributes here are not using float64, so on WebGPU the layer uploads:
- float32 high parts
- float32
64Lowresiduals
and reconstructs through project_position_vec3_f64(...) in the shader. So the representation is different, but it is meant to preserve the same high/low position split as the existing fp64 path.
| ? this.getAttributeManager()!.getBufferLayouts() | ||
| : this.getAttributeManager()! | ||
| .getBufferLayouts() | ||
| .map(layout => |
There was a problem hiding this comment.
On extracting the buffer layout branch to a helper
Agreed. I extracted the _getModel() buffer-layout branching/filtering into a small helper to keep the model setup easier to read, without broadening the refactor beyond that.
| type: opts.fp64 ? Float64Array : Float32Array | ||
| }, | ||
| segmentTypes: {size: 1, type: Uint8ClampedArray} | ||
| segmentTypes: {size: 1, type: Float32Array} |
There was a problem hiding this comment.
why this change? Can't we use Uint8Array?
There was a problem hiding this comment.
On Float32Array for segmentTypes
This change is to satisfy WebGPU alignment/layout requirements in the current shader path.
instanceTypes is consumed as f32 in WGSL, and WebGPU rejects the 1-byte stride / non-4-byte upload pattern that worked on the WebGL side. Keeping Uint8Array would require a separate padded representation (for example uint8x4/unorm8x4) plus extra packing and shader changes, which felt like more JS/shader churn than justified for this PR.
So Float32Array here is the minimal way to make the existing WebGPU path valid without reopening the data model further.
Background
Summary
This PR ports
PathLayerto WGSL/WebGPU and updates the website highway/path example to support device switching and device stats.Changes
PathLayer WebGPU/WGSL support
PathLayer.pathuniforms and wired them into the existing shader module.PathLayerto provide a WGSL shader source alongside the existing GLSL shaders.PathLayer, including depth state configuration.PathLayer attribute/model plumbing
PathLayerthat avoids the WebGL packedvertexOffsetpattern.fp64low partsPathLayeron WebGPU to avoid unsupportedBufferTransformusage.segmentTypesstorage fromUint8ClampedArraytoFloat32Arrayto satisfy WebGPU vertex/upload alignment requirements.getBounds()on WebGPU forPathLayer, since the WebGPU attribute layout no longer exposes the originalvertexPositionsbuffer used by the WebGL path.WGSL shader parity fixes
PathLayerjoin/cap extrusion logic to WGSL.PathLayer.layer.opacityin WGSL, matching existing layer-module usage.Shared WGSL fix
project_get_orientation_matrixinproject.wgsl.tsby correcting theselect(...)branch order.Website example updates
StatsWidget(type: 'device') to the example.Files changed
modules/layers/src/path-layer/path-layer.wgsl.tsmodules/layers/src/path-layer/path-layer-uniforms.tsmodules/layers/src/path-layer/path-layer.tsmodules/layers/src/path-layer/path-tesselator.tsmodules/core/src/shaderlib/project/project.wgsl.tswebsite/src/examples/geojson-layer-paths.jsexamples/website/highway/app.tsxValidation
yarn lintvitest run --project rendergeojson-layerandpath-layerrender casesyarn test