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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // We don't recycle resources when abandoning them. | 59 // We don't recycle resources when abandoning them. |
60 fTrackedRecycledResources[i]->unrefAndAbandon(); | 60 fTrackedRecycledResources[i]->unrefAndAbandon(); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 void GrVkCommandBuffer::reset(GrVkGpu* gpu) { | 64 void GrVkCommandBuffer::reset(GrVkGpu* gpu) { |
65 SkASSERT(!fIsActive); | 65 SkASSERT(!fIsActive); |
66 for (int i = 0; i < fTrackedResources.count(); ++i) { | 66 for (int i = 0; i < fTrackedResources.count(); ++i) { |
67 fTrackedResources[i]->unref(gpu); | 67 fTrackedResources[i]->unref(gpu); |
68 } | 68 } |
69 fTrackedResources.reset(); | |
70 | |
71 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { | 69 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { |
72 fTrackedRecycledResources[i]->recycle(const_cast<GrVkGpu*>(gpu)); | 70 fTrackedRecycledResources[i]->recycle(const_cast<GrVkGpu*>(gpu)); |
73 } | 71 } |
74 fTrackedRecycledResources.reset(); | 72 |
| 73 if (++fNumResets > kNumRewindResetsBeforeFullReset) { |
| 74 fTrackedResources.reset(); |
| 75 fTrackedRecycledResources.reset(); |
| 76 fTrackedResources.setReserve(kInitialTrackedResourcesCount); |
| 77 fTrackedRecycledResources.setReserve(kInitialTrackedResourcesCount); |
| 78 fNumResets = 0; |
| 79 } else { |
| 80 fTrackedResources.rewind(); |
| 81 fTrackedRecycledResources.rewind(); |
| 82 } |
| 83 |
75 | 84 |
76 this->invalidateState(); | 85 this->invalidateState(); |
77 | 86 |
78 // we will retain resources for later use | 87 // we will retain resources for later use |
79 VkCommandBufferResetFlags flags = 0; | 88 VkCommandBufferResetFlags flags = 0; |
80 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); | 89 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); |
81 | 90 |
82 this->onReset(gpu); | 91 this->onReset(gpu); |
83 } | 92 } |
84 | 93 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 fIsActive = true; | 660 fIsActive = true; |
652 } | 661 } |
653 | 662 |
654 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { | 663 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { |
655 SkASSERT(fIsActive); | 664 SkASSERT(fIsActive); |
656 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); | 665 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); |
657 this->invalidateState(); | 666 this->invalidateState(); |
658 fIsActive = false; | 667 fIsActive = false; |
659 } | 668 } |
660 | 669 |
OLD | NEW |