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 GrVkBuffer_DEFINED | 8 #ifndef GrVkBuffer_DEFINED |
9 #define GrVkBuffer_DEFINED | 9 #define GrVkBuffer_DEFINED |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 kCopyWrite_Type, | 46 kCopyWrite_Type, |
47 }; | 47 }; |
48 | 48 |
49 protected: | 49 protected: |
50 struct Desc { | 50 struct Desc { |
51 size_t fSizeInBytes; | 51 size_t fSizeInBytes; |
52 Type fType; // vertex buffer, index buffer, etc. | 52 Type fType; // vertex buffer, index buffer, etc. |
53 bool fDynamic; | 53 bool fDynamic; |
54 }; | 54 }; |
55 | 55 |
56 class Resource : public GrVkResource { | 56 class Resource : public GrVkRecycledResource { |
57 public: | 57 public: |
58 Resource(VkBuffer buf, const GrVkAlloc& alloc, Type type) | 58 Resource(VkBuffer buf, const GrVkAlloc& alloc, Type type) |
59 : INHERITED(), fBuffer(buf), fAlloc(alloc), fType(type) {} | 59 : INHERITED(), fBuffer(buf), fAlloc(alloc), fType(type) {} |
60 | 60 |
61 #ifdef SK_TRACE_VK_RESOURCES | 61 #ifdef SK_TRACE_VK_RESOURCES |
62 void dumpInfo() const override { | 62 void dumpInfo() const override { |
63 SkDebugf("GrVkBuffer: %d (%d refs)\n", fBuffer, this->getRefCnt()); | 63 SkDebugf("GrVkBuffer: %d (%d refs)\n", fBuffer, this->getRefCnt()); |
64 } | 64 } |
65 #endif | 65 #endif |
66 VkBuffer fBuffer; | 66 VkBuffer fBuffer; |
67 GrVkAlloc fAlloc; | 67 GrVkAlloc fAlloc; |
68 Type fType; | 68 Type fType; |
69 | 69 |
70 private: | 70 private: |
71 void freeGPUData(const GrVkGpu* gpu) const override; | 71 void freeGPUData(const GrVkGpu* gpu) const override; |
72 | 72 |
73 typedef GrVkResource INHERITED; | 73 void onRecycle(GrVkGpu* gpu) const override { this->unref(gpu); } |
| 74 |
| 75 typedef GrVkRecycledResource INHERITED; |
74 }; | 76 }; |
75 | 77 |
76 // convenience routine for raw buffer creation | 78 // convenience routine for raw buffer creation |
77 static const Resource* Create(const GrVkGpu* gpu, | 79 static const Resource* Create(const GrVkGpu* gpu, |
78 const Desc& descriptor); | 80 const Desc& descriptor); |
79 | 81 |
80 GrVkBuffer(const Desc& desc, const GrVkBuffer::Resource* resource) | 82 GrVkBuffer(const Desc& desc, const GrVkBuffer::Resource* resource) |
81 : fDesc(desc), fResource(resource), fOffset(0), fMapPtr(nullptr) { | 83 : fDesc(desc), fResource(resource), fOffset(0), fMapPtr(nullptr) { |
82 } | 84 } |
83 | 85 |
(...skipping 13 matching lines...) Expand all Loading... |
97 | 99 |
98 Desc fDesc; | 100 Desc fDesc; |
99 const Resource* fResource; | 101 const Resource* fResource; |
100 VkDeviceSize fOffset; | 102 VkDeviceSize fOffset; |
101 void* fMapPtr; | 103 void* fMapPtr; |
102 | 104 |
103 typedef SkNoncopyable INHERITED; | 105 typedef SkNoncopyable INHERITED; |
104 }; | 106 }; |
105 | 107 |
106 #endif | 108 #endif |
OLD | NEW |