• Home
  • Raw
  • Download

Lines Matching refs:pool

18 static int block_count(const GrSBlockAllocator<N>& pool) {  in block_count()  argument
20 for (const Block* b : pool->blocks()) { in block_count()
28 static Block* get_block(GrSBlockAllocator<N>& pool, int blockIndex) { in get_block() argument
31 for (Block* b: pool->blocks()) { in get_block()
47 static size_t total_size(GrSBlockAllocator<N>& pool) { in total_size() argument
48 return pool->totalSize() - pool->testingOnly_scratchBlockSize(); in total_size()
52 static size_t add_block(GrSBlockAllocator<N>& pool) { in add_block() argument
53 size_t currentSize = total_size(pool); in add_block()
54 GrBlockAllocator::Block* current = pool->currentBlock(); in add_block()
55 while(pool->currentBlock() == current) { in add_block()
56 pool->template allocate<4>(pool->preallocSize() / 2); in add_block()
58 return total_size(pool) - currentSize; in add_block()
62 static void* alloc_byte(GrSBlockAllocator<N>& pool) { in alloc_byte() argument
63 auto br = pool->template allocate<1>(1); in alloc_byte()
93 GrSBlockAllocator<1024> pool{}; in DEF_TEST() local
94 SkDEBUGCODE(pool->validate();) in DEF_TEST()
109 REPORTER_ASSERT(r, pool->currentBlock() == br.fBlock); in DEF_TEST()
123 auto p1 = pool->allocate<1>(14); in DEF_TEST()
126 auto p2 = pool->allocate<2>(24); in DEF_TEST()
129 auto p4 = pool->allocate<4>(28); in DEF_TEST()
132 auto p8 = pool->allocate<8>(40); in DEF_TEST()
135 auto p16 = pool->allocate<16>(64); in DEF_TEST()
138 auto p32 = pool->allocate<32>(96); in DEF_TEST()
142 REPORTER_ASSERT(r, total_size(pool) == pool->preallocSize()); in DEF_TEST()
143 SkDEBUGCODE(pool->validate();) in DEF_TEST()
146 size_t avail = pool->currentBlock()->avail<4>(); in DEF_TEST()
147 auto pAvail = pool->allocate<4>(avail); in DEF_TEST()
152 REPORTER_ASSERT(r, pool->currentBlock()->avail<4>() < 4); in DEF_TEST()
153 auto pNextBlock = pool->allocate<4>(4); in DEF_TEST()
155 REPORTER_ASSERT(r, total_size(pool) > pool->preallocSize()); in DEF_TEST()
158 size_t currentSize = total_size(pool); in DEF_TEST()
159 size_t bigRequest = pool->currentBlock()->avail<4>() * 2; in DEF_TEST()
160 auto pTooBig = pool->allocate<4>(bigRequest); in DEF_TEST()
162 REPORTER_ASSERT(r, total_size(pool) > currentSize); in DEF_TEST()
165 REPORTER_ASSERT(r, total_size(pool) - currentSize < 4096); in DEF_TEST()
166 currentSize = total_size(pool); in DEF_TEST()
167 auto pReallyTooBig = pool->allocate<4>(4096); in DEF_TEST()
169 REPORTER_ASSERT(r, total_size(pool) >= currentSize + 4096); in DEF_TEST()
170 SkDEBUGCODE(pool->validate();) in DEF_TEST()
174 GrSBlockAllocator<1024> pool{}; in DEF_TEST() local
175 SkDEBUGCODE(pool->validate();) in DEF_TEST()
178 GrBlockAllocator::ByteRange p = pool->allocate<4>(16); in DEF_TEST()
186 auto pNext = pool->allocate<4>(16); in DEF_TEST()
212 pNext = pool->allocate<4>(16); in DEF_TEST()
215 SkDEBUGCODE(pool->validate();) in DEF_TEST()
227 GrSBlockAllocator<1024> pool{}; in DEF_TEST() local
228 SkDEBUGCODE(pool->validate();) in DEF_TEST()
231 auto p = pool->allocate<8>(32); in DEF_TEST()
232 REPORTER_ASSERT(r, pool->currentBlock()->release(p.fStart, p.fEnd)); in DEF_TEST()
234 auto p2 = pool->allocate<8>(32); in DEF_TEST()
238 auto p3 = pool->allocate<8>(64); in DEF_TEST()
244 auto p4 = pool->allocate<8>(16); in DEF_TEST()
245 auto p5 = pool->allocate<8>(96); in DEF_TEST()
251 p = pool->allocate<8>(32); in DEF_TEST()
255 SkDEBUGCODE(pool->validate();) in DEF_TEST()
261 GrSBlockAllocator<1024> pool{}; in DEF_TEST() local
262 SkDEBUGCODE(pool->validate();) in DEF_TEST()
266 ptrs.push_back(pool->allocate<4>(16)); in DEF_TEST()
270 SkDEBUGCODE(pool->validate();) in DEF_TEST()
278 SkDEBUGCODE(pool->validate();) in DEF_TEST()
279 REPORTER_ASSERT(r, pool->allocate<4>(16).fStart == ptrs[0].fStart); in DEF_TEST()
297 GrSBlockAllocator<kInitSize> pool{(GrowthPolicy) gp}; in DEF_TEST() local
298 SkDEBUGCODE(pool->validate();) in DEF_TEST()
300 REPORTER_ASSERT(r, kExpectedSizes[gp][0] == total_size(pool)); in DEF_TEST()
302 REPORTER_ASSERT(r, kExpectedSizes[gp][i] == add_block(pool)); in DEF_TEST()
305 SkDEBUGCODE(pool->validate();) in DEF_TEST()
312 GrSBlockAllocator<kBlockIncrement> pool{GrowthPolicy::kLinear}; in DEF_TEST() local
313 SkDEBUGCODE(pool->validate();) in DEF_TEST()
315 void* firstAlloc = alloc_byte(pool); in DEF_TEST()
318 add_block(pool); in DEF_TEST()
319 add_block(pool); in DEF_TEST()
320 add_block(pool); in DEF_TEST()
321 SkDEBUGCODE(pool->validate();) in DEF_TEST()
323 REPORTER_ASSERT(r, block_count(pool) == 4); // 3 added plus the implicit head in DEF_TEST()
325 get_block(pool, 0)->setMetadata(2); in DEF_TEST()
329 pool->reset(); in DEF_TEST()
330 SkDEBUGCODE(pool->validate();) in DEF_TEST()
332 REPORTER_ASSERT(r,block_count(pool) == 1); in DEF_TEST()
333 REPORTER_ASSERT(r, pool->preallocSize() == pool->totalSize()); in DEF_TEST()
334 REPORTER_ASSERT(r, get_block(pool, 0)->metadata() == 0); in DEF_TEST()
336 REPORTER_ASSERT(r, firstAlloc == alloc_byte(pool)); in DEF_TEST()
337 REPORTER_ASSERT(r, 2 * kBlockIncrement == add_block(pool)); in DEF_TEST()
338 REPORTER_ASSERT(r, 3 * kBlockIncrement == add_block(pool)); in DEF_TEST()
339 SkDEBUGCODE(pool->validate();) in DEF_TEST()
346 GrSBlockAllocator<1024> pool{(GrowthPolicy) gp}; in DEF_TEST() local
347 SkDEBUGCODE(pool->validate();) in DEF_TEST()
349 void* firstAlloc = alloc_byte(pool); in DEF_TEST()
351 size_t b1Size = total_size(pool); in DEF_TEST()
352 size_t b2Size = add_block(pool); in DEF_TEST()
353 size_t b3Size = add_block(pool); in DEF_TEST()
354 size_t b4Size = add_block(pool); in DEF_TEST()
355 SkDEBUGCODE(pool->validate();) in DEF_TEST()
357 get_block(pool, 0)->setMetadata(1); in DEF_TEST()
358 get_block(pool, 1)->setMetadata(2); in DEF_TEST()
359 get_block(pool, 2)->setMetadata(3); in DEF_TEST()
360 get_block(pool, 3)->setMetadata(4); in DEF_TEST()
364 REPORTER_ASSERT(r, total_size(pool) == b1Size + b2Size + b3Size + b4Size); in DEF_TEST()
365 pool->releaseBlock(get_block(pool, 1)); in DEF_TEST()
366 REPORTER_ASSERT(r, block_count(pool) == 3); in DEF_TEST()
367 REPORTER_ASSERT(r, get_block(pool, 1)->metadata() == 3); in DEF_TEST()
368 REPORTER_ASSERT(r, total_size(pool) == b1Size + b3Size + b4Size); in DEF_TEST()
370 pool->releaseBlock(get_block(pool, 1)); in DEF_TEST()
371 REPORTER_ASSERT(r, block_count(pool) == 2); in DEF_TEST()
372 REPORTER_ASSERT(r, get_block(pool, 1)->metadata() == 4); in DEF_TEST()
373 REPORTER_ASSERT(r, total_size(pool) == b1Size + b4Size); in DEF_TEST()
375 pool->releaseBlock(get_block(pool, 1)); in DEF_TEST()
376 REPORTER_ASSERT(r, block_count(pool) == 1); in DEF_TEST()
377 REPORTER_ASSERT(r, total_size(pool) == b1Size); in DEF_TEST()
381 pool->resetScratchSpace(); in DEF_TEST()
382 size_t size = add_block(pool); in DEF_TEST()
384 pool->releaseBlock(get_block(pool, 1)); in DEF_TEST()
387 pool->releaseBlock(get_block(pool, 0)); in DEF_TEST()
388 REPORTER_ASSERT(r, total_size(pool) == pool->preallocSize()); in DEF_TEST()
389 REPORTER_ASSERT(r, block_count(pool) == 1); in DEF_TEST()
390 REPORTER_ASSERT(r, firstAlloc == alloc_byte(pool)); in DEF_TEST()
391 REPORTER_ASSERT(r, get_block(pool, 0)->metadata() == 0); // metadata reset too in DEF_TEST()
395 add_block(pool); in DEF_TEST()
396 add_block(pool); in DEF_TEST()
397 pool->releaseBlock(get_block(pool, 0)); in DEF_TEST()
398 REPORTER_ASSERT(r, block_count(pool) == 3); in DEF_TEST()
399 SkDEBUGCODE(pool->validate();) in DEF_TEST()
404 GrSBlockAllocator<256> pool; in DEF_TEST() local
406 pool->headBlock()->setMetadata(1); in DEF_TEST()
407 add_block(pool); in DEF_TEST()
408 add_block(pool); in DEF_TEST()
409 add_block(pool); in DEF_TEST()
413 for (auto* b : pool->blocks()) { in DEF_TEST()
414 pool->releaseBlock(b); in DEF_TEST()
419 REPORTER_ASSERT(r, pool->headBlock()->metadata() == 0); in DEF_TEST()
420 REPORTER_ASSERT(r, block_count(pool) == 1); in DEF_TEST()
423 pool->headBlock()->setMetadata(1); in DEF_TEST()
424 add_block(pool); in DEF_TEST()
425 add_block(pool); in DEF_TEST()
426 add_block(pool); in DEF_TEST()
430 for (auto* b : pool->rblocks()) { in DEF_TEST()
431 pool->releaseBlock(b); in DEF_TEST()
436 REPORTER_ASSERT(r, pool->headBlock()->metadata() == 0); in DEF_TEST()
437 REPORTER_ASSERT(r, block_count(pool) == 1); in DEF_TEST()
441 GrSBlockAllocator<256> pool; in DEF_TEST() local
443 size_t added = add_block(pool); in DEF_TEST()
444 REPORTER_ASSERT(r, pool->testingOnly_scratchBlockSize() == 0); in DEF_TEST()
445 size_t total = pool->totalSize(); in DEF_TEST()
446 pool->releaseBlock(pool->currentBlock()); in DEF_TEST()
449 REPORTER_ASSERT(r, pool->totalSize() == total); in DEF_TEST()
450 REPORTER_ASSERT(r, (size_t) pool->testingOnly_scratchBlockSize() == added); in DEF_TEST()
453 pool->reset(); in DEF_TEST()
454 REPORTER_ASSERT(r, pool->testingOnly_scratchBlockSize() == 0); in DEF_TEST()
457 size_t avail = pool->currentBlock()->avail(); in DEF_TEST()
459 pool->reserve(reserve); in DEF_TEST()
460 REPORTER_ASSERT(r, (size_t) pool->currentBlock()->avail() == avail); in DEF_TEST()
462 REPORTER_ASSERT(r, (size_t) pool->testingOnly_scratchBlockSize() >= reserve && in DEF_TEST()
463 pool->testingOnly_scratchBlockSize() % 256 == 0); in DEF_TEST()
466 size_t preAllocTotalSize = pool->totalSize(); in DEF_TEST()
467 pool->allocate<1>(avail + 1); in DEF_TEST()
468 REPORTER_ASSERT(r, (size_t) pool->testingOnly_scratchBlockSize() == 0); in DEF_TEST()
469 REPORTER_ASSERT(r, pool->totalSize() == preAllocTotalSize); in DEF_TEST()
473 pool->reserve(pool->currentBlock()->avail()); in DEF_TEST()
474 REPORTER_ASSERT(r, pool->testingOnly_scratchBlockSize() == 0); in DEF_TEST()
477 pool->reserve(pool->currentBlock()->avail(), GrBlockAllocator::kIgnoreExistingBytes_Flag); in DEF_TEST()
478 REPORTER_ASSERT(r, pool->testingOnly_scratchBlockSize() > 0); in DEF_TEST()
482 pool->resetScratchSpace(); in DEF_TEST()
483 pool->reserve(32, GrBlockAllocator::kIgnoreGrowthPolicy_Flag); in DEF_TEST()
484 REPORTER_ASSERT(r, pool->testingOnly_scratchBlockSize() > 0 && in DEF_TEST()
485 pool->testingOnly_scratchBlockSize() < 256); in DEF_TEST()
489 GrBlockAllocator::Block* oldTail = pool->currentBlock(); in DEF_TEST()
492 pool->reserve(scratchAvail); in DEF_TEST()
493 REPORTER_ASSERT(r, (size_t) pool->testingOnly_scratchBlockSize() >= scratchAvail); in DEF_TEST()
497 scratchAvail = pool->testingOnly_scratchBlockSize(); in DEF_TEST()
498 pool->allocate<1>(scratchAvail + 1); in DEF_TEST()
499 REPORTER_ASSERT(r, pool->currentBlock() != oldTail); in DEF_TEST()
500 REPORTER_ASSERT(r, (size_t) pool->testingOnly_scratchBlockSize() == scratchAvail); in DEF_TEST()
554 GrSBlockAllocator<1024> pool{}; in DEF_TEST() local
555 SkDEBUGCODE(pool->validate();) in DEF_TEST()
559 auto p1 = pool->allocate<16, sizeof(TestMeta)>(16); in DEF_TEST()
560 SkDEBUGCODE(pool->validate();) in DEF_TEST()
573 auto p2 = pool->allocate<alignof(TestMetaBig), sizeof(TestMetaBig)>(16); in DEF_TEST()
574 SkDEBUGCODE(pool->validate();) in DEF_TEST()
592 GrSBlockAllocator<256> pool{}; in DEF_TEST() local
593 SkDEBUGCODE(pool->validate();) in DEF_TEST()
595 REPORTER_ASSERT(r, pool->metadata() == 0); // initial value in DEF_TEST()
597 pool->setMetadata(4); in DEF_TEST()
598 REPORTER_ASSERT(r, pool->metadata() == 4); in DEF_TEST()
602 pool->releaseBlock(pool->headBlock()); in DEF_TEST()
603 REPORTER_ASSERT(r, pool->metadata() == 4); in DEF_TEST()
606 pool->reset(); in DEF_TEST()
607 REPORTER_ASSERT(r, pool->metadata() == 0); in DEF_TEST()
611 static void run_owning_block_test(skiatest::Reporter* r, GrBlockAllocator* pool) { in run_owning_block_test() argument
612 auto br = pool->allocate<Align, Padding>(1); in run_owning_block_test()
617 Block* block = pool->owningBlock<Align, Padding>(userPtr, br.fStart); in run_owning_block_test()
620 block = pool->owningBlock<Align>(metaPtr, br.fStart); in run_owning_block_test()
628 static void run_owning_block_tests(skiatest::Reporter* r, GrBlockAllocator* pool) { in run_owning_block_tests() argument
629 run_owning_block_test<1, Padding>(r, pool); in run_owning_block_tests()
630 run_owning_block_test<2, Padding>(r, pool); in run_owning_block_tests()
631 run_owning_block_test<4, Padding>(r, pool); in run_owning_block_tests()
632 run_owning_block_test<8, Padding>(r, pool); in run_owning_block_tests()
633 run_owning_block_test<16, Padding>(r, pool); in run_owning_block_tests()
634 run_owning_block_test<32, Padding>(r, pool); in run_owning_block_tests()
635 run_owning_block_test<64, Padding>(r, pool); in run_owning_block_tests()
636 run_owning_block_test<128, Padding>(r, pool); in run_owning_block_tests()
640 GrSBlockAllocator<1024> pool{}; in DEF_TEST() local
641 SkDEBUGCODE(pool->validate();) in DEF_TEST()
643 run_owning_block_tests<1>(r, pool.allocator()); in DEF_TEST()
644 run_owning_block_tests<2>(r, pool.allocator()); in DEF_TEST()
645 run_owning_block_tests<4>(r, pool.allocator()); in DEF_TEST()
646 run_owning_block_tests<8>(r, pool.allocator()); in DEF_TEST()
647 run_owning_block_tests<16>(r, pool.allocator()); in DEF_TEST()
648 run_owning_block_tests<32>(r, pool.allocator()); in DEF_TEST()
651 run_owning_block_tests<3>(r, pool.allocator()); in DEF_TEST()
652 run_owning_block_tests<9>(r, pool.allocator()); in DEF_TEST()
653 run_owning_block_tests<17>(r, pool.allocator()); in DEF_TEST()