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

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

Issue 1774913005: Create new buffer (if necessary) on vkMap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | 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 "GrVkBuffer.h" 8 #include "GrVkBuffer.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 #include "GrVkMemory.h" 10 #include "GrVkMemory.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void GrVkBuffer::vkAbandon() { 118 void GrVkBuffer::vkAbandon() {
119 fResource->unrefAndAbandon(); 119 fResource->unrefAndAbandon();
120 fMapPtr = nullptr; 120 fMapPtr = nullptr;
121 VALIDATE(); 121 VALIDATE();
122 } 122 }
123 123
124 void* GrVkBuffer::vkMap(const GrVkGpu* gpu) { 124 void* GrVkBuffer::vkMap(const GrVkGpu* gpu) {
125 VALIDATE(); 125 VALIDATE();
126 SkASSERT(!this->vkIsMapped()); 126 SkASSERT(!this->vkIsMapped());
127 127
128 // we should be the only owner 128 if (!fResource->unique()) {
129 SkASSERT(fResource->unique()); 129 // in use by the command buffer, so we need to create a new one
130 fResource->unref(gpu);
131 fResource = Create(gpu, fDesc);
132 }
130 133
131 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SI ZE, 0, &fMapPtr)); 134 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SI ZE, 0, &fMapPtr));
132 if (err) { 135 if (err) {
133 fMapPtr = nullptr; 136 fMapPtr = nullptr;
134 } 137 }
135 138
136 VALIDATE(); 139 VALIDATE();
137 return fMapPtr; 140 return fMapPtr;
138 } 141 }
139 142
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 180
178 return true; 181 return true;
179 } 182 }
180 183
181 void GrVkBuffer::validate() const { 184 void GrVkBuffer::validate() const {
182 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type 185 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type
183 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType 186 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType
184 || kUniform_Type == fDesc.fType); 187 || kUniform_Type == fDesc.fType);
185 } 188 }
186 189
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698