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

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

Issue 1256613002: Add tracing for GL texture objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_process_id
Patch Set: review feedback Created 5 years, 5 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
Index: gpu/command_buffer/service/texture_manager.cc
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index c7150ee98eee936d0c174cd9246505cbc691eefe..f1016fbb393866954949d34051639903c26727b8 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -11,6 +11,8 @@
#include "base/bits.h"
#include "base/lazy_instance.h"
#include "base/strings/stringprintf.h"
+#include "base/thread_task_runner_handle.h"
+#include "base/trace_event/memory_dump_manager.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/context_state.h"
#include "gpu/command_buffer/service/error_state.h"
@@ -20,6 +22,7 @@
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "ui/gl/gl_implementation.h"
+#include "ui/gl/trace_util.h"
namespace gpu {
namespace gles2 {
@@ -283,6 +286,9 @@ TextureManager::~TextureManager() {
DCHECK_EQ(0, num_unsafe_textures_);
DCHECK_EQ(0, num_uncleared_mips_);
DCHECK_EQ(0, num_images_);
+
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
}
void TextureManager::Destroy(bool have_context) {
@@ -1324,6 +1330,7 @@ TextureManager::TextureManager(MemoryTracker* memory_tracker,
new MemoryTypeTracker(memory_tracker, MemoryTracker::kManaged)),
memory_tracker_unmanaged_(
new MemoryTypeTracker(memory_tracker, MemoryTracker::kUnmanaged)),
+ memory_tracker_(memory_tracker),
feature_info_(feature_info),
framebuffer_manager_(NULL),
max_texture_size_(max_texture_size),
@@ -1375,6 +1382,9 @@ bool TextureManager::Initialize() {
GL_TEXTURE_RECTANGLE_ARB, &black_texture_ids_[kRectangleARB]);
}
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this, base::ThreadTaskRunnerHandle::Get());
+
return true;
}
@@ -2027,5 +2037,47 @@ ScopedTextureUploadTimer::~ScopedTextureUploadTimer() {
base::TimeTicks::Now() - begin_time_;
}
+bool TextureManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) {
+ for (const auto& resource : textures_) {
+ // Only dump memory info for textures actually owned by this TextureManager.
ssid 2015/07/29 11:17:44 textures 'is'?
petrcermak 2015/07/29 16:13:35 I think it's correct as is.
+ if (resource.second == resource.second->texture()->memory_tracking_ref_) {
+ DumpTextureRef(pmd, resource.second.get());
+ }
+ }
+
+ // Also dump TextureManager internal textures, if allocated.
+ for (int i = 0; i < kNumDefaultTextures; i++) {
+ if (default_textures_[i]) {
+ DumpTextureRef(pmd, default_textures_[i].get());
+ }
+ }
+
+ return true;
+}
+
+void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd,
+ TextureRef* ref) {
+ uint32_t size = ref->texture()->estimated_size();
+
+ // Ignore unallocated texture IDs.
+ if (size == 0)
+ return;
+
+ std::string dump_name =
+ base::StringPrintf("gl/textures/client_%d/texture_%d",
+ memory_tracker_->client_id(), ref->client_id());
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump(dump_name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ static_cast<uint64_t>(size));
+
+ // Add GUID info for shared ownership with client process.
+ auto guid = gfx::GetGLTextureGUIDForTracing(
reveman 2015/07/28 21:38:49 what if the texture is backed by a GLImage? I thin
ericrk 2015/07/29 18:46:47 Going to save this for a follow-up CL. Added a TOD
+ memory_tracker_->ClientTracingId(), ref->client_id());
+ pmd->CreateSharedGlobalAllocatorDump(guid);
+ pmd->AddOwnershipEdge(dump->guid(), guid);
+}
+
} // namespace gles2
} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698