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 #ifndef GrVkUniformBuffer_DEFINED | 8 #ifndef GrVkUniformBuffer_DEFINED |
9 #define GrVkUniformBuffer_DEFINED | 9 #define GrVkUniformBuffer_DEFINED |
10 | 10 |
11 #include "GrVkBuffer.h" | 11 #include "GrVkBuffer.h" |
12 | 12 |
13 class GrVkGpu; | 13 class GrVkGpu; |
14 | 14 |
15 class GrVkUniformBuffer : public GrVkBuffer { | 15 class GrVkUniformBuffer : public GrVkBuffer { |
16 | 16 |
17 public: | 17 public: |
18 static GrVkUniformBuffer* Create(GrVkGpu* gpu, size_t size, bool dynamic); | 18 static GrVkUniformBuffer* Create(GrVkGpu* gpu, size_t size); |
| 19 static const GrVkResource* CreateResource(GrVkGpu* gpu, size_t size); |
| 20 static const size_t kStandardSize = 256; |
19 | 21 |
20 void* map(const GrVkGpu* gpu) { | 22 void* map(const GrVkGpu* gpu) { |
21 return this->vkMap(gpu); | 23 return this->vkMap(gpu); |
22 } | 24 } |
23 void unmap(GrVkGpu* gpu) { | 25 void unmap(GrVkGpu* gpu) { |
24 this->vkUnmap(gpu); | 26 this->vkUnmap(gpu); |
25 } | 27 } |
26 // The output variable createdNewBuffer must be set to true if a new VkBuffe
r is created in | 28 // The output variable createdNewBuffer must be set to true if a new VkBuffe
r is created in |
27 // order to upload the data | 29 // order to upload the data |
28 bool updateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes, | 30 bool updateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes, |
29 bool* createdNewBuffer) { | 31 bool* createdNewBuffer) { |
30 return this->vkUpdateData(gpu, src, srcSizeInBytes, createdNewBuffer); | 32 return this->vkUpdateData(gpu, src, srcSizeInBytes, createdNewBuffer); |
31 } | 33 } |
32 void release(const GrVkGpu* gpu) { | 34 void release(const GrVkGpu* gpu) { this->vkRelease(gpu); } |
33 this->vkRelease(gpu); | 35 void abandon() { this->vkAbandon(); } |
34 } | |
35 void abandon() { | |
36 this->vkAbandon(); | |
37 } | |
38 | 36 |
39 private: | 37 private: |
40 GrVkUniformBuffer(const GrVkBuffer::Desc& desc, const GrVkBuffer::Resource*
resource) | 38 class Resource : public GrVkBuffer::Resource { |
41 : INHERITED(desc, resource) { | 39 public: |
| 40 Resource(VkBuffer buf, const GrVkAlloc& alloc) |
| 41 : INHERITED(buf, alloc, kUniform_Type) {} |
| 42 |
| 43 void onRecycle(GrVkGpu* gpu) const override; |
| 44 |
| 45 typedef GrVkBuffer::Resource INHERITED; |
42 }; | 46 }; |
43 | 47 |
| 48 GrVkUniformBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, |
| 49 const GrVkUniformBuffer::Resource* resource) |
| 50 : INHERITED(desc, resource) |
| 51 , fGpu(gpu) {} |
| 52 |
| 53 GrVkGpu* fGpu; |
| 54 |
44 typedef GrVkBuffer INHERITED; | 55 typedef GrVkBuffer INHERITED; |
45 }; | 56 }; |
46 | 57 |
47 #endif | 58 #endif |
OLD | NEW |