← WebGPU: buffer_view feature

v153 · enabled by default · wgsl built-in function

bufferArrayView

Limited availability

  • Chrome · enabled by default 153
  • Edge · not separately reported
  • Firefox · no signal
  • Safari · closed without a position

Requires the buffer_view WGSL language extension — see the feature overview.

The bufferView variant for types without a fixed footprint: it additionally takes an explicit byte size, letting a shader split one large buffer into several regions that each carry their own dynamically-sized array tail. The result pointer covers [offset, offset + size).

syntax

Two overloads (verbatim from WGSL §17.14.2); both are @must_use:

@must_use fn bufferArrayView<T>(p : ptr<AS, buffer, AM>, offset : OI, size : SI) -> ptr<AS, T, AM>

@must_use fn bufferArrayView<T>(p : ptr<AS, buffer<N>, AM>, offset : OI, size : SI) -> ptr<AS, T, AM>
Source: WGSL §17.14.2 (fetched 2026-07-29)

inputs

ParameterTypeContract
T (template)typeHost-shareable type without a fixed footprint — it must be (or contain) a runtime-sized array; must not be nor contain an atomic or buffer type; must satisfy the address-space layout constraints for AS
pptr<AS, buffer> or ptr<AS, buffer<N>>AS ∈ {storage, uniform, workgroup}; AM a valid access mode for AS
offsetOIu32 or i32Byte offset; i32 negatives error as with bufferView; alignment rules below
sizeSIu32 or i32Byte size of the view; i32 negatives error the same way. Lets the implementation return correct arrayLength values for the resulting runtime-sized array
Source: WGSL §17.14.2 preconditions

outputs

A ptr<AS, T, AM>: if the memory locations of p are [0, bufferLength(p)), the result's memory locations are [offset, offset + size) with store type T. The runtime element count of the array inside T is derived from the view size (and the effective buffer binding) per WGSL §13.3.4; implementations track size so subsequent arrayLength calls return valid values. The size rules are designed so the resulting runtime-sized array always has at least one element.

Source: WGSL §17.14.2 description; proposal — bufferArrayView

errors

ConditionBehavior
MinTypeSize(T) > sizeInvalid memory reference at runtime; shader-creation error if size is a const-expression (using 0 for offset when it is not); pipeline-creation error if size is an override-expression
offset + size > bufferLength(p)Invalid memory reference at runtime; for fixed-size buffers, shader-creation error when the offending value is a const-expression and pipeline-creation error when it is an override-expression (use 0 for the parameter that is neither)
MinTypeSize(T) + offset > bufferLength(p)Invalid memory reference; shader-creation error if offset is a const-expression; pipeline-creation error if an override-expression
offset % RequiredAlignOf(T, AS) != 0Shader-creation error (const) / pipeline-creation error (override); otherwise the implementation rounds down: offset & ~(RequiredAlignOf(T, AS) - 1)
(size - ArrayOffset(T)) % StrideOf(array<E>) != 0Shader-creation error (const size) / pipeline-creation error (override size); otherwise the implementation uses roundDown(StrideOf(array<E>), size - ArrayOffset(T)) + ArrayOffset(T)
Negative offset or size (i32)Shader-creation error (const-expression) / pipeline-creation error (override-expression) / indeterminate value may be used (otherwise)
T has a fixed footprint, is/contains an atomic or buffer type, or violates AS layout constraintsValidation error (precondition failure)

As with bufferView, checks are interprocedural so size reductions through the call stack are respected; the alignment rule interacts with uniform_buffer_standard_layout.

Source: WGSL §17.14.2

context and exposure

Source: WGSL §17.14.2; proposal — bufferArrayView

lifecycle

  1. Declaration — buffer variable per the type rules.
  2. Reinterpretationoffset and size are validated (shader-creation / pipeline-creation / runtime invalid-reference paths).
  3. Use — the implementation tracks size alongside the pointer so arrayLength reports the view-bounded element count; indexing beyond the view is invalid memory-reference behavior.
  4. Pure pointer operation, @must_use, no state or cleanup.
Source: WGSL §17.14.2

examples

Splitting one buffer into a counted u32 region and an f32 tail (the proposal's wireframe pattern):

requires buffer_view;

@group(0) @binding(0) var<storage> indices_and_vertices : buffer;

fn foo() {
  // The first word stores the byte size of the indices region.
  let indices_size = *bufferView<u32>(&indices_and_vertices, 0);

  // Bounded view: the indices array occupies [4, 4 + indices_size).
  let indices_ptr = bufferArrayView<array<u32>>(&indices_and_vertices, 4, indices_size);

  // The vertices tail runs to the end of the buffer.
  let vertices_ptr = bufferView<array<f32>>(&indices_and_vertices, indices_size + 4);

  let index_count = arrayLength(&*indices_ptr);  // derived from `size`
  let vertex_count = arrayLength(&*vertices_ptr); // derived from the binding
}
Source: proposal — motivating example; WGSL §17.14.2

browser compatibility

Interim table (no BCD key; compiled from primary sources, 2026-07-29):

BrowserSupportEvidence
ChromeEnabled by default 153 (desktop, Android, WebView)milestone=153 listing
EdgeNot separately reportedChromium-based
FirefoxNo signalmozilla/standards-positions #1205
SafariClosed without a positionWebKit/standards-positions #294
Source: chromestatus.com/feature/5094091886034944

security and privacy

Source: WGSL §17.14.2

see also