Skip to content

Instantly share code, notes, and snippets.

@greggman
Created February 6, 2026 01:07
Show Gist options
  • Select an option

  • Save greggman/cdb8f6409c036f4774bc98a52047272d to your computer and use it in GitHub Desktop.

Select an option

Save greggman/cdb8f6409c036f4774bc98a52047272d to your computer and use it in GitHub Desktop.
WebGPU: Buffer Aliasing?
/*bug-in-github-api-content-can-not-be-empty*/
/*bug-in-github-api-content-can-not-be-empty*/
const code = `
@group(0) @binding(0) var<storage> positions: array<f32>;
@group(0) @binding(1) var<storage> normals: array<f32>;
@group(0) @binding(2) var<storage> joints: array<u32>;
@group(0) @binding(3) var<storage> weights: array<f32>;
@compute @workgroup_size(1) fn cs() {
_ = &positions;
_ = &normals;
_ = &joints;
_ = &weights;
}
`
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
device.addEventListener('uncapturederror', e => console.error(e.error.message));
const module = device.createShaderModule({ code });
const pipeline = device.createComputePipeline({
layout: 'auto',
compute: { module },
});
const buffer = device.createBuffer({
size: 1024,
usage: GPUBufferUsage.STORAGE,
});
const bindGroup = device.createBindGroup({
layout: pipeline.getBindGroupLayout(0),
entries: [
{ binding: 0, resource: { buffer } },
{ binding: 1, resource: { buffer } },
{ binding: 2, resource: { buffer } },
{ binding: 3, resource: { buffer } },
],
});
device.queue.submit([]);
{"name":"WebGPU: Buffer Aliasing?","settings":{},"filenames":["index.html","index.css","index.js"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment