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

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: Unset texture and texture_ref after deleting Created 6 years, 8 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 24 matching lines...) Expand all
35 } 35 }
36 36
37 void set_context_lost(bool context_lost) { 37 void set_context_lost(bool context_lost) {
38 context_lost_ = context_lost; 38 context_lost_ = context_lost;
39 } 39 }
40 40
41 private: 41 private:
42 bool context_lost_; 42 bool context_lost_;
43 }; 43 };
44 44
45 namespace {
46 void EmptyPoll() {
47 }
48 }
49
45 class BufferTrackerTest : public testing::Test { 50 class BufferTrackerTest : public testing::Test {
46 protected: 51 protected:
47 static const int32 kNumCommandEntries = 400; 52 static const int32 kNumCommandEntries = 400;
48 static const int32 kCommandBufferSizeBytes = 53 static const int32 kCommandBufferSizeBytes =
49 kNumCommandEntries * sizeof(CommandBufferEntry); 54 kNumCommandEntries * sizeof(CommandBufferEntry);
50 55
51 virtual void SetUp() { 56 virtual void SetUp() {
52 command_buffer_.reset(new MockClientCommandBufferImpl()); 57 command_buffer_.reset(new MockClientCommandBufferImpl());
53 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); 58 helper_.reset(new GLES2CmdHelper(command_buffer_.get()));
54 helper_->Initialize(kCommandBufferSizeBytes); 59 helper_->Initialize(kCommandBufferSizeBytes);
55 mapped_memory_.reset(new MappedMemoryManager( 60 mapped_memory_.reset(new MappedMemoryManager(
56 helper_.get(), MappedMemoryManager::kNoLimit)); 61 helper_.get(), base::Bind(&EmptyPoll), MappedMemoryManager::kNoLimit));
57 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); 62 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get()));
58 } 63 }
59 64
60 virtual void TearDown() { 65 virtual void TearDown() {
61 buffer_tracker_.reset(); 66 buffer_tracker_.reset();
62 mapped_memory_.reset(); 67 mapped_memory_.reset();
63 helper_.reset(); 68 helper_.reset();
64 command_buffer_.reset(); 69 command_buffer_.reset();
65 } 70 }
66 71
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Check mapped memory address. 125 // Check mapped memory address.
121 EXPECT_EQ(64u, buffer->size()); 126 EXPECT_EQ(64u, buffer->size());
122 // Check mapped memory address. 127 // Check mapped memory address.
123 EXPECT_TRUE(buffer->address() == NULL); 128 EXPECT_TRUE(buffer->address() == NULL);
124 // Check no shared memory was allocated. 129 // Check no shared memory was allocated.
125 EXPECT_EQ(0lu, mapped_memory_->num_chunks()); 130 EXPECT_EQ(0lu, mapped_memory_->num_chunks());
126 // Check we can delete the buffer. 131 // Check we can delete the buffer.
127 buffer_tracker_->RemoveBuffer(kId); 132 buffer_tracker_->RemoveBuffer(kId);
128 } 133 }
129 134
135 TEST_F(BufferTrackerTest, Unmanage) {
136 const GLuint kId = 123;
137 const GLsizeiptr size = 64;
138
139 BufferTracker::Buffer* buffer = buffer_tracker_->CreateBuffer(kId, size);
140 ASSERT_TRUE(buffer != NULL);
141 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size));
142
143 void* mem = buffer->address();
144 buffer_tracker_->Unmanage(buffer);
145 buffer_tracker_->RemoveBuffer(kId);
146 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size));
147
148 mapped_memory_->Free(mem);
149 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(0));
150 }
151
130 } // namespace gles2 152 } // namespace gles2
131 } // namespace gpu 153 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/buffer_tracker.cc ('k') | gpu/command_buffer/client/cmd_buffer_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698