playcanvas / playcanvas/engine

feat(graphics): adopt WGSL buffer_view once every WebGPU browser ships it

Open
#9,389 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: graphics
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 a T at a byte offset
  • bufferArrayView<T> - a pointer to a bounded, runtime-sized array<T> at a byte offset
  • bufferLength - 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:

  1. Gsplat and clustered-lighting chunks that reinterpret packed data (roughly 30 bitcast<> sites, plus the array<u32> storage buffers in the gsplat compute chunks) could read typed views from a single buffer instead.
  2. Single-buffer partitioning for mixed data, e.g. indirect args plus counters, or index plus vertex data for vertex pulling.
  3. Check that the storage-buffer regex in WebgpuShaderProcessorWGSL accepts the opaque buffer store type, and confirm BindGroupFormat needs 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.