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

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

Issue 2358123004: Revert of Some Vulkan memory fixes and cleanup (Closed)
Patch Set: Created 4 years, 3 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, uint32_t heapIndex , 96 GrVkSubHeap(const GrVkGpu* gpu, uint32_t memoryTypeIndex,
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 uint32_t fMemoryTypeIndex; 108 uint32_t fMemoryTypeIndex;
109 uint32_t fHeapIndex;
110 VkDeviceMemory fAlloc; 109 VkDeviceMemory fAlloc;
111 110
112 typedef GrVkFreeListAlloc INHERITED; 111 typedef GrVkFreeListAlloc INHERITED;
113 }; 112 };
114 113
115 class GrVkHeap { 114 class GrVkHeap {
116 public: 115 public:
117 enum Strategy { 116 enum Strategy {
118 kSubAlloc_Strategy, // alloc large subheaps and suballoc within th em 117 kSubAlloc_Strategy, // alloc large subheaps and suballoc within th em
119 kSingleAlloc_Strategy // alloc/recycle an individual subheap per obj ect 118 kSingleAlloc_Strategy // alloc/recycle an individual subheap per obj ect
120 }; 119 };
121 120
122 GrVkHeap(const GrVkGpu* gpu, Strategy strategy, VkDeviceSize subHeapSize) 121 GrVkHeap(const GrVkGpu* gpu, Strategy strategy, VkDeviceSize subHeapSize)
123 : fGpu(gpu) 122 : fGpu(gpu)
124 , fSubHeapSize(subHeapSize) 123 , fSubHeapSize(subHeapSize)
125 , fAllocSize(0) 124 , fAllocSize(0)
126 , fUsedSize(0) { 125 , fUsedSize(0) {
127 if (strategy == kSubAlloc_Strategy) { 126 if (strategy == kSubAlloc_Strategy) {
128 fAllocFunc = &GrVkHeap::subAlloc; 127 fAllocFunc = &GrVkHeap::subAlloc;
129 } else { 128 } else {
130 fAllocFunc = &GrVkHeap::singleAlloc; 129 fAllocFunc = &GrVkHeap::singleAlloc;
131 } 130 }
132 } 131 }
133 132
134 ~GrVkHeap() {} 133 ~GrVkHeap() {}
135 134
136 VkDeviceSize allocSize() const { return fAllocSize; } 135 VkDeviceSize allocSize() const { return fAllocSize; }
137 VkDeviceSize usedSize() const { return fUsedSize; } 136 VkDeviceSize usedSize() const { return fUsedSize; }
138 137
139 bool alloc(VkDeviceSize size, VkDeviceSize alignment, uint32_t memoryTypeInd ex, 138 bool alloc(VkDeviceSize size, VkDeviceSize alignment, uint32_t memoryTypeInd ex,
140 uint32_t heapIndex, GrVkAlloc* alloc) { 139 GrVkAlloc* alloc) {
141 SkASSERT(size > 0); 140 SkASSERT(size > 0);
142 return (*this.*fAllocFunc)(size, alignment, memoryTypeIndex, heapIndex, alloc); 141 return (*this.*fAllocFunc)(size, alignment, memoryTypeIndex, alloc);
143 } 142 }
144 bool free(const GrVkAlloc& alloc); 143 bool free(const GrVkAlloc& alloc);
145 144
146 private: 145 private:
147 typedef bool (GrVkHeap::*AllocFunc)(VkDeviceSize size, VkDeviceSize alignmen t, 146 typedef bool (GrVkHeap::*AllocFunc)(VkDeviceSize size, VkDeviceSize alignmen t,
148 uint32_t memoryTypeIndex, uint32_t heapI ndex, 147 uint32_t memoryTypeIndex, GrVkAlloc* all oc);
149 GrVkAlloc* alloc);
150 148
151 bool subAlloc(VkDeviceSize size, VkDeviceSize alignment, 149 bool subAlloc(VkDeviceSize size, VkDeviceSize alignment,
152 uint32_t memoryTypeIndex, uint32_t heapIndex, 150 uint32_t memoryTypeIndex, GrVkAlloc* alloc);
153 GrVkAlloc* alloc);
154 bool singleAlloc(VkDeviceSize size, VkDeviceSize alignment, 151 bool singleAlloc(VkDeviceSize size, VkDeviceSize alignment,
155 uint32_t memoryTypeIndex, uint32_t heapIndex, 152 uint32_t memoryTypeIndex, GrVkAlloc* alloc);
156 GrVkAlloc* alloc);
157 153
158 const GrVkGpu* fGpu; 154 const GrVkGpu* fGpu;
159 VkDeviceSize fSubHeapSize; 155 VkDeviceSize fSubHeapSize;
160 VkDeviceSize fAllocSize; 156 VkDeviceSize fAllocSize;
161 VkDeviceSize fUsedSize; 157 VkDeviceSize fUsedSize;
162 AllocFunc fAllocFunc; 158 AllocFunc fAllocFunc;
163 SkTArray<SkAutoTDelete<GrVkSubHeap>> fSubHeaps; 159 SkTArray<SkAutoTDelete<GrVkSubHeap>> fSubHeaps;
164 }; 160 };
165 #endif 161 #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