Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: src/gpu/vk/GrVkCommandBuffer.cpp

Issue 2167453003: Add GrVkRecycledResource subclass (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove extra unref Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkCommandBuffer.h ('k') | src/gpu/vk/GrVkResource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
74 fTrackedRecycledResources.reset();
75
76
62 this->invalidateState(); 77 this->invalidateState();
63 78
64 // we will retain resources for later use 79 // we will retain resources for later use
65 VkCommandBufferResetFlags flags = 0; 80 VkCommandBufferResetFlags flags = 0;
66 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags)); 81 GR_VK_CALL(gpu->vkInterface(), ResetCommandBuffer(fCmdBuffer, flags));
67 82
68 this->onReset(gpu); 83 this->onReset(gpu);
69 } 84 }
70 85
71 //////////////////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////////////////
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 fIsActive = true; 632 fIsActive = true;
618 } 633 }
619 634
620 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) { 635 void GrVkSecondaryCommandBuffer::end(const GrVkGpu* gpu) {
621 SkASSERT(fIsActive); 636 SkASSERT(fIsActive);
622 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer)); 637 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), EndCommandBuffer(fCmdBuffer));
623 this->invalidateState(); 638 this->invalidateState();
624 fIsActive = false; 639 fIsActive = false;
625 } 640 }
626 641
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkCommandBuffer.h ('k') | src/gpu/vk/GrVkResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698