Skip creating the VkImageView if the texture usage is only Copy
Bug: dawn:399 Change-Id: Iedd097dc96b248499fefd0c259b13fb55fc39f0d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22380 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
47a3341e07
commit
5b3cdc66fd
|
@ -946,6 +946,14 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
MaybeError TextureView::Initialize(const TextureViewDescriptor* descriptor) {
|
||||
if ((GetTexture()->GetUsage() &
|
||||
~(wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst)) == 0) {
|
||||
// If the texture view has no other usage than CopySrc and CopyDst, then it can't
|
||||
// actually be used as a render pass attachment or sampled/storage texture. The Vulkan
|
||||
// validation errors warn if you create such a vkImageView, so return early.
|
||||
return {};
|
||||
}
|
||||
|
||||
Device* device = ToBackend(GetTexture()->GetDevice());
|
||||
|
||||
VkImageViewCreateInfo createInfo;
|
||||
|
|
|
@ -614,3 +614,23 @@ TEST_P(TextureViewRenderingTest, Texture2DArrayViewOnALayerOf2DArrayTextureAsCol
|
|||
DAWN_INSTANTIATE_TEST(TextureViewSamplingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
||||
|
||||
DAWN_INSTANTIATE_TEST(TextureViewRenderingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
||||
|
||||
class TextureViewTest : public DawnTest {};
|
||||
|
||||
// This is a regression test for crbug.com/dawn/399 where creating a texture view with only copy
|
||||
// usage would cause the Vulkan validation layers to warn
|
||||
TEST_P(TextureViewTest, OnlyCopySrcDst) {
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.size = {4, 4, 1};
|
||||
descriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst;
|
||||
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
|
||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||
wgpu::TextureView view = texture.CreateView();
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(TextureViewTest,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
OpenGLBackend(),
|
||||
VulkanBackend());
|
||||
|
|
Loading…
Reference in New Issue