-
Notifications
You must be signed in to change notification settings - Fork 345
Description
This is a follow up to Support GPUBuffer in GPUBindingResource
We made it easier to use buffers in a bindGroup, what about textures?
const bg = device.createBindGroup({
layout,
entries: [
{ binding: 0, resource: someTexture }, // currently requires someTexture.createView()
},
});It would effectively just call createView with no parameters for you.
I've run into this issue multiple times where I forget to call createView() and the error is not that helpful.
Testing, the error I get for this is
- chrome:
Failed to execute 'createBindGroup' on 'GPUDevice': Failed to read the 'entries' property from 'GPUBindGroupDescriptor': Failed to read the 'resource' property from 'GPUBindGroupEntry': Failed to read the 'buffer' property from 'GPUBufferBinding': Required member is undefined. - firefox:
GPUDevice.createBindGroup: Missing required 'buffer' member of GPUBufferBinding. - safari:
Member GPUBufferBinding.buffer is required and must be an instance of GPUBuffer
Nothing about textures. Since it says "buffer" I end up looking for issues related to buffers and get sidetracked. Yes, we could try to fix the error message but we could instead just make it not an error.
Arguably this could/would/should? also apply to:
GPURenderPassColorAttachment.viewGPURenderPassColorAttachment.resolveTargetGPURenderPassDepthStencilAttachment.view
It's unfortunate those are called view and not target. They have the advantage over bind group entries that they are a specific type and so easy to make the correct message for when used wrong. Still, it would be nice to be able to use the texture directly when you don't need custom view options.
wdty?