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

Side by Side Diff: src/gpu/vk/GrVkMemory.h

Issue 2356343003: Some Vulkan memory fixes and cleanup (Closed)
Patch Set: Fix release build Created 4 years, 2 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/GrVkBuffer.cpp ('k') | src/gpu/vk/GrVkMemory.cpp » ('j') | 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 #ifndef GrVkMemory_DEFINED 8 #ifndef GrVkMemory_DEFINED
9 #define GrVkMemory_DEFINED 9 #define GrVkMemory_DEFINED
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 VkDeviceSize fSize; 86 VkDeviceSize fSize;
87 VkDeviceSize fAlignment; 87 VkDeviceSize fAlignment;
88 VkDeviceSize fFreeSize; 88 VkDeviceSize fFreeSize;
89 VkDeviceSize fLargestBlockSize; 89 VkDeviceSize fLargestBlockSize;
90 VkDeviceSize fLargestBlockOffset; 90 VkDeviceSize fLargestBlockOffset;
91 FreeList fFreeList; 91 FreeList fFreeList;
92 }; 92 };
93 93
94 class GrVkSubHeap : public GrVkFreeListAlloc { 94 class GrVkSubHeap : public GrVkFreeListAlloc {
95 public: 95 public:
96 GrVkSubHeap(const GrVkGpu* gpu, uint32_t memoryTypeIndex, 96 GrVkSubHeap(const GrVkGpu* gpu, uint32_t memoryTypeIndex, uint32_t heapIndex ,
97 VkDeviceSize size, VkDeviceSize alignment); 97 VkDeviceSize size, VkDeviceSize alignment);
98 ~GrVkSubHeap(); 98 ~GrVkSubHeap();
99 99
100 uint32_t memoryTypeIndex() const { return fMemoryTypeIndex; } 100 uint32_t memoryTypeIndex() const { return fMemoryTypeIndex; }
101 VkDeviceMemory memory() { return fAlloc; } 101 VkDeviceMemory memory() { return fAlloc; }
102 102
103 bool alloc(VkDeviceSize requestedSize, GrVkAlloc* alloc); 103 bool alloc(VkDeviceSize requestedSize, GrVkAlloc* alloc);
104 void free(const GrVkAlloc& alloc); 104 void free(const GrVkAlloc& alloc);
105 105
106 private: 106 private:
107 const GrVkGpu* fGpu; 107 const GrVkGpu* fGpu;
108 #ifdef SK_DEBUG
109 uint32_t fHeapIndex;
110 #endif
108 uint32_t fMemoryTypeIndex; 111 uint32_t fMemoryTypeIndex;
109 VkDeviceMemory fAlloc; 112 VkDeviceMemory fAlloc;
110 113
111 typedef GrVkFreeListAlloc INHERITED; 114 typedef GrVkFreeListAlloc INHERITED;
112 }; 115 };
113 116
114 class GrVkHeap { 117 class GrVkHeap {
115 public: 118 public:
116 enum Strategy { 119 enum Strategy {
117 kSubAlloc_Strategy, // alloc large subheaps and suballoc within th em 120 kSubAlloc_Strategy, // alloc large subheaps and suballoc within th em
(...skipping 10 matching lines...) Expand all
128 } else { 131 } else {
129 fAllocFunc = &GrVkHeap::singleAlloc; 132 fAllocFunc = &GrVkHeap::singleAlloc;
130 } 133 }
131 } 134 }
132 135
133 ~GrVkHeap() {} 136 ~GrVkHeap() {}
134 137
135 VkDeviceSize allocSize() const { return fAllocSize; } 138 VkDeviceSize allocSize() const { return fAllocSize; }
136 VkDeviceSize usedSize() const { return fUsedSize; } 139 VkDeviceSize usedSize() const { return fUsedSize; }
137 140
138 bool alloc(VkDeviceSize size, VkDeviceSize alignment, uint32_t memoryTypeInd ex, 141 bool alloc(VkDeviceSize size, VkDeviceSize alignment, uint32_t memoryTypeInd ex,
139 GrVkAlloc* alloc) { 142 uint32_t heapIndex, GrVkAlloc* alloc) {
140 SkASSERT(size > 0); 143 SkASSERT(size > 0);
141 return (*this.*fAllocFunc)(size, alignment, memoryTypeIndex, alloc); 144 return (*this.*fAllocFunc)(size, alignment, memoryTypeIndex, heapIndex, alloc);
142 } 145 }
143 bool free(const GrVkAlloc& alloc); 146 bool free(const GrVkAlloc& alloc);
144 147
145 private: 148 private:
146 typedef bool (GrVkHeap::*AllocFunc)(VkDeviceSize size, VkDeviceSize alignmen t, 149 typedef bool (GrVkHeap::*AllocFunc)(VkDeviceSize size, VkDeviceSize alignmen t,
147 uint32_t memoryTypeIndex, GrVkAlloc* all oc); 150 uint32_t memoryTypeIndex, uint32_t heapI ndex,
151 GrVkAlloc* alloc);
148 152
149 bool subAlloc(VkDeviceSize size, VkDeviceSize alignment, 153 bool subAlloc(VkDeviceSize size, VkDeviceSize alignment,
150 uint32_t memoryTypeIndex, GrVkAlloc* alloc); 154 uint32_t memoryTypeIndex, uint32_t heapIndex,
155 GrVkAlloc* alloc);
151 bool singleAlloc(VkDeviceSize size, VkDeviceSize alignment, 156 bool singleAlloc(VkDeviceSize size, VkDeviceSize alignment,
152 uint32_t memoryTypeIndex, GrVkAlloc* alloc); 157 uint32_t memoryTypeIndex, uint32_t heapIndex,
158 GrVkAlloc* alloc);
153 159
154 const GrVkGpu* fGpu; 160 const GrVkGpu* fGpu;
155 VkDeviceSize fSubHeapSize; 161 VkDeviceSize fSubHeapSize;
156 VkDeviceSize fAllocSize; 162 VkDeviceSize fAllocSize;
157 VkDeviceSize fUsedSize; 163 VkDeviceSize fUsedSize;
158 AllocFunc fAllocFunc; 164 AllocFunc fAllocFunc;
159 SkTArray<SkAutoTDelete<GrVkSubHeap>> fSubHeaps; 165 SkTArray<SkAutoTDelete<GrVkSubHeap>> fSubHeaps;
160 }; 166 };
161 #endif 167 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkBuffer.cpp ('k') | src/gpu/vk/GrVkMemory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698