diff options
author | jadahl@opera.com <jadahl@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-16 11:41:38 +0000 |
---|---|---|
committer | jadahl@opera.com <jadahl@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-16 11:41:38 +0000 |
commit | 535a985a5e496e9e25fb2f5591b0418e403c5c92 (patch) | |
tree | 5be6f1435d4ee6743da8470e1f1315110f4933e0 /gpu | |
parent | 14a3735da78b165aec9c8b219042d814621518de (diff) | |
download | chromium_src-535a985a5e496e9e25fb2f5591b0418e403c5c92.zip chromium_src-535a985a5e496e9e25fb2f5591b0418e403c5c92.tar.gz chromium_src-535a985a5e496e9e25fb2f5591b0418e403c5c92.tar.bz2 |
gpu: Assert that FencedAllocator is empty in destructor
With the commit "gpu: Reuse transfer buffers more aggresively" mapped
memory is free:ed on lost context. This means that we can reinstate the
DCHECKs in the FencedAllocator destructor that checks that all blocks
have been free:ed by their owner.
Tests that didn't explicitly free mapped memory now do so, and one test
that tested that leaking was OK has been removed.
BUG=328808
Review URL: https://codereview.chromium.org/282513003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/mapped_memory_unittest.cc | 20 |
3 files changed, 17 insertions, 15 deletions
diff --git a/gpu/command_buffer/client/fenced_allocator.cc b/gpu/command_buffer/client/fenced_allocator.cc index 4e405e9..8003857 100644 --- a/gpu/command_buffer/client/fenced_allocator.cc +++ b/gpu/command_buffer/client/fenced_allocator.cc @@ -50,9 +50,9 @@ FencedAllocator::~FencedAllocator() { i = WaitForTokenAndFreeBlock(i); } } - // These checks are not valid if the service has crashed or lost the context. - // DCHECK_EQ(blocks_.size(), 1u); - // DCHECK_EQ(blocks_[0].state, FREE); + + DCHECK_EQ(blocks_.size(), 1u); + DCHECK_EQ(blocks_[0].state, FREE); } // Looks for a non-allocated block that is big enough. Search in the FREE diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index f7fbca4..a35f1f9 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -3275,9 +3275,11 @@ TEST_F(GLES2ImplementationTest, LimitSizeAndOffsetTo32Bit) { EXPECT_STREQ(kSizeOverflowMessage, GetLastError().c_str()); // Call MapBufferSubDataCHROMIUM() should succeed with legal paramaters. - EXPECT_TRUE(NULL != gl_->MapBufferSubDataCHROMIUM( - GL_ARRAY_BUFFER, 0, 1, GL_WRITE_ONLY)); + void* mem = + gl_->MapBufferSubDataCHROMIUM(GL_ARRAY_BUFFER, 0, 1, GL_WRITE_ONLY); + EXPECT_TRUE(NULL != mem); EXPECT_EQ(GL_NO_ERROR, CheckError()); + gl_->UnmapBufferSubDataCHROMIUM(mem); // MapBufferSubDataCHROMIUM: offset EXPECT_TRUE(NULL == gl_->MapBufferSubDataCHROMIUM( diff --git a/gpu/command_buffer/client/mapped_memory_unittest.cc b/gpu/command_buffer/client/mapped_memory_unittest.cc index a7dcf9e..2f3a9e7 100644 --- a/gpu/command_buffer/client/mapped_memory_unittest.cc +++ b/gpu/command_buffer/client/mapped_memory_unittest.cc @@ -268,16 +268,6 @@ TEST_F(MappedMemoryManagerTest, FreePendingToken) { } } -// Check if we don't free we don't crash. -TEST_F(MappedMemoryManagerTest, DontFree) { - const unsigned int kSize = 1024; - // Check we can alloc. - int32 id1 = -1; - unsigned int offset1 = 0xFFFFFFFFU; - void* mem1 = manager_->Alloc(kSize, &id1, &offset1); - ASSERT_TRUE(mem1); -} - TEST_F(MappedMemoryManagerTest, FreeUnused) { int32 id = -1; unsigned int offset = 0xFFFFFFFFU; @@ -321,6 +311,10 @@ TEST_F(MappedMemoryManagerTest, ChunkSizeMultiple) { EXPECT_EQ(0u, offset1); EXPECT_EQ(kSize, offset2); EXPECT_EQ(0u, offset3); + + manager_->Free(mem1); + manager_->Free(mem2); + manager_->Free(mem3); } TEST_F(MappedMemoryManagerTest, UnusedMemoryLimit) { @@ -350,6 +344,9 @@ TEST_F(MappedMemoryManagerTest, UnusedMemoryLimit) { // Expect two chunks to be allocated, exceeding the limit, // since all memory is in use. EXPECT_EQ(2 * kChunkSize, manager_->allocated_memory()); + + manager_->Free(mem1); + manager_->Free(mem2); } TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) { @@ -400,6 +397,9 @@ TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) { // Expect one chunk to be allocated EXPECT_EQ(1 * kChunkSize, manager_->allocated_memory()); + + manager_->Free(mem1); + manager_->Free(mem3); } namespace { |