Resources

Resources and address spaces

A resource is a declare, which is TypeScript for a value something else provides. The address space is the wrapper type on the annotation. The access mode of a storage binding is the one its writes give, so a binding some entry writes is read-write and every other one is read-only, and every resource is a const.

WGSLTypeShade
@group(0) @binding(0) var<uniform> camera: Camera;
declare const camera: uniform<Camera>
@group(0) @binding(1) var<storage, read> src: array<f32>;
declare const src: storage<array<f32>>
@group(0) @binding(2) var<storage, read_write> dst: array<f32>;
declare const dst: storage<array<f32>, "read_write">
@group(0) @binding(3) var tex: texture_2d<f32>;
declare const tex: texture_2d<f32>
@group(0) @binding(4) var smp: sampler;
declare const smp: sampler
var<workgroup> tile: array<f32, 64>;
let tile: workgroup<array<f32, 64>>
var<private> seed: u32 = 7u;
let seed: u32 = 7
override tint: f32 = 0.85;
const tint: override<f32> = 0.85

There is no @group or @binding to write. The slot index is the source order of the declare in the file, and the WGSL above shows what that came out as. A texture or a sampler takes the next slot the same way.

Edit this page Report a problem