Created
February 6, 2026 01:07
-
-
Save greggman/cdb8f6409c036f4774bc98a52047272d to your computer and use it in GitHub Desktop.
WebGPU: Buffer Aliasing?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*bug-in-github-api-content-can-not-be-empty*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*bug-in-github-api-content-can-not-be-empty*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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([]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"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