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

Unified Diff: gpu/command_buffer/client/mapped_memory_unittest.cc

Issue 1168853002: Use mapped memory for uploading large textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added dcheck and improved other error messages Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | gpu/command_buffer/client/ring_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6430b667d3f4c7683ade442d208ae246040f45bf..20b4c532f354af02039caf565f6a4c88de93b1e5 100644
--- a/gpu/command_buffer/client/mapped_memory_unittest.cc
+++ b/gpu/command_buffer/client/mapped_memory_unittest.cc
@@ -394,6 +394,54 @@ TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) {
manager_->Free(mem3);
}
+TEST_F(MappedMemoryManagerTest, MaxAllocationTest) {
+ const unsigned int kSize = 1024;
+ // Reset the manager with a memory limit.
+ manager_.reset(new MappedMemoryManager(
+ helper_.get(), base::Bind(&EmptyPoll), kSize));
+
+ const size_t kLimit = 512;
+ manager_->set_chunk_size_multiple(kLimit);
+
+ // Allocate twice the limit worth of memory (currently unbounded).
+ int32 id1 = -1;
+ unsigned int offset1 = 0xFFFFFFFFU;
+ void* mem1 = manager_->Alloc(kLimit, &id1, &offset1);
+ ASSERT_TRUE(mem1);
+ EXPECT_NE(-1, id1);
+ EXPECT_EQ(0u, offset1);
+
+ int32 id2 = -1;
+ unsigned int offset2 = 0xFFFFFFFFU;
+ void* mem2 = manager_->Alloc(kLimit, &id2, &offset2);
+ ASSERT_TRUE(mem2);
+ EXPECT_NE(-1, id2);
+ EXPECT_EQ(0u, offset2);
+
+ manager_->set_max_allocated_bytes(kLimit);
+
+ // A new allocation should now fail.
+ int32 id3 = -1;
+ unsigned int offset3 = 0xFFFFFFFFU;
+ void* mem3 = manager_->Alloc(kLimit, &id3, &offset3);
+ ASSERT_FALSE(mem3);
+ EXPECT_EQ(-1, id3);
+ EXPECT_EQ(0xFFFFFFFFU, offset3);
+
+ manager_->Free(mem2);
+
+ // New allocation is over the limit but should reuse allocated space
+ int32 id4 = -1;
+ unsigned int offset4 = 0xFFFFFFFFU;
+ void* mem4 = manager_->Alloc(kLimit, &id4, &offset4);
+ ASSERT_TRUE(mem4);
+ EXPECT_EQ(id2, id4);
+ EXPECT_EQ(offset2, offset4);
+
+ manager_->Free(mem1);
+ manager_->Free(mem4);
+}
+
namespace {
void Poll(MappedMemoryManagerTest *test, std::list<void*>* list) {
std::list<void*>::iterator it = list->begin();
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | gpu/command_buffer/client/ring_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698