playcanvas / playcanvas/engine
feat(graphics): adopt WGSL buffer_view once every WebGPU browser ships it
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Revisit this issue when Firefox and Safari report buffer_view in navigator.gpu.wgslLanguageFeatures. Start by reviewing WebgpuShaderProcessorWGSL and BindGroupFormat, then assess the listed gsplat, clustered-lighting, and single-buffer candidates. Done means the universally available extension has been evaluated for those use sites without adding support prematurely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100