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

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

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Async upload token part of existing Async command; use separate shared memory to sync async upload … 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 // Tests for the BufferTracker. 5 // Tests for the BufferTracker.
6 6
7 #include "gpu/command_buffer/client/buffer_tracker.h" 7 #include "gpu/command_buffer/client/buffer_tracker.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 void set_context_lost(bool context_lost) { 36 void set_context_lost(bool context_lost) {
37 context_lost_ = context_lost; 37 context_lost_ = context_lost;
38 } 38 }
39 39
40 private: 40 private:
41 bool context_lost_; 41 bool context_lost_;
42 }; 42 };
43 43
44 namespace {
45 void EmptyPoll() {
46 }
47 }
48
44 class BufferTrackerTest : public testing::Test { 49 class BufferTrackerTest : public testing::Test {
45 protected: 50 protected:
46 static const int32 kNumCommandEntries = 400; 51 static const int32 kNumCommandEntries = 400;
47 static const int32 kCommandBufferSizeBytes = 52 static const int32 kCommandBufferSizeBytes =
48 kNumCommandEntries * sizeof(CommandBufferEntry); 53 kNumCommandEntries * sizeof(CommandBufferEntry);
49 54
50 virtual void SetUp() { 55 virtual void SetUp() {
51 command_buffer_.reset(new MockClientCommandBufferImpl()); 56 command_buffer_.reset(new MockClientCommandBufferImpl());
52 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); 57 helper_.reset(new GLES2CmdHelper(command_buffer_.get()));
53 helper_->Initialize(kCommandBufferSizeBytes); 58 helper_->Initialize(kCommandBufferSizeBytes);
54 mapped_memory_.reset(new MappedMemoryManager( 59 mapped_memory_.reset(new MappedMemoryManager(
55 helper_.get(), MappedMemoryManager::kNoLimit)); 60 helper_.get(), base::Bind(&EmptyPoll), MappedMemoryManager::kNoLimit));
56 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); 61 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get()));
57 } 62 }
58 63
59 virtual void TearDown() { 64 virtual void TearDown() {
60 buffer_tracker_.reset(); 65 buffer_tracker_.reset();
61 mapped_memory_.reset(); 66 mapped_memory_.reset();
62 helper_.reset(); 67 helper_.reset();
63 command_buffer_.reset(); 68 command_buffer_.reset();
64 } 69 }
65 70
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Check mapped memory address. 124 // Check mapped memory address.
120 EXPECT_EQ(64u, buffer->size()); 125 EXPECT_EQ(64u, buffer->size());
121 // Check mapped memory address. 126 // Check mapped memory address.
122 EXPECT_TRUE(buffer->address() == NULL); 127 EXPECT_TRUE(buffer->address() == NULL);
123 // Check no shared memory was allocated. 128 // Check no shared memory was allocated.
124 EXPECT_EQ(0lu, mapped_memory_->num_chunks()); 129 EXPECT_EQ(0lu, mapped_memory_->num_chunks());
125 // Check we can delete the buffer. 130 // Check we can delete the buffer.
126 buffer_tracker_->RemoveBuffer(kId); 131 buffer_tracker_->RemoveBuffer(kId);
127 } 132 }
128 133
134 TEST_F(BufferTrackerTest, Unmanage) {
135 const GLuint kId = 123;
136 const GLsizeiptr size = 64;
137
138 BufferTracker::Buffer* buffer = buffer_tracker_->CreateBuffer(kId, size);
139 ASSERT_TRUE(buffer != NULL);
140 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size));
141
142 void* mem = buffer->address();
143 buffer_tracker_->Unmanage(buffer);
144 buffer_tracker_->RemoveBuffer(kId);
145 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size));
146
147 mapped_memory_->Free(mem);
148 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(0));
149 }
150
129 } // namespace gles2 151 } // namespace gles2
130 } // namespace gpu 152 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698