OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrVkCommandBuffer.h" | 8 #include "GrVkCommandBuffer.h" |
9 | 9 |
10 #include "GrVkFramebuffer.h" | 10 #include "GrVkFramebuffer.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 fCachedBlendConstant[i] = -1.0; | 33 fCachedBlendConstant[i] = -1.0; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 void GrVkCommandBuffer::freeGPUData(const GrVkGpu* gpu) const { | 37 void GrVkCommandBuffer::freeGPUData(const GrVkGpu* gpu) const { |
38 SkASSERT(!fIsActive); | 38 SkASSERT(!fIsActive); |
39 for (int i = 0; i < fTrackedResources.count(); ++i) { | 39 for (int i = 0; i < fTrackedResources.count(); ++i) { |
40 fTrackedResources[i]->unref(gpu); | 40 fTrackedResources[i]->unref(gpu); |
41 } | 41 } |
42 | 42 |
43 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { | |
44 fTrackedRecycledResources[i]->recycle(const_cast<GrVkGpu*>(gpu)); | |
45 fTrackedRecycledResources[i]->unref(gpu); | |
46 } | |
47 | |
43 GR_VK_CALL(gpu->vkInterface(), FreeCommandBuffers(gpu->device(), gpu->cmdPoo l(), | 48 GR_VK_CALL(gpu->vkInterface(), FreeCommandBuffers(gpu->device(), gpu->cmdPoo l(), |
44 1, &fCmdBuffer)); | 49 1, &fCmdBuffer)); |
45 | 50 |
46 this->onFreeGPUData(gpu); | 51 this->onFreeGPUData(gpu); |
47 } | 52 } |
48 | 53 |
49 void GrVkCommandBuffer::abandonSubResources() const { | 54 void GrVkCommandBuffer::abandonSubResources() const { |
50 for (int i = 0; i < fTrackedResources.count(); ++i) { | 55 for (int i = 0; i < fTrackedResources.count(); ++i) { |
51 fTrackedResources[i]->unrefAndAbandon(); | 56 fTrackedResources[i]->unrefAndAbandon(); |
52 } | 57 } |
58 | |
59 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { | |
60 // We don't recycle resources when abadoning them. | |
jvanverth1
2016/07/20 14:08:47
sp: abandon
egdaniel
2016/07/20 14:48:39
Done.
| |
61 fTrackedRecycledResources[i]->unrefAndAbandon(); | |
62 } | |
53 } | 63 } |
54 | 64 |
55 void GrVkCommandBuffer::reset(GrVkGpu* gpu) { | 65 void GrVkCommandBuffer::reset(GrVkGpu* gpu) { |
56 SkASSERT(!fIsActive); | 66 SkASSERT(!fIsActive); |
57 for (int i = 0; i < fTrackedResources.count(); ++i) { | 67 for (int i = 0; i < fTrackedResources.count(); ++i) { |
58 fTrackedResources[i]->unref(gpu); | 68 fTrackedResources[i]->unref(gpu); |
59 } | 69 } |
60 fTrackedResources.reset(); | 70 fTrackedResources.reset(); |
61 | 71 |
72 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { | |
73 fTrackedRecycledResources[i]->recycle(const_cast<GrVkGpu*>(gpu)); | |
74 fTrackedRecycledResources[i]->unref(gpu); | |
75 } | |
76 fTrackedRecycledResources.reset(); | |
77 | |
78 | |
62 this->invalidateState(); | 79 this->invalidateState(); |
63 | 80 |
64 // we will retain resources for later use | 81 // we will retain resources for later use |
65 VkCommandBufferResetFlags flags = 0; | 82 VkCommandBufferResetFlags flags = 0; |
66 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); | 83 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); |
67 | 84 |
68 this->onReset(gpu); | 85 this->onReset(gpu); |
69 } | 86 } |
70 | 87 |
71 //////////////////////////////////////////////////////////////////////////////// | 88 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
617 fIsActive = true; | 634 fIsActive = true; |
618 } | 635 } |
619 | 636 |
620 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { | 637 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { |
621 SkASSERT(fIsActive); | 638 SkASSERT(fIsActive); |
622 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); | 639 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); |
623 this->invalidateState(); | 640 this->invalidateState(); |
624 fIsActive = false; | 641 fIsActive = false; |
625 } | 642 } |
626 | 643 |
OLD | NEW |