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

Side by Side Diff: src/gpu/vk/GrVkUniformBuffer.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/GrVkUniformBuffer.h ('k') | 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 "GrVkUniformBuffer.h" 8 #include "GrVkUniformBuffer.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const GrVkResource* resource = new GrVkUniformBuffer::Resource(buffer, alloc ); 75 const GrVkResource* resource = new GrVkUniformBuffer::Resource(buffer, alloc );
76 if (!resource) { 76 if (!resource) {
77 VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr)); 77 VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr));
78 GrVkMemory::FreeBufferMemory(gpu, kUniform_Type, alloc); 78 GrVkMemory::FreeBufferMemory(gpu, kUniform_Type, alloc);
79 return nullptr; 79 return nullptr;
80 } 80 }
81 81
82 return resource; 82 return resource;
83 } 83 }
84 84
85 const GrVkBuffer::Resource* GrVkUniformBuffer::createResource(GrVkGpu* gpu,
86 const GrVkBuffer:: Desc& descriptor) {
87 const GrVkResource* vkResource;
88 if (descriptor.fSizeInBytes <= GrVkUniformBuffer::kStandardSize) {
89 GrVkResourceProvider& provider = gpu->resourceProvider();
90 vkResource = provider.findOrCreateStandardUniformBufferResource();
91 } else {
92 vkResource = CreateResource(gpu, descriptor.fSizeInBytes);
93 }
94 return (const GrVkBuffer::Resource*) vkResource;
95 }
96
85 void GrVkUniformBuffer::Resource::onRecycle(GrVkGpu* gpu) const { 97 void GrVkUniformBuffer::Resource::onRecycle(GrVkGpu* gpu) const {
86 if (fAlloc.fSize <= GrVkUniformBuffer::kStandardSize) { 98 if (fAlloc.fSize <= GrVkUniformBuffer::kStandardSize) {
87 gpu->resourceProvider().recycleStandardUniformBufferResource(this); 99 gpu->resourceProvider().recycleStandardUniformBufferResource(this);
88 } else { 100 } else {
89 this->unref(gpu); 101 this->unref(gpu);
90 } 102 }
91 } 103 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkUniformBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698