Vulkan: Skip newLayout transition on import if not specified

Fixes vulkan validation layer assertions on Linux in CTS reftests:
 canvas_complex_bgra8unorm_copy.https.html
 canvas_size_different_with_back_buffer_size.https.html

Bug: chromium:1083478
Change-Id: I36580184d15fe36423e5f759eaf959191c6b571c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/82480
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2022-03-02 23:28:17 +00:00 committed by Dawn LUCI CQ
parent 641ec0ae7c
commit cab7419338
1 changed files with 6 additions and 3 deletions

View File

@ -924,9 +924,12 @@ namespace dawn::native::vulkan {
bool isInitialized = IsSubresourceContentInitialized(GetAllSubresources()); bool isInitialized = IsSubresourceContentInitialized(GetAllSubresources());
// We don't care about the pending old layout if the texture is uninitialized. The // We don't care about the pending old layout if the texture is uninitialized. The
// driver is free to discard it. Likewise, we don't care about the pending new layout if // driver is free to discard it. Also it is invalid to transition to layout UNDEFINED or
// the texture is uninitialized. We can skip the layout transition. // PREINITIALIZED. If the embedder provided no new layout, or we don't care about the
if (!isInitialized) { // previous contents, we can skip the layout transition.
// https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageMemoryBarrier-newLayout-01198
if (!isInitialized || mPendingAcquireNewLayout == VK_IMAGE_LAYOUT_UNDEFINED ||
mPendingAcquireNewLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) {
barrier->oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; barrier->oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
barrier->newLayout = desiredLayout; barrier->newLayout = desiredLayout;
} else { } else {