From 87ab2f96d93bcf28ce97fa27a0c90f870ec040db Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Thu, 13 Jun 2019 00:07:42 +0000 Subject: [PATCH] Vulkan: always specify TRANSFER_DST_BIT usage when creating images This patch adds VK_IMAGE_USAGE_TRANSFER_DST_BIT usage when creating Vulkan images because when we do resource initialization with vkCmdClearColorImage() and vkCmdClearDepthStencilImage(), the image must have been created with VK_IMAGE_USAGE_TRANSFER_DST_BIT usage flag according to Vulkan SPEC. BUG=dawn:171 TEST=dawn_end2end_tests Change-Id: Iaba6c04c6942354cc6be502eeee04457d3f43ba7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8100 Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Jiawei Shao --- src/dawn_native/vulkan/TextureVk.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index 8fdc63d7ee..e73ecb6034 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -301,6 +301,11 @@ namespace dawn_native { namespace vulkan { createInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; } + // We always set VK_IMAGE_USAGE_TRANSFER_DST_BIT unconditionally beause the Vulkan images + // that are used in vkCmdClearColorImage() must have been created with this flag, which is + // also required for the implementation of robust resource initialization. + createInfo.usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if (device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &mHandle) != VK_SUCCESS) { ASSERT(false);