aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-27 10:07:29 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-27 20:26:09 +0000
commit45a44de0a13511650151ad5efbfd03aa8ae5baa3 (patch)
treef2bdba3a0356f4195e72d067a8d5dfb137ae82ec /src
parent90e88aa8594bf04473f993c22d0cd41087262277 (diff)
Make sure we add render target mem barriers after any last second copies
Bug: skia: Change-Id: I67e6e6a026145ecbd7476fbf201ce07e053c337d Reviewed-on: https://skia-review.googlesource.com/110622 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/vk/GrVkGpuCommandBuffer.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index f6ef5a7920..fe9585f9df 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -153,28 +153,8 @@ void GrVkGpuRTCommandBuffer::submit() {
}
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
-
- // Change layout of our render target so it can be used as the color attachment. Currently
- // we don't attach the resolve to the framebuffer so no need to change its layout.
GrVkImage* targetImage = vkRT->msaaImage() ? vkRT->msaaImage() : vkRT;
-
- // Change layout of our render target so it can be used as the color attachment
- targetImage->setImageLayout(fGpu,
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
- VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
- false);
-
- // If we are using a stencil attachment we also need to update its layout
- if (GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getStencilAttachment()) {
- GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil;
- vkStencil->setImageLayout(fGpu,
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
- VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
- false);
- }
+ GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getStencilAttachment();
for (int i = 0; i < fCommandBufferInfos.count(); ++i) {
CommandBufferInfo& cbInfo = fCommandBufferInfos[i];
@@ -190,6 +170,28 @@ void GrVkGpuRTCommandBuffer::submit() {
copyInfo.fSrcRect, copyInfo.fDstPoint);
}
+ // Make sure we do the following layout changes after all copies, uploads, or any other pre
+ // work is done since we may change the layouts in the pre-work. Also since the draws will
+ // be submitted in different render passes, we need to guard againts write and write issues.
+
+ // Change layout of our render target so it can be used as the color attachment.
+ targetImage->setImageLayout(fGpu,
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
+ VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+ false);
+
+ // If we are using a stencil attachment we also need to update its layout
+ if (stencil) {
+ GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil;
+ vkStencil->setImageLayout(fGpu,
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
+ VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+ false);
+ }
+
// TODO: We can't add this optimization yet since many things create a scratch texture which
// adds the discard immediately, but then don't draw to it right away. This causes the
// discard to be ignored and we get yelled at for loading uninitialized data. However, once