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>
diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp
index 52d03bc..fc608a1 100644
--- a/src/dawn/native/vulkan/TextureVk.cpp
+++ b/src/dawn/native/vulkan/TextureVk.cpp
@@ -924,9 +924,12 @@
             bool isInitialized = IsSubresourceContentInitialized(GetAllSubresources());
 
             // 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
-            // the texture is uninitialized. We can skip the layout transition.
-            if (!isInitialized) {
+            // driver is free to discard it. Also it is invalid to transition to layout UNDEFINED or
+            // PREINITIALIZED. If the embedder provided no new layout, or we don't care about the
+            // 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->newLayout = desiredLayout;
             } else {