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

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

Issue 23130004: Enforce a memory limit on MappedMemoryManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused enum Created 7 years, 4 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 #include "gpu/command_buffer/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 ASSERT_TRUE(mem2); 299 ASSERT_TRUE(mem2);
300 ASSERT_TRUE(mem3); 300 ASSERT_TRUE(mem3);
301 EXPECT_NE(-1, id1); 301 EXPECT_NE(-1, id1);
302 EXPECT_EQ(id1, id2); 302 EXPECT_EQ(id1, id2);
303 EXPECT_NE(id2, id3); 303 EXPECT_NE(id2, id3);
304 EXPECT_EQ(0u, offset1); 304 EXPECT_EQ(0u, offset1);
305 EXPECT_EQ(kSize, offset2); 305 EXPECT_EQ(kSize, offset2);
306 EXPECT_EQ(0u, offset3); 306 EXPECT_EQ(0u, offset3);
307 } 307 }
308 308
309 TEST_F(MappedMemoryManagerTest, MemoryLimit) {
310 const unsigned int kSize = 1024;
311 // Reset the manager with a memory limit.
312 manager_.reset(new MappedMemoryManager(helper_.get(), 2 * kSize));
313 manager_->set_chunk_size_multiple(2 * kSize);
314
315 // Allocate half a chunk worth of memory.
316 int32 id1 = -1;
317 unsigned int offset1 = 0xFFFFFFFFU;
318 void* mem1 = manager_->Alloc(kSize, &id1, &offset1);
319 ASSERT_TRUE(mem1);
320 EXPECT_NE(-1, id1);
321 EXPECT_EQ(0u, offset1);
322
323 // Allocate half a chunk worth of memory again.
324 // The same chunk will be used.
325 int32 id2 = -1;
326 unsigned int offset2 = 0xFFFFFFFFU;
327 void* mem2 = manager_->Alloc(kSize, &id2, &offset2);
328 ASSERT_TRUE(mem2);
329 EXPECT_NE(-1, id2);
330 EXPECT_EQ(kSize, offset2);
331
332 // Allocate half a chunk worth of memory. Since we reached
333 // the memory limit we'll wait tokens on existing chunks.
piman 2013/08/15 02:49:03 Wait for what token? You didn't free anything pend
kaanb 2013/08/16 22:50:44 Done.
334 int32 id3 = -1;
335 unsigned int offset3 = 0xFFFFFFFFU;
336 void* mem3 = manager_->Alloc(kSize, &id3, &offset3);
337 ASSERT_TRUE(mem3);
no sievers 2013/08/15 01:43:42 I think this test shows that your patch does not n
no sievers 2013/08/15 01:49:06 Btw, which usage case are you trying to optimize a
kaanb 2013/08/16 22:50:44 Done.
kaanb 2013/08/16 22:50:44 I think this optimization is oblivious to whether
338 EXPECT_NE(-1, id3);
339 EXPECT_EQ(0u, offset3);
340 }
341
309 } // namespace gpu 342 } // namespace gpu
OLDNEW
« gpu/command_buffer/client/mapped_memory.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