Chromium Code Reviews| 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 } | |
| 46 | |
| 43 GR_VK_CALL(gpu->vkInterface(), FreeCommandBuffers(gpu->device(), gpu->cmdPoo l(), | 47 GR_VK_CALL(gpu->vkInterface(), FreeCommandBuffers(gpu->device(), gpu->cmdPoo l(), |
| 44 1, &fCmdBuffer)); | 48 1, &fCmdBuffer)); |
| 45 | 49 |
| 46 this->onFreeGPUData(gpu); | 50 this->onFreeGPUData(gpu); |
| 47 } | 51 } |
| 48 | 52 |
| 49 void GrVkCommandBuffer::abandonSubResources() const { | 53 void GrVkCommandBuffer::abandonSubResources() const { |
| 50 for (int i = 0; i < fTrackedResources.count(); ++i) { | 54 for (int i = 0; i < fTrackedResources.count(); ++i) { |
| 51 fTrackedResources[i]->unrefAndAbandon(); | 55 fTrackedResources[i]->unrefAndAbandon(); |
| 52 } | 56 } |
| 57 | |
| 58 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { | |
| 59 // We don't recycle resources when abandoning them. | |
| 60 fTrackedRecycledResources[i]->unrefAndAbandon(); | |
| 61 } | |
| 53 } | 62 } |
| 54 | 63 |
| 55 void GrVkCommandBuffer::reset(GrVkGpu* gpu) { | 64 void GrVkCommandBuffer::reset(GrVkGpu* gpu) { |
| 56 SkASSERT(!fIsActive); | 65 SkASSERT(!fIsActive); |
| 57 for (int i = 0; i < fTrackedResources.count(); ++i) { | 66 for (int i = 0; i < fTrackedResources.count(); ++i) { |
| 58 fTrackedResources[i]->unref(gpu); | 67 fTrackedResources[i]->unref(gpu); |
| 59 } | 68 } |
| 60 fTrackedResources.reset(); | 69 fTrackedResources.reset(); |
| 61 | 70 |
| 71 for (int i = 0; i < fTrackedRecycledResources.count(); ++i) { | |
| 72 fTrackedRecycledResources[i]->recycle(const_cast<GrVkGpu*>(gpu)); | |
| 73 fTrackedRecycledResources[i]->unref(gpu); | |
|
jvanverth1
2016/07/20 14:51:36
I think you have an extra unref here.
egdaniel
2016/07/20 14:53:26
Done.
| |
| 74 } | |
| 75 fTrackedRecycledResources.reset(); | |
| 76 | |
| 77 | |
| 62 this->invalidateState(); | 78 this->invalidateState(); |
| 63 | 79 |
| 64 // we will retain resources for later use | 80 // we will retain resources for later use |
| 65 VkCommandBufferResetFlags flags = 0; | 81 VkCommandBufferResetFlags flags = 0; |
| 66 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); | 82 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); |
| 67 | 83 |
| 68 this->onReset(gpu); | 84 this->onReset(gpu); |
| 69 } | 85 } |
| 70 | 86 |
| 71 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 617 fIsActive = true; | 633 fIsActive = true; |
| 618 } | 634 } |
| 619 | 635 |
| 620 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { | 636 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { |
| 621 SkASSERT(fIsActive); | 637 SkASSERT(fIsActive); |
| 622 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); | 638 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); |
| 623 this->invalidateState(); | 639 this->invalidateState(); |
| 624 fIsActive = false; | 640 fIsActive = false; |
| 625 } | 641 } |
| 626 | 642 |
| OLD | NEW |