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 "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 Loading... |
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 } |
OLD | NEW |