Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Validation errors when creating sRGB view of storage texture #5379

Open
SludgePhD opened this issue Mar 11, 2024 · 5 comments
Open

Vulkan Validation errors when creating sRGB view of storage texture #5379

SludgePhD opened this issue Mar 11, 2024 · 5 comments
Labels
area: validation Issues related to validation, diagnostics, and error handling

Comments

@SludgePhD
Copy link
Contributor

Description

[2024-03-11T19:11:33Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-VkImageViewCreateInfo-usage-02275 (0x618ab1e7)] Validation Error: [ VUID-VkImageViewCreateInfo-usage-02275 ] Object 0: handle = 0x92c9c400000001ea, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x618ab1e7 | vkCreateImageView(): pCreateInfo->format VK_FORMAT_R8G8B8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL only supports VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT|VK_FORMAT_FEATURE_2_BLIT_SRC_BIT|VK_FORMAT_FEATURE_2_BLIT_DST_BIT|VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT|VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT|VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT. The Vulkan spec states: If usage contains VK_IMAGE_USAGE_STORAGE_BIT, then the image view's format features must contain VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-usage-02275) [2024-03-11T19:11:33Z ERROR wgpu_hal::vulkan::instance] objects: (type: IMAGE, hndl: 0x92c9c400000001ea, name: ?)

Repro steps
I haven't yet figured out which exact code pattern causes this, but the validation diagnostic above might provide a hint.

Expected vs observed behavior
This should fail during wgpu validation, or it should work without causing Vulkan validation errors, I suppose.

Platform
Linux radv, wgpu 0.19.3

@SludgePhD
Copy link
Contributor Author

This patch to current wgpu trunk reproduces it:

diff --git a/examples/src/storage_texture/mod.rs b/examples/src/storage_texture/mod.rs
index d4e207f3b..3356c181c 100644
--- a/examples/src/storage_texture/mod.rs
+++ b/examples/src/storage_texture/mod.rs
@@ -58,7 +58,11 @@ async fn run(_path: Option<String>) {
         dimension: wgpu::TextureDimension::D2,
         format: wgpu::TextureFormat::Rgba8Unorm,
         usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::COPY_SRC,
-        view_formats: &[],
+        view_formats: &[wgpu::TextureFormat::Rgba8UnormSrgb],
+    });
+    let srgb_texture_view = storage_texture.create_view(&wgpu::TextureViewDescriptor {
+        format: Some(wgpu::TextureFormat::Rgba8UnormSrgb),
+        ..Default::default()
     });
     let storage_texture_view = storage_texture.create_view(&wgpu::TextureViewDescriptor::default());
     let output_staging_buffer = device.create_buffer(&wgpu::BufferDescriptor {

@SludgePhD SludgePhD changed the title Vulkan Validation errors when using sRGB view as storage texture Vulkan Validation errors when creating sRGB view of storage texture Mar 12, 2024
@teoxoy teoxoy added the area: validation Issues related to validation, diagnostics, and error handling label Mar 12, 2024
@teoxoy
Copy link
Member

teoxoy commented Mar 12, 2024

I think we should validate that all view formats support the usages.
I reopened a relevant spec issue.

@SludgePhD
Copy link
Contributor Author

Hmm, then what is the intended way to correctly sample an sRGB texture that is also sometimes used as a storage texture? Is there no way to do that in Vulkan?

@teoxoy

This comment was marked as outdated.

@teoxoy
Copy link
Member

teoxoy commented Mar 12, 2024

Nvm, I think this should work; see gpuweb/gpuweb#4426 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling
Projects
None yet
Development

No branches or pull requests

2 participants