aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-08-31 10:13:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-31 10:13:08 -0700
commit19ff1035d3334ffa513c93edce04662bb5ead5bd (patch)
treea009226f86bc0b3dd52c210abf072f60d056e399 /src
parent682580fb204b72925a48d1d6fe8c9c30fa53bb67 (diff)
Always add a barrier when old layout was general in vulkan.
When we have a general layout, we need to always add a barrier even if leaving the layout in general since we don't know what the use case for general was with the old layout. This doesn't seem to fix any of our synchronization issues which makes sense since we don't really use a general layout much. The only place it is used is for mipmap generation, but then we add explicit barriers in that function itself and the first use of the image after mipmap generation will change the layout to something other than general, usually SHADER_READ. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2298483002 Review-Url: https://codereview.chromium.org/2298483002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/vk/GrVkImage.cpp9
-rw-r--r--src/gpu/vk/GrVkMemory.cpp8
2 files changed, 11 insertions, 6 deletions
diff --git a/src/gpu/vk/GrVkImage.cpp b/src/gpu/vk/GrVkImage.cpp
index a7fe478c4f..d0457ca28b 100644
--- a/src/gpu/vk/GrVkImage.cpp
+++ b/src/gpu/vk/GrVkImage.cpp
@@ -32,9 +32,12 @@ void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout,
SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED != newLayout &&
VK_IMAGE_LAYOUT_PREINITIALIZED != newLayout);
VkImageLayout currentLayout = this->currentLayout();
- // Is this reasonable? Could someone want to keep the same layout but use the masks to force
- // a barrier on certain things?
- if (newLayout == currentLayout) {
+
+ // If the old and new layout are the same, there is no reason to put in a barrier since the
+ // operations used for each layout are implicitly synchronized with eachother. The one exception
+ // is if the layout is GENERAL. In this case the image could have been used for any operation so
+ // we must respect the barrier.
+ if (newLayout == currentLayout && VK_IMAGE_LAYOUT_GENERAL != currentLayout) {
return;
}
diff --git a/src/gpu/vk/GrVkMemory.cpp b/src/gpu/vk/GrVkMemory.cpp
index 1dac9f3440..48bea9c67e 100644
--- a/src/gpu/vk/GrVkMemory.cpp
+++ b/src/gpu/vk/GrVkMemory.cpp
@@ -223,9 +223,11 @@ VkAccessFlags GrVkMemory::LayoutToSrcAccessMask(const VkImageLayout layout) {
VkAccessFlags flags = 0;;
if (VK_IMAGE_LAYOUT_GENERAL == layout) {
flags = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_TRANSFER_WRITE_BIT |
- VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_HOST_READ_BIT;
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
+ VK_ACCESS_TRANSFER_WRITE_BIT |
+ VK_ACCESS_TRANSFER_READ_BIT |
+ VK_ACCESS_SHADER_READ_BIT |
+ VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_HOST_READ_BIT;
} else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
flags = VK_ACCESS_HOST_WRITE_BIT;
} else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {