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

Unified Diff: gpu/command_buffer/service/transfer_buffer_manager.cc

Issue 2575803002: Bug fix: TranferBufferManager's SharedMemory memory usage reporting was wrong (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/common/buffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/transfer_buffer_manager.cc
diff --git a/gpu/command_buffer/service/transfer_buffer_manager.cc b/gpu/command_buffer/service/transfer_buffer_manager.cc
index 9f583b9f656cee8958219f7c84253323e3d1bbb2..8fd4050d04b96b5d0822254913716e5fa7eabe7d 100644
--- a/gpu/command_buffer/service/transfer_buffer_manager.cc
+++ b/gpu/command_buffer/service/transfer_buffer_manager.cc
@@ -35,8 +35,10 @@ TransferBufferManager::TransferBufferManager(
TransferBufferManager::~TransferBufferManager() {
while (!registered_buffers_.empty()) {
BufferMap::iterator it = registered_buffers_.begin();
- DCHECK(shared_memory_bytes_allocated_ >= it->second->size());
- shared_memory_bytes_allocated_ -= it->second->size();
+ if (it->second->backing()->is_shared()) {
+ DCHECK(shared_memory_bytes_allocated_ >= it->second->size());
+ shared_memory_bytes_allocated_ -= it->second->size();
+ }
registered_buffers_.erase(it);
}
DCHECK(!shared_memory_bytes_allocated_);
@@ -77,8 +79,8 @@ bool TransferBufferManager::RegisterTransferBuffer(
DCHECK(!(reinterpret_cast<uintptr_t>(buffer->memory()) &
(kCommandBufferEntrySize - 1)));
- shared_memory_bytes_allocated_ += buffer->size();
-
+ if (buffer->backing()->is_shared())
+ shared_memory_bytes_allocated_ += buffer->size();
registered_buffers_[id] = buffer;
return true;
@@ -91,9 +93,10 @@ void TransferBufferManager::DestroyTransferBuffer(int32_t id) {
return;
}
- DCHECK(shared_memory_bytes_allocated_ >= it->second->size());
- shared_memory_bytes_allocated_ -= it->second->size();
-
+ if (it->second->backing()->is_shared()) {
+ DCHECK(shared_memory_bytes_allocated_ >= it->second->size());
+ shared_memory_bytes_allocated_ -= it->second->size();
+ }
registered_buffers_.erase(it);
}
@@ -135,10 +138,12 @@ bool TransferBufferManager::OnMemoryDump(
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, buffer->size());
- auto guid =
- GetBufferGUIDForTracing(memory_tracker_->ClientTracingId(), buffer_id);
- pmd->CreateSharedGlobalAllocatorDump(guid);
- pmd->AddOwnershipEdge(dump->guid(), guid);
+ if (buffer->backing()->is_shared()) {
+ auto guid = GetBufferGUIDForTracing(memory_tracker_->ClientTracingId(),
+ buffer_id);
+ pmd->CreateSharedGlobalAllocatorDump(guid);
+ pmd->AddOwnershipEdge(dump->guid(), guid);
+ }
}
return true;
« no previous file with comments | « gpu/command_buffer/common/buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698