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

Side by Side Diff: tests/VkHeapTests.cpp

Issue 2072763002: Check for some potential subheap allocation failures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add some asserts Created 4 years, 6 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/GrVkMemory.cpp ('k') | no next file » | 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 // This is a GPU-backend specific test. It relies on static intializers to work 8 // This is a GPU-backend specific test. It relies on static intializers to work
9 9
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 REPORTER_ASSERT(reporter, heap.alloc(22 * 1024, kAlignment, kHeapIndex, &all oc2)); 148 REPORTER_ASSERT(reporter, heap.alloc(22 * 1024, kAlignment, kHeapIndex, &all oc2));
149 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 107 * 1024); 149 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 107 * 1024);
150 heap.free(alloc1); 150 heap.free(alloc1);
151 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 102 * 1024); 151 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 102 * 1024);
152 heap.free(alloc0); 152 heap.free(alloc0);
153 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 62 * 1024); 153 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 62 * 1024);
154 heap.free(alloc2); 154 heap.free(alloc2);
155 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 40 * 1024); 155 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 40 * 1024);
156 heap.free(alloc3); 156 heap.free(alloc3);
157 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 0 * 1024); 157 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 0 * 1024);
158 // heap should not grow here (allocating more than subheap size)
159 REPORTER_ASSERT(reporter, heap.alloc(128 * 1024, kAlignment, kHeapIndex, &al loc0));
160 REPORTER_ASSERT(reporter, 0 == alloc0.fSize);
161 REPORTER_ASSERT(reporter, heap.allocSize() == 128 * 1024 && heap.usedSize() == 0 * 1024);
162 heap.free(alloc0);
158 } 163 }
159 164
160 void singlealloc_test(skiatest::Reporter* reporter, GrContext* context) { 165 void singlealloc_test(skiatest::Reporter* reporter, GrContext* context) {
161 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); 166 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
162 167
163 // heap index doesn't matter, we're just testing the allocation algorithm so we'll use 0 168 // heap index doesn't matter, we're just testing the allocation algorithm so we'll use 0
164 GrVkHeap heap(gpu, GrVkHeap::kSingleAlloc_Strategy, 64 * 1024); 169 GrVkHeap heap(gpu, GrVkHeap::kSingleAlloc_Strategy, 64 * 1024);
165 GrVkAlloc alloc0, alloc1, alloc2, alloc3; 170 GrVkAlloc alloc0, alloc1, alloc2, alloc3;
166 const VkDeviceSize kAlignment = 64; 171 const VkDeviceSize kAlignment = 64;
167 const uint32_t kHeapIndex = 0; 172 const uint32_t kHeapIndex = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 REPORTER_ASSERT(reporter, heap.allocSize() == 112 * 1024 && heap.usedSize() == 0 * 1024); 204 REPORTER_ASSERT(reporter, heap.allocSize() == 112 * 1024 && heap.usedSize() == 0 * 1024);
200 } 205 }
201 206
202 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkHeapTests, reporter, ctxInfo) { 207 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkHeapTests, reporter, ctxInfo) {
203 subheap_test(reporter, ctxInfo.grContext()); 208 subheap_test(reporter, ctxInfo.grContext());
204 suballoc_test(reporter, ctxInfo.grContext()); 209 suballoc_test(reporter, ctxInfo.grContext());
205 singlealloc_test(reporter, ctxInfo.grContext()); 210 singlealloc_test(reporter, ctxInfo.grContext());
206 } 211 }
207 212
208 #endif 213 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkMemory.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698