Chromium Code Reviews| Index: gpu/command_buffer/client/mapped_memory_unittest.cc |
| diff --git a/gpu/command_buffer/client/mapped_memory_unittest.cc b/gpu/command_buffer/client/mapped_memory_unittest.cc |
| index 99e6e8d3ec27eea55b7c42fbb3cd2b4f160fd55a..4ba1337af9028be4f3afd81b841f094f70ec7a36 100644 |
| --- a/gpu/command_buffer/client/mapped_memory_unittest.cc |
| +++ b/gpu/command_buffer/client/mapped_memory_unittest.cc |
| @@ -306,4 +306,37 @@ TEST_F(MappedMemoryManagerTest, ChunkSizeMultiple) { |
| EXPECT_EQ(0u, offset3); |
| } |
| +TEST_F(MappedMemoryManagerTest, MemoryLimit) { |
| + const unsigned int kSize = 1024; |
| + // Reset the manager with a memory limit. |
| + manager_.reset(new MappedMemoryManager(helper_.get(), 2 * kSize)); |
| + manager_->set_chunk_size_multiple(2 * kSize); |
| + |
| + // Allocate half a chunk worth of memory. |
| + int32 id1 = -1; |
| + unsigned int offset1 = 0xFFFFFFFFU; |
| + void* mem1 = manager_->Alloc(kSize, &id1, &offset1); |
| + ASSERT_TRUE(mem1); |
| + EXPECT_NE(-1, id1); |
| + EXPECT_EQ(0u, offset1); |
| + |
| + // Allocate half a chunk worth of memory again. |
| + // The same chunk will be used. |
| + int32 id2 = -1; |
| + unsigned int offset2 = 0xFFFFFFFFU; |
| + void* mem2 = manager_->Alloc(kSize, &id2, &offset2); |
| + ASSERT_TRUE(mem2); |
| + EXPECT_NE(-1, id2); |
| + EXPECT_EQ(kSize, offset2); |
| + |
| + // Allocate half a chunk worth of memory. Since we reached |
| + // 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.
|
| + int32 id3 = -1; |
| + unsigned int offset3 = 0xFFFFFFFFU; |
| + void* mem3 = manager_->Alloc(kSize, &id3, &offset3); |
| + 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
|
| + EXPECT_NE(-1, id3); |
| + EXPECT_EQ(0u, offset3); |
| +} |
| + |
| } // namespace gpu |