| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrVkGpuCommandBuffer.h" | 8 #include "GrVkGpuCommandBuffer.h" |
| 9 | 9 |
| 10 #include "GrMesh.h" | 10 #include "GrMesh.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 fRenderPass->unref(fGpu); | 93 fRenderPass->unref(fGpu); |
| 94 } | 94 } |
| 95 | 95 |
| 96 GrGpu* GrVkGpuCommandBuffer::gpu() { return fGpu; } | 96 GrGpu* GrVkGpuCommandBuffer::gpu() { return fGpu; } |
| 97 | 97 |
| 98 void GrVkGpuCommandBuffer::end() { | 98 void GrVkGpuCommandBuffer::end() { |
| 99 fCommandBuffer->end(fGpu); | 99 fCommandBuffer->end(fGpu); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) { | 102 void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) { |
| 103 // Change layout of our render target so it can be used as the color attachm
ent | 103 // Change layout of our render target so it can be used as the color attachm
ent. Currently |
| 104 fRenderTarget->setImageLayout(fGpu, | 104 // we don't attach the resolve to the framebuffer so no need to change its l
ayout. |
| 105 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | 105 GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaIma
ge() |
| 106 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | 106 : fRenderTarget; |
| 107 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, | 107 targetImage->setImageLayout(fGpu, |
| 108 false); | 108 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 109 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 110 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, |
| 111 false); |
| 109 | 112 |
| 110 // If we are using a stencil attachment we also need to update its layout | 113 // If we are using a stencil attachment we also need to update its layout |
| 111 if (GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getSten
cilAttachment()) { | 114 if (GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getSten
cilAttachment()) { |
| 112 GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil; | 115 GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil; |
| 113 vkStencil->setImageLayout(fGpu, | 116 vkStencil->setImageLayout(fGpu, |
| 114 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIM
AL, | 117 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIM
AL, |
| 115 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | | 118 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | |
| 116 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, | 119 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, |
| 117 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, | 120 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, |
| 118 false); | 121 false); |
| 119 } | 122 } |
| 120 | 123 |
| 121 if (GrVkImage* msaaImage = fRenderTarget->msaaImage()) { | |
| 122 msaaImage->setImageLayout(fGpu, | |
| 123 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | |
| 124 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | |
| 125 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, | |
| 126 false); | |
| 127 } | |
| 128 | |
| 129 for (int i = 0; i < fSampledImages.count(); ++i) { | 124 for (int i = 0; i < fSampledImages.count(); ++i) { |
| 130 fSampledImages[i]->setImageLayout(fGpu, | 125 fSampledImages[i]->setImageLayout(fGpu, |
| 131 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIM
AL, | 126 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIM
AL, |
| 132 VK_ACCESS_SHADER_READ_BIT, | 127 VK_ACCESS_SHADER_READ_BIT, |
| 133 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, | 128 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, |
| 134 false); | 129 false); |
| 135 } | 130 } |
| 136 | 131 |
| 137 fGpu->submitSecondaryCommandBuffer(fCommandBuffer, fRenderPass, &fColorClear
Value, | 132 fGpu->submitSecondaryCommandBuffer(fCommandBuffer, fRenderPass, &fColorClear
Value, |
| 138 fRenderTarget, bounds); | 133 fRenderTarget, bounds); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 fGpu->stats()->incNumDraws(); | 432 fGpu->stats()->incNumDraws(); |
| 438 } while ((nonIdxMesh = iter.next())); | 433 } while ((nonIdxMesh = iter.next())); |
| 439 } | 434 } |
| 440 | 435 |
| 441 // Technically we don't have to call this here (since there is a safety chec
k in | 436 // Technically we don't have to call this here (since there is a safety chec
k in |
| 442 // pipelineState:setData but this will allow for quicker freeing of resource
s if the | 437 // pipelineState:setData but this will allow for quicker freeing of resource
s if the |
| 443 // pipelineState sits in a cache for a while. | 438 // pipelineState sits in a cache for a while. |
| 444 pipelineState->freeTempResources(fGpu); | 439 pipelineState->freeTempResources(fGpu); |
| 445 } | 440 } |
| 446 | 441 |
| OLD | NEW |