feat(graphics): adopt WGSL buffer_view once every WebGPU browser ships it
Background
The buffer_view WGSL language extension lets a uniform, storage or workgroup variable be declared with an opaque buffer store type and reinterpreted as typed data at a byte offset, with bounds checking, through three built-ins:
bufferView<T>- a pointer to aTat a byte offsetbufferArrayView<T>- a pointer to a bounded, runtime-sizedarray<T>at a byte offsetbufferLength- the byte size of the buffer
This gives safe type punning and lets one buffer be partitioned into logical sections, e.g. an index count, an index array and a vertex array in a single storage buffer (the Chrome post links a wireframe sample doing exactly that).
It is a requires extension. The directive only documents the dependency and makes shader creation fail early where the extension is missing; it does not gate the feature.
Status
- Shipped in Chrome 153 (What's New in WebGPU 153-154). Chrome Canary 155 lists it in
navigator.gpu.wgslLanguageFeatures; Chrome 152 stable does not. - Not shipped in Firefox or Safari as far as we know.
Plan
Do not add engine support yet - no supports* flag, no CAPS_* define, no injected requires line, and no use in engine chunks - until every WebGPU browser ships it, so no use site ever needs a fallback path.
Candidates once it is universally available:
- Gsplat and clustered-lighting chunks that reinterpret packed data (roughly 30
bitcast<>sites, plus thearray<u32>storage buffers in the gsplat compute chunks) could read typed views from a single buffer instead. - Single-buffer partitioning for mixed data, e.g. indirect args plus counters, or index plus vertex data for vertex pulling.
- Check that the storage-buffer regex in
WebgpuShaderProcessorWGSLaccepts the opaquebufferstore type, and confirmBindGroupFormatneeds no change (the binding remains a plain storage buffer).
Triggers to revisit
- Firefox and Safari stable report
navigator.gpu.wgslLanguageFeatures.has('buffer_view') === true.
References
- https://developer.chrome.com/blog/new-in-webgpu-153-154
- https://www.w3.org/TR/WGSL/ - Buffer View Built-in Functions
Source: playcanvas/engine