demo · v132

Storage vs sample: one texture, two views, two passes

The real shape of the feature. One texture, marked with three usages. A first compute pass writes through a STORAGE_BINDING-only view; a second render pass samples through a TEXTURE_BINDING-only view. Narrowing each view to its actual usage lets the driver place barriers / formats more aggressively — a compatibility gain on Vulkan / Metal.

click run to acquire device…

1. compute writes (view: STORAGE_BINDING only)

const writeView = tex.createView({
  usage: GPUTextureUsage.STORAGE_BINDING,
});
computePass.setBindGroup(0, /* bg with writeView */);

2. render samples (view: TEXTURE_BINDING only)

const sampleView = tex.createView({
  usage: GPUTextureUsage.TEXTURE_BINDING,
});
renderPass.setBindGroup(0, /* bg with sampleView */);
Pre-132 both views inherited the full texture usage; drivers had to assume either could be a storage write. v132 lets you tell the driver explicitly — cleaner barriers, sometimes a different internal format.

see also