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 "GrVkVertexBuffer.h" | 8 #include "GrVkVertexBuffer.h" |
9 #include "GrVkGpu.h" | 9 #include "GrVkGpu.h" |
10 | 10 |
11 GrVkVertexBuffer::GrVkVertexBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, | 11 GrVkVertexBuffer::GrVkVertexBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, |
12 const GrVkBuffer::Resource* bufferResource) | 12 const GrVkBuffer::Resource* bufferResource) |
13 : INHERITED(gpu, desc.fSizeInBytes, desc.fDynamic, false) | 13 : INHERITED(gpu, kVertex_GrBufferType, desc.fSizeInBytes, |
| 14 desc.fDynamic ? kDynamic_GrAccessPattern : kStatic_GrAccessPatte
rn, false) |
14 , GrVkBuffer(desc, bufferResource) { | 15 , GrVkBuffer(desc, bufferResource) { |
15 this->registerWithCache(); | 16 this->registerWithCache(); |
16 } | 17 } |
17 | 18 |
18 GrVkVertexBuffer* GrVkVertexBuffer::Create(GrVkGpu* gpu, size_t size, bool dynam
ic) { | 19 GrVkVertexBuffer* GrVkVertexBuffer::Create(GrVkGpu* gpu, size_t size, bool dynam
ic) { |
19 GrVkBuffer::Desc desc; | 20 GrVkBuffer::Desc desc; |
20 desc.fDynamic = dynamic; | 21 desc.fDynamic = dynamic; |
21 desc.fType = GrVkBuffer::kVertex_Type; | 22 desc.fType = GrVkBuffer::kVertex_Type; |
22 desc.fSizeInBytes = size; | 23 desc.fSizeInBytes = size; |
23 | 24 |
(...skipping 15 matching lines...) Expand all Loading... |
39 } | 40 } |
40 | 41 |
41 INHERITED::onRelease(); | 42 INHERITED::onRelease(); |
42 } | 43 } |
43 | 44 |
44 void GrVkVertexBuffer::onAbandon() { | 45 void GrVkVertexBuffer::onAbandon() { |
45 this->vkAbandon(); | 46 this->vkAbandon(); |
46 INHERITED::onAbandon(); | 47 INHERITED::onAbandon(); |
47 } | 48 } |
48 | 49 |
49 void* GrVkVertexBuffer::onMap() { | 50 void GrVkVertexBuffer::onMap() { |
50 if (!this->wasDestroyed()) { | 51 if (!this->wasDestroyed()) { |
51 return this->vkMap(this->getVkGpu()); | 52 this->GrBuffer::fMapPtr = this->vkMap(this->getVkGpu()); |
52 } else { | |
53 return NULL; | |
54 } | 53 } |
55 } | 54 } |
56 | 55 |
57 void GrVkVertexBuffer::onUnmap() { | 56 void GrVkVertexBuffer::onUnmap() { |
58 if (!this->wasDestroyed()) { | 57 if (!this->wasDestroyed()) { |
59 this->vkUnmap(this->getVkGpu()); | 58 this->vkUnmap(this->getVkGpu()); |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
63 bool GrVkVertexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) { | 62 bool GrVkVertexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) { |
64 if (!this->wasDestroyed()) { | 63 if (!this->wasDestroyed()) { |
65 return this->vkUpdateData(this->getVkGpu(), src, srcSizeInBytes); | 64 return this->vkUpdateData(this->getVkGpu(), src, srcSizeInBytes); |
66 } else { | 65 } else { |
67 return false; | 66 return false; |
68 } | 67 } |
69 } | 68 } |
70 | 69 |
71 GrVkGpu* GrVkVertexBuffer::getVkGpu() const { | 70 GrVkGpu* GrVkVertexBuffer::getVkGpu() const { |
72 SkASSERT(!this->wasDestroyed()); | 71 SkASSERT(!this->wasDestroyed()); |
73 return static_cast<GrVkGpu*>(this->getGpu()); | 72 return static_cast<GrVkGpu*>(this->getGpu()); |
74 } | 73 } |
75 | 74 |
OLD | NEW |