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

Side by Side Diff: gpu/command_buffer/client/fenced_allocator_test.cc

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added glWaitAllAsyncTexImage2DCHROMIUM; other review issues addressed Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the tests for the FencedAllocator class. 5 // This file contains the tests for the FencedAllocator class.
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/aligned_memory.h" 9 #include "base/memory/aligned_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; 81 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
82 scoped_ptr<CommandBufferService> command_buffer_; 82 scoped_ptr<CommandBufferService> command_buffer_;
83 scoped_ptr<GpuScheduler> gpu_scheduler_; 83 scoped_ptr<GpuScheduler> gpu_scheduler_;
84 scoped_ptr<CommandBufferHelper> helper_; 84 scoped_ptr<CommandBufferHelper> helper_;
85 }; 85 };
86 86
87 #ifndef _MSC_VER 87 #ifndef _MSC_VER
88 const unsigned int BaseFencedAllocatorTest::kBufferSize; 88 const unsigned int BaseFencedAllocatorTest::kBufferSize;
89 #endif 89 #endif
90 90
91 namespace {
92 void EmptyPoll() {
93 }
94 }
95
91 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a 96 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a
92 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling 97 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling
93 // it directly, not through the RPC mechanism), making sure Noops are ignored 98 // it directly, not through the RPC mechanism), making sure Noops are ignored
94 // and SetToken are properly forwarded to the engine. 99 // and SetToken are properly forwarded to the engine.
95 class FencedAllocatorTest : public BaseFencedAllocatorTest { 100 class FencedAllocatorTest : public BaseFencedAllocatorTest {
96 protected: 101 protected:
97 virtual void SetUp() { 102 virtual void SetUp() {
98 BaseFencedAllocatorTest::SetUp(); 103 BaseFencedAllocatorTest::SetUp();
99 allocator_.reset(new FencedAllocator(kBufferSize, helper_.get())); 104 allocator_.reset(new FencedAllocator(kBufferSize,
105 helper_.get(),
106 base::Bind(&EmptyPoll)));
100 } 107 }
piman 2014/02/20 01:52:37 Could we add a test that exercises the poll featur
101 108
102 virtual void TearDown() { 109 virtual void TearDown() {
103 // If the GpuScheduler posts any tasks, this forces them to run. 110 // If the GpuScheduler posts any tasks, this forces them to run.
104 base::MessageLoop::current()->RunUntilIdle(); 111 base::MessageLoop::current()->RunUntilIdle();
105 112
106 EXPECT_TRUE(allocator_->CheckConsistency()); 113 EXPECT_TRUE(allocator_->CheckConsistency());
107 114
108 BaseFencedAllocatorTest::TearDown(); 115 BaseFencedAllocatorTest::TearDown();
109 } 116 }
110 117
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 class FencedAllocatorWrapperTest : public BaseFencedAllocatorTest { 406 class FencedAllocatorWrapperTest : public BaseFencedAllocatorTest {
400 protected: 407 protected:
401 virtual void SetUp() { 408 virtual void SetUp() {
402 BaseFencedAllocatorTest::SetUp(); 409 BaseFencedAllocatorTest::SetUp();
403 410
404 // Though allocating this buffer isn't strictly necessary, it makes 411 // Though allocating this buffer isn't strictly necessary, it makes
405 // allocations point to valid addresses, so they could be used for 412 // allocations point to valid addresses, so they could be used for
406 // something. 413 // something.
407 buffer_.reset(static_cast<char*>(base::AlignedAlloc( 414 buffer_.reset(static_cast<char*>(base::AlignedAlloc(
408 kBufferSize, kAllocAlignment))); 415 kBufferSize, kAllocAlignment)));
409 allocator_.reset(new FencedAllocatorWrapper(kBufferSize, helper_.get(), 416 allocator_.reset(new FencedAllocatorWrapper(kBufferSize,
417 helper_.get(),
418 base::Bind(&EmptyPoll),
410 buffer_.get())); 419 buffer_.get()));
411 } 420 }
412 421
413 virtual void TearDown() { 422 virtual void TearDown() {
414 // If the GpuScheduler posts any tasks, this forces them to run. 423 // If the GpuScheduler posts any tasks, this forces them to run.
415 base::MessageLoop::current()->RunUntilIdle(); 424 base::MessageLoop::current()->RunUntilIdle();
416 425
417 EXPECT_TRUE(allocator_->CheckConsistency()); 426 EXPECT_TRUE(allocator_->CheckConsistency());
418 427
419 BaseFencedAllocatorTest::TearDown(); 428 BaseFencedAllocatorTest::TearDown();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 EXPECT_LE(token, GetToken()); 578 EXPECT_LE(token, GetToken());
570 579
571 // Free up everything. 580 // Free up everything.
572 for (unsigned int i = 0; i < kAllocCount; ++i) { 581 for (unsigned int i = 0; i < kAllocCount; ++i) {
573 allocator_->Free(pointers[i]); 582 allocator_->Free(pointers[i]);
574 EXPECT_TRUE(allocator_->CheckConsistency()); 583 EXPECT_TRUE(allocator_->CheckConsistency());
575 } 584 }
576 } 585 }
577 586
578 } // namespace gpu 587 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698