2

I'm trying to write a ray tracer with webgpu based on the cornell box sample. I've tested for the bgra8unorm-storage feature and I have it but am still encountering errors trying to store to the current texture. I can run the cornell box example. Wondering if anyone else has run into something similar. Perhaps it doesn't work when not in an origin-trial or something else?

The texture usage (TextureUsage::(StorageBinding|RenderAttachment)) includes TextureUsage::StorageBinding, which is incompatible with the format (TextureFormat::BGRA8Unorm).
    at ValidateTextureUsage (..\..\third_party\dawn\src\dawn\native\Texture.cpp:318)
    at ValidateTextureDescriptor (..\..\third_party\dawn\src\dawn\native\Texture.cpp:358)

Texture format (TextureFormat::BGRA8Unorm) does not support storage textures.
 - While validating entries[1]
 - While validating [BindGroupLayoutDescriptor "TonemapperPipeline.bindGroupLayout"]
 - While calling [Device].CreateBindGroupLayout([BindGroupLayoutDescriptor "TonemapperPipeline.bindGroupLayout"]).

[Invalid Texture] is invalid.
 - While calling [Invalid Texture].CreateView([TextureViewDescriptor]).

[Invalid BindGroupLayout "TonemapperPipeline.bindGroupLayout"] is invalid.
 - While validating [BindGroupDescriptor "TonemapperPipeline.bindGroup"] against [Invalid BindGroupLayout "TonemapperPipeline.bindGroupLayout"]
 - While calling [Device].CreateBindGroup([BindGroupDescriptor "TonemapperPipeline.bindGroup"]).

BGRA8Unorm storage textures are not supported if optional feature bgra8unorm-storage is not supported.
 - While processing entry point "main".
 - While calling [Device].CreateShaderModule([ShaderModuleDescriptor]).

[Invalid BindGroupLayout "TonemapperPipeline.bindGroupLayout"] is invalid.
 - While calling [Device].CreatePipelineLayout([PipelineLayoutDescriptor "TonemapperPipeline.pipelineLayout"]).

[Invalid PipelineLayout] is invalid.
 - While calling [Device].CreateComputePipeline([ComputePipelineDescriptor "TonemapperPipeline.pipeline"]).

[Invalid BindGroup "TonemapperPipeline.bindGroup"] is invalid.
 - While encoding [ComputePassEncoder].SetBindGroup(0, [Invalid BindGroup "TonemapperPipeline.bindGroup"], 0, ...).
Axiverse
  • 1,589
  • 3
  • 14
  • 30

1 Answers1

2

Did some more digging and finally found the answer after much frustration:

It's not enough to only have the "bgra8unorm-storage" feature, you must explicitly pass it in as a requiredFeature when creating a device.

await adapter.requestDevice({ requiredFeatures: ['bgra8unorm-storage'] });

Axiverse
  • 1,589
  • 3
  • 14
  • 30