From 429c2f93f4d1ef234debcb81d1b5cc06233a909a Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Tue, 17 Jan 2023 23:40:41 +0000 Subject: [PATCH] Fix vulkan::Buffer::TransitionUsageAndGetResourceBarrier() Do not transition if the buffer usage is already MapWrite Change-Id: I16cf68501e19a5b60d6c6f28eaa539df691f14fd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117240 Reviewed-by: Austin Eng Auto-Submit: Peng Huang Kokoro: Kokoro Commit-Queue: Peng Huang --- src/dawn/native/vulkan/BufferVk.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dawn/native/vulkan/BufferVk.cpp b/src/dawn/native/vulkan/BufferVk.cpp index 5bec8da4ac..8e0811cc26 100644 --- a/src/dawn/native/vulkan/BufferVk.cpp +++ b/src/dawn/native/vulkan/BufferVk.cpp @@ -262,10 +262,11 @@ bool Buffer::TransitionUsageAndGetResourceBarrier(wgpu::BufferUsage usage, VkPipelineStageFlags* srcStages, VkPipelineStageFlags* dstStages) { bool lastIncludesTarget = IsSubset(usage, mLastUsage); - bool lastReadOnly = IsSubset(mLastUsage, kReadOnlyBufferUsages); + constexpr wgpu::BufferUsage kReuseNoBarrierBufferUsages = + kReadOnlyBufferUsages | wgpu::BufferUsage::MapWrite; + bool lastCanBeReusedWithoutBarrier = IsSubset(mLastUsage, kReuseNoBarrierBufferUsages); - // We can skip transitions to already current read-only usages. - if (lastIncludesTarget && lastReadOnly) { + if (lastIncludesTarget && lastCanBeReusedWithoutBarrier) { return false; }