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

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

Issue 2195713002: Properly recycle uniform buffers in vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@slownanobench
Patch Set: rebase Created 4 years, 4 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/GrVkBuffer.h ('k') | src/gpu/vk/GrVkPipelineState.cpp » ('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 "GrVkBuffer.h" 8 #include "GrVkBuffer.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 #include "GrVkMemory.h" 10 #include "GrVkMemory.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return false; 173 return false;
174 } 174 }
175 175
176 // TODO: update data based on buffer offset 176 // TODO: update data based on buffer offset
177 if (!fDesc.fDynamic) { 177 if (!fDesc.fDynamic) {
178 return gpu->updateBuffer(this, src, fOffset, srcSizeInBytes); 178 return gpu->updateBuffer(this, src, fOffset, srcSizeInBytes);
179 } 179 }
180 180
181 if (!fResource->unique()) { 181 if (!fResource->unique()) {
182 // in use by the command buffer, so we need to create a new one 182 // in use by the command buffer, so we need to create a new one
183 fResource->unref(gpu); 183 fResource->recycle(gpu);
184 fResource = Create(gpu, fDesc); 184 fResource = this->createResource(gpu, fDesc);
185 if (createdNewBuffer) { 185 if (createdNewBuffer) {
186 *createdNewBuffer = true; 186 *createdNewBuffer = true;
187 } 187 }
188 } 188 }
189 189
190 void* mapPtr; 190 void* mapPtr;
191 const GrVkAlloc& alloc = this->alloc(); 191 const GrVkAlloc& alloc = this->alloc();
192 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, 192 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory,
193 alloc.fOffset + fOffset, 193 alloc.fOffset + fOffset,
194 srcSizeInBytes, 0, &mapPtr)); 194 srcSizeInBytes, 0, &mapPtr));
195 195
196 if (VK_SUCCESS != err) { 196 if (VK_SUCCESS != err) {
197 return false; 197 return false;
198 } 198 }
199 199
200 memcpy(mapPtr, src, srcSizeInBytes); 200 memcpy(mapPtr, src, srcSizeInBytes);
201 201
202 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc.fMemory)); 202 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc.fMemory));
203 203
204 return true; 204 return true;
205 } 205 }
206 206
207 void GrVkBuffer::validate() const { 207 void GrVkBuffer::validate() const {
208 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type 208 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type
209 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType 209 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType
210 || kUniform_Type == fDesc.fType); 210 || kUniform_Type == fDesc.fType);
211 } 211 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkBuffer.h ('k') | src/gpu/vk/GrVkPipelineState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698