Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove the need to hard-code texel format for texture_storage_2d in shaders #4298

@rokcej

Description

@rokcej

When I'm using texture_storage_2d, I'm forced to hard-code the texel format (e.g. rgba8unorm) in the shader. Here's an example from my compute shader:

@group(0) @binding(8) var uRadiance: texture_storage_2d<rgba8unorm, write>;

Hard-coding rgba8unorm seems super redundant, since vec4<f32> is used when writing to the texture for several different formats. Why can't I just write something like texture_storage_2d<f32, write>, similar to normal texture bindings?

Here's the comment from @mehmetoguzderin on WebGPU's Matrix chat:

The bottleneck here is specific devices in Vulkan, where shaderStorageImageReadWithoutFormat and/or shaderStorageImageWriteWithoutFormat are necessary (that's why you see the more generic pattern in HLSL and Metal instead of GLSL's more specific format setting), even though SPIR-V supports the more generic typing. Although the support seems to be quite widespread in the latest drivers, this still needs consideration within the committee. If I am not missing an open issue in GitHub, this topic is not tracked right now, so maybe you can create an issue (or I can help with creating one).

shaderStorageImageReadWithoutFormat on Android: http://vulkan.gpuinfo.org/listdevicescoverage.php?feature=shaderStorageImageReadWithoutFormat&platform=android

shaderStorageImageWriteWithoutFormat on Android: http://vulkan.gpuinfo.org/listdevicescoverage.php?feature=shaderStorageImageWriteWithoutFormat&platform=android

Metadata

Metadata

Labels

wgslWebGPU Shading Language Issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions