这是indexloc提供的服务,不要输入任何密码
Skip to content

Feature Request: Let you pass a GPUTexture everywhere a GPUTextureView is currently used #5215

@greggman

Description

@greggman

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

live

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.view
  • GPURenderPassColorAttachment.resolveTarget
  • GPURenderPassDepthStencilAttachment.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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiWebGPU APIfeature requestA request for a new GPU feature exposed in the API

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions