Created
June 6, 2025 22:07
-
-
Save greggman/98e2766376048f434757e87a8d0ddb32 to your computer and use it in GitHub Desktop.
WebGPU: Show error using createBindGroup when you forget to call createView on a texture binding
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
:root { color-scheme: light dark; } |
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(); | |
const layout = device.createBindGroupLayout({ | |
entries: [ | |
{ | |
binding: 0, | |
visibility: GPUShaderStage.FRAGMENT, | |
texture: {}, | |
}, | |
], | |
}); | |
const texture = device.createTexture({ | |
format: 'rgba8unorm', | |
usage: GPUTextureUsage.TEXTURE_BINDING, | |
size: [1, 1], | |
}); | |
try { | |
const bg = device.createBindGroup({ | |
layout, | |
entries: [ | |
{ binding: 0, resource: texture }, // error, should be texture.createView() | |
], | |
}); | |
} catch (ex) { | |
log(ex.message); | |
} | |
function log(...args) { | |
const elem = document.createElement('code') | |
elem.textContent = args.join(' '); | |
document.body.append(elem); | |
} |
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: Show error using createBindGroup when you forget to call createView on a texture binding","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