vk: Only support bgra8unorm_storage if STORAGE_READ_WITHOUT_FORMAT is supported#4655
vk: Only support bgra8unorm_storage if STORAGE_READ_WITHOUT_FORMAT is supported#4655sethdusek wants to merge 1 commit intogfx-rs:trunkfrom
Conversation
Wumpf
left a comment
There was a problem hiding this comment.
However I do not understand why wgpu requires both WRITE_WITHOUT_FORMAT and READ_WITHOUT_FORMAT in the first place.
The feature flag enabled here corresponds to https://www.w3.org/TR/webgpu/#bgra8unorm-storage which requires both read & write storage access. So I think you fix here makes perfectly sense.
If we want to break this down, we'd have to add a wgpu-native only feature for this.
I've tried specifying the format of the texture when creating the TextureView that gets passed to the compute shader but to no avail, as I get the same validation errors (and an empty screen since nothing is being read). It seems wgpu is ignoring these view formats somehow and thus requires both of these WITHOUT_FORMAT extensions?
The only "conversion" a texture view can do right now is adding/removing srgb flag https://www.w3.org/TR/webgpu/#dom-gputexturedescriptor-viewformats
I'm not 100% sure on this part, but texture views aren't really relevant for storage textures at all, only about non-storage texture access, i.e. when you access via texture_2d instead of texture_storage_2d
(worth noting that texture_2d should always be supported for bgra8)
|
Can you add a changelog line? That's still a bugfix worth calling out :) |
|
Can we hold off for a bit on merging this?
The PR that added But the situation of I'll look some more into what would be best here and open a spec issue. |
|
thanks for the context @teoxoy, had no idea ofc 😄 |
|
Based on the data from https://vulkan.gpuinfo.org/ it seems that requiring Which contradicts what @sethdusek experienced (Intel HD Graphics 520 supporting Not sure what to make of this. |
We only require For more background on this see: KhronosGroup/Vulkan-Docs#2027 (comment). |
From what I can tell reading ANV source code (Intel driver from Mesa), it only enables support for READ_WITHOUT_FORMAT if The table says that versions of Intel GPUs > 125 support "typed reads" for B8R8G8A8_UNORM but versions of Intel GPUs > 70 support typed writes (I'm not sure what exactly these version numbers correspond to among generations of Intel GPUs), but this indicates there are certain GPUs that can write to a B8G8R8A8_Unorm image but can't read from them. Which would explain why I don't get validation errors binding the image as write-only but only get it when binding it read-only. Relevant files in mesa: Output of |
|
That makes sense, thanks for looking into it and sharing those resources! The The remaining mystery is why does the vulkaninfo DB only contain reports where either both or none of those capabilities show up. |
|
Could you share the output of |
|
It turns out that the reports at https://vulkan.gpuinfo.org/ don't contain I got tripped up by SaschaWillems/vulkan.gpuinfo.org#50 (comment). Because bit 31 ( That's why we were seeing either both or none of them set. That was quite the rabbit hole. |
|
Given the current requirements for
I think the I'll open an issue on the spec to see what the others think. We also need to add some more validation for this. |
cwfitzgerald
left a comment
There was a problem hiding this comment.
Requesting changes per above comments.
Please re-request a review from teo once the changes are addressed to make sure they see it!
|
I filed #4704 to track the new changes to the spec (which should cover the validation I was mentioning before). |
Checklist
cargo clippy.cargo clippy --target wasm32-unknown-unknownif applicable.Connections
Link to the issues addressed by this PR, or dependent PRs in other repositories
Description
On Intel 6th generation GPUs, a simple compute shader that reads from a bgra8unorm texture and writes to a bgra8unorm texture does not work. Upon further inspection, writes to the texture were working but reading wasn't. After running it through renderdoc with validation layers I get the following error: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDispatch-OpTypeImage-07028
It seems my Intel GPU supports VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT but does not support VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT.
This PR only enables BGRA8UNORM_STORAGE if both of these are present.
However I do not understand why wgpu requires both WRITE_WITHOUT_FORMAT and READ_WITHOUT_FORMAT in the first place. I've tried specifying the format of the texture when creating the TextureView that gets passed to the compute shader but to no avail, as I get the same validation errors (and an empty screen since nothing is being read). It seems wgpu is ignoring these view formats somehow and thus requires both of these WITHOUT_FORMAT extensions?
Testing
I've tested this patch on an Intel HD Graphics 520. Now it does not support BGRA8UNORM_STORAGE, as it should, instead of spitting out validation errors later. It works as expected on any normal GPU that supports both these features.