GPUTexture.createView ignores usage
Categories
(Core :: Graphics: WebGPU, defect)
Tracking
()
People
(Reporter: catscratchesp, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Steps to reproduce:
When creating a texture view, GPUTextureViewDescriptor has a usage property, specifying the usage of the texture view (which can be a subset of the GPUTexture's usage). However, Firefox ignores this usage, and instead hardcodes the usage to None (meaning it is instead inherited from the GPUTexture's usage).
While in many cases, simply inheriting the texture's usage will work, there are cases where it doesn't For instance, the following:
const canvas = document.querySelector('canvas');
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const context = canvas.getContext('webgpu');
const texture_Output = device.createTexture({
label: "texture DemofoxMinesweeper.Output",
size: [512, 512, 1],
format: "rgba8unorm",
usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING,
viewFormats: [ "rgba8unorm-srgb" ],
});
const textureView = texture_Output.createView({ dimension: "2d", format: "rgba8unorm-srgb", usage: GPUTextureUsage.TEXTURE_BINDING });
rgba8unorm supports STORAGE_BINDING usage, but rgba8unorm-srgb does not. Since we are creating an sRGB view, the usage musn't include STORAGE_BINDING. The user-supplied usage doesn't, but this is ignored and instead the usage is inherited from the texture, which doesn't work.
This breaks the following gigi sample: https://electronicarts.github.io/gigi/Demos/Minesweeper/index.html
Actual results:
The texture view creation fails, with an error message:
Texture view format `Rgba8UnormSrgb` cannot be used as a storage binding. Make sure the format supports STORAGE usage and required device features are enabled.
Expected results:
The texture view should have been created successfully.
Description
•