Last active
January 8, 2026 18:21
-
-
Save greggman/e2395d304fce578e2c1026bfb46fa8fe to your computer and use it in GitHub Desktop.
WebGPU: primitive-index test
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 adapter = await navigator.gpu.requestAdapter(); | |
| const device = await adapter.requestDevice({ | |
| requiredFeatures: ['primitive-index'], | |
| }); | |
| if (!device) { | |
| fail('no device'); | |
| } | |
| console.log('features:', [...device.features].join(', ')); | |
| device.addEventListener('uncapturederror', e => console.error(e.error.message)); | |
| device.createShaderModule({ | |
| code: ` | |
| requires primitive_index; | |
| struct VSOut { | |
| @builtin(position) p: vec4f, | |
| } | |
| struct FSIn { | |
| @builtin(primitive_index) i_0: u32, | |
| } | |
| struct FSOut { | |
| @location(0) color: vec4f, | |
| } | |
| @vertex fn vs() -> VSOut { | |
| var o: VSOut; | |
| o.p = vec4f(0); | |
| return o; | |
| } | |
| @fragment fn fs(i: FSIn) -> FSOut { | |
| var o: FSOut; | |
| o.color = vec4f(0); | |
| return o; | |
| } | |
| `, | |
| }) | |
| 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: primitive-index test","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