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

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

Issue 11419280: Make FencedAlloctor fail on size = 0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add separate zero allocation tracking Created 8 years 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 | Annotate | Revision Log
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 #include "gpu/command_buffer/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 9 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
10 #include "gpu/command_buffer/service/mocks.h" 10 #include "gpu/command_buffer/service/mocks.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 ASSERT_TRUE(mem5 != NULL); 198 ASSERT_TRUE(mem5 != NULL);
199 EXPECT_EQ(id3, id4); 199 EXPECT_EQ(id3, id4);
200 EXPECT_EQ(id4, id5); 200 EXPECT_EQ(id4, id5);
201 EXPECT_EQ(0u, offset4); 201 EXPECT_EQ(0u, offset4);
202 EXPECT_EQ(kSize / 2u, offset5); 202 EXPECT_EQ(kSize / 2u, offset5);
203 manager_->Free(mem4); 203 manager_->Free(mem4);
204 manager_->Free(mem2); 204 manager_->Free(mem2);
205 manager_->Free(mem5); 205 manager_->Free(mem5);
206 } 206 }
207 207
208 TEST_F(MappedMemoryManagerTest, AllocZero) {
209 int32 id = -1;
210 unsigned int offset = 0xFFFFFFFFU;
211 void* mem = manager_->Alloc(0, &id, &offset);
212 ASSERT_TRUE(mem);
213 EXPECT_NE(-1, id);
214 EXPECT_EQ(0u, offset);
215 manager_->Free(mem);
216
217 id = -1;
218 offset = 0xFFFFFFFFU;
219 mem = manager_->Alloc(0, &id, &offset);
220
221 int32 token = helper_.get()->InsertToken();
222 manager_->FreePendingToken(mem, token);
223 EXPECT_GT(token, GetToken());
224 helper_->Finish();
225 }
226
208 TEST_F(MappedMemoryManagerTest, FreePendingToken) { 227 TEST_F(MappedMemoryManagerTest, FreePendingToken) {
209 const unsigned int kSize = 128; 228 const unsigned int kSize = 128;
210 const unsigned int kAllocCount = (kBufferSize / kSize) * 2; 229 const unsigned int kAllocCount = (kBufferSize / kSize) * 2;
211 CHECK(kAllocCount * kSize == kBufferSize * 2); 230 CHECK(kAllocCount * kSize == kBufferSize * 2);
212 231
213 // Allocate several buffers across multiple chunks. 232 // Allocate several buffers across multiple chunks.
214 void *pointers[kAllocCount]; 233 void *pointers[kAllocCount];
215 for (unsigned int i = 0; i < kAllocCount; ++i) { 234 for (unsigned int i = 0; i < kAllocCount; ++i) {
216 int32 id = -1; 235 int32 id = -1;
217 unsigned int offset = 0xFFFFFFFFu; 236 unsigned int offset = 0xFFFFFFFFu;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 ASSERT_TRUE(mem3); 318 ASSERT_TRUE(mem3);
300 EXPECT_NE(-1, id1); 319 EXPECT_NE(-1, id1);
301 EXPECT_EQ(id1, id2); 320 EXPECT_EQ(id1, id2);
302 EXPECT_NE(id2, id3); 321 EXPECT_NE(id2, id3);
303 EXPECT_EQ(0u, offset1); 322 EXPECT_EQ(0u, offset1);
304 EXPECT_EQ(kSize, offset2); 323 EXPECT_EQ(kSize, offset2);
305 EXPECT_EQ(0u, offset3); 324 EXPECT_EQ(0u, offset3);
306 } 325 }
307 326
308 } // namespace gpu 327 } // namespace gpu
OLDNEW
« gpu/command_buffer/client/fenced_allocator.cc ('K') | « gpu/command_buffer/client/mapped_memory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698