Open SludgePhD opened 5 months ago
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 {
I think we should validate that all view formats support the usages. I reopened a relevant spec issue.
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?
It seems there isn't. You'd have to use 2 textures and keep copying between them.
Nvm, I think this should work; see https://github.com/gpuweb/gpuweb/issues/4426#issuecomment-1992203395.
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