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 "GrFixedClip.h" | 10 #include "GrFixedClip.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 *storeOp = VK_ATTACHMENT_STORE_OP_STORE; | 50 *storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 GrVkGpuCommandBuffer::GrVkGpuCommandBuffer(GrVkGpu* gpu, | 54 GrVkGpuCommandBuffer::GrVkGpuCommandBuffer(GrVkGpu* gpu, |
55 GrVkRenderTarget* target, | 55 GrVkRenderTarget* target, |
56 const LoadAndStoreInfo& colorInfo, | 56 const LoadAndStoreInfo& colorInfo, |
57 const LoadAndStoreInfo& stencilInfo) | 57 const LoadAndStoreInfo& stencilInfo) |
58 : fGpu(gpu) | 58 : fGpu(gpu) |
59 , fRenderTarget(target) | 59 , fRenderTarget(target) |
60 , fIsEmpty(true) { | 60 , fIsEmpty(true) |
| 61 , fStartsWithClear(false) { |
61 VkAttachmentLoadOp vkLoadOp; | 62 VkAttachmentLoadOp vkLoadOp; |
62 VkAttachmentStoreOp vkStoreOp; | 63 VkAttachmentStoreOp vkStoreOp; |
63 | 64 |
64 get_vk_load_store_ops(colorInfo, &vkLoadOp, &vkStoreOp); | 65 get_vk_load_store_ops(colorInfo, &vkLoadOp, &vkStoreOp); |
65 GrVkRenderPass::LoadStoreOps vkColorOps(vkLoadOp, vkStoreOp); | 66 GrVkRenderPass::LoadStoreOps vkColorOps(vkLoadOp, vkStoreOp); |
66 | 67 |
67 get_vk_load_store_ops(stencilInfo, &vkLoadOp, &vkStoreOp); | 68 get_vk_load_store_ops(stencilInfo, &vkLoadOp, &vkStoreOp); |
68 GrVkRenderPass::LoadStoreOps vkStencilOps(vkLoadOp, vkStoreOp); | 69 GrVkRenderPass::LoadStoreOps vkStencilOps(vkLoadOp, vkStoreOp); |
69 | 70 |
70 GrVkRenderPass::LoadStoreOps vkResolveOps(VK_ATTACHMENT_LOAD_OP_LOAD, | 71 GrVkRenderPass::LoadStoreOps vkResolveOps(VK_ATTACHMENT_LOAD_OP_LOAD, |
(...skipping 23 matching lines...) Expand all Loading... |
94 fRenderPass->unref(fGpu); | 95 fRenderPass->unref(fGpu); |
95 } | 96 } |
96 | 97 |
97 GrGpu* GrVkGpuCommandBuffer::gpu() { return fGpu; } | 98 GrGpu* GrVkGpuCommandBuffer::gpu() { return fGpu; } |
98 | 99 |
99 void GrVkGpuCommandBuffer::end() { | 100 void GrVkGpuCommandBuffer::end() { |
100 fCommandBuffer->end(fGpu); | 101 fCommandBuffer->end(fGpu); |
101 } | 102 } |
102 | 103 |
103 void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) { | 104 void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) { |
| 105 if (fIsEmpty && !fStartsWithClear) { |
| 106 // We have sumbitted no actual draw commands to the command buffer and w
e are not using |
| 107 // the render pass to do a clear so there is no need to submit anything. |
| 108 return; |
| 109 } |
| 110 |
104 // Change layout of our render target so it can be used as the color attachm
ent. Currently | 111 // Change layout of our render target so it can be used as the color attachm
ent. Currently |
105 // we don't attach the resolve to the framebuffer so no need to change its l
ayout. | 112 // we don't attach the resolve to the framebuffer so no need to change its l
ayout. |
106 GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaIma
ge() | 113 GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaIma
ge() |
107 : fRenderTarget; | 114 : fRenderTarget; |
108 targetImage->setImageLayout(fGpu, | 115 targetImage->setImageLayout(fGpu, |
109 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | 116 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
110 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | 117 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
111 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, | 118 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, |
112 false); | 119 false); |
113 | 120 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 vkStencilOps); | 155 vkStencilOps); |
149 } else { | 156 } else { |
150 fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT, | 157 fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT, |
151 vkColorOps, | 158 vkColorOps, |
152 vkResolveOps, | 159 vkResolveOps, |
153 vkStencilOps); | 160 vkStencilOps); |
154 } | 161 } |
155 | 162 |
156 SkASSERT(fRenderPass->isCompatible(*oldRP)); | 163 SkASSERT(fRenderPass->isCompatible(*oldRP)); |
157 oldRP->unref(fGpu); | 164 oldRP->unref(fGpu); |
| 165 fStartsWithClear = false; |
158 } | 166 } |
159 } | 167 } |
160 | 168 |
161 void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTarget* target, | 169 void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTarget* target, |
162 const GrFixedClip& clip, | 170 const GrFixedClip& clip, |
163 bool insideStencilMask) { | 171 bool insideStencilMask) { |
164 SkASSERT(target); | 172 SkASSERT(target); |
165 SkASSERT(!clip.hasWindowRectangles()); | 173 SkASSERT(!clip.hasWindowRectangles()); |
166 | 174 |
167 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(target); | 175 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(target); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT, | 253 fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT, |
246 vkColorOps, | 254 vkColorOps, |
247 vkResolveOps, | 255 vkResolveOps, |
248 vkStencilOps); | 256 vkStencilOps); |
249 } | 257 } |
250 | 258 |
251 SkASSERT(fRenderPass->isCompatible(*oldRP)); | 259 SkASSERT(fRenderPass->isCompatible(*oldRP)); |
252 oldRP->unref(fGpu); | 260 oldRP->unref(fGpu); |
253 | 261 |
254 GrColorToRGBAFloat(color, fColorClearValue.color.float32); | 262 GrColorToRGBAFloat(color, fColorClearValue.color.float32); |
| 263 fStartsWithClear = true; |
255 return; | 264 return; |
256 } | 265 } |
257 | 266 |
258 // We always do a sub rect clear with clearAttachments since we are inside a
render pass | 267 // We always do a sub rect clear with clearAttachments since we are inside a
render pass |
259 VkClearRect clearRect; | 268 VkClearRect clearRect; |
260 // Flip rect if necessary | 269 // Flip rect if necessary |
261 SkIRect vkRect; | 270 SkIRect vkRect; |
262 if (!clip.scissorEnabled()) { | 271 if (!clip.scissorEnabled()) { |
263 vkRect.setXYWH(0, 0, vkRT->width(), vkRT->height()); | 272 vkRect.setXYWH(0, 0, vkRT->width(), vkRT->height()); |
264 } else if (kBottomLeft_GrSurfaceOrigin != vkRT->origin()) { | 273 } else if (kBottomLeft_GrSurfaceOrigin != vkRT->origin()) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 fGpu->stats()->incNumDraws(); | 445 fGpu->stats()->incNumDraws(); |
437 } while ((nonIdxMesh = iter.next())); | 446 } while ((nonIdxMesh = iter.next())); |
438 } | 447 } |
439 | 448 |
440 // Technically we don't have to call this here (since there is a safety chec
k in | 449 // Technically we don't have to call this here (since there is a safety chec
k in |
441 // pipelineState:setData but this will allow for quicker freeing of resource
s if the | 450 // pipelineState:setData but this will allow for quicker freeing of resource
s if the |
442 // pipelineState sits in a cache for a while. | 451 // pipelineState sits in a cache for a while. |
443 pipelineState->freeTempResources(fGpu); | 452 pipelineState->freeTempResources(fGpu); |
444 } | 453 } |
445 | 454 |
OLD | NEW |