OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gpu_tracer.h" | 5 #include "gpu/command_buffer/service/gpu_tracer.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 void TraceOutputter::TraceDevice(GpuTracerSource source, | 60 void TraceOutputter::TraceDevice(GpuTracerSource source, |
61 const std::string& category, | 61 const std::string& category, |
62 const std::string& name, | 62 const std::string& name, |
63 int64 start_time, | 63 int64 start_time, |
64 int64 end_time) { | 64 int64 end_time) { |
65 DCHECK(source >= 0 && source < NUM_TRACER_SOURCES); | 65 DCHECK(source >= 0 && source < NUM_TRACER_SOURCES); |
66 TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP2( | 66 TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP2( |
67 TRACE_DISABLED_BY_DEFAULT("gpu.device"), | 67 TRACE_DISABLED_BY_DEFAULT("gpu.device"), |
68 name.c_str(), | 68 name.c_str(), |
69 static_cast<int>(source), | 69 local_trace_device_id_, |
70 named_thread_.thread_id(), | 70 named_thread_.thread_id(), |
71 start_time, | 71 start_time, |
72 "gl_category", | 72 "gl_category", |
73 category.c_str(), | 73 category.c_str(), |
74 "channel", | 74 "channel", |
75 kGpuTraceSourceNames[source]); | 75 kGpuTraceSourceNames[source]); |
76 TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP2( | 76 TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP2( |
77 TRACE_DISABLED_BY_DEFAULT("gpu.device"), | 77 TRACE_DISABLED_BY_DEFAULT("gpu.device"), |
78 name.c_str(), | 78 name.c_str(), |
79 static_cast<int>(source), | 79 local_trace_device_id_, |
80 named_thread_.thread_id(), | 80 named_thread_.thread_id(), |
81 end_time, | 81 end_time, |
82 "gl_category", | 82 "gl_category", |
83 category.c_str(), | 83 category.c_str(), |
84 "channel", | 84 "channel", |
85 kGpuTraceSourceNames[source]); | 85 kGpuTraceSourceNames[source]); |
| 86 ++local_trace_device_id_; |
86 } | 87 } |
87 | 88 |
88 void TraceOutputter::TraceServiceBegin(GpuTracerSource source, | 89 void TraceOutputter::TraceServiceBegin(GpuTracerSource source, |
89 const std::string& category, | 90 const std::string& category, |
90 const std::string& name) { | 91 const std::string& name) { |
91 DCHECK(source >= 0 && source < NUM_TRACER_SOURCES); | 92 DCHECK(source >= 0 && source < NUM_TRACER_SOURCES); |
92 TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2( | 93 TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2( |
93 TRACE_DISABLED_BY_DEFAULT("gpu.service"), | 94 TRACE_DISABLED_BY_DEFAULT("gpu.service"), |
94 name.c_str(), static_cast<int>(source), | 95 name.c_str(), local_trace_service_id_, |
95 "gl_category", category.c_str(), | 96 "gl_category", category.c_str(), |
96 "channel", kGpuTraceSourceNames[source]); | 97 "channel", kGpuTraceSourceNames[source]); |
| 98 |
| 99 trace_service_id_stack_[source].push(local_trace_service_id_); |
| 100 ++local_trace_service_id_; |
97 } | 101 } |
98 | 102 |
99 void TraceOutputter::TraceServiceEnd(GpuTracerSource source, | 103 void TraceOutputter::TraceServiceEnd(GpuTracerSource source, |
100 const std::string& category, | 104 const std::string& category, |
101 const std::string& name) { | 105 const std::string& name) { |
102 DCHECK(source >= 0 && source < NUM_TRACER_SOURCES); | 106 DCHECK(source >= 0 && source < NUM_TRACER_SOURCES); |
| 107 DCHECK(!trace_service_id_stack_[source].empty()); |
| 108 const uint64 local_trace_id = trace_service_id_stack_[source].top(); |
| 109 trace_service_id_stack_[source].pop(); |
| 110 |
103 TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2( | 111 TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2( |
104 TRACE_DISABLED_BY_DEFAULT("gpu.service"), | 112 TRACE_DISABLED_BY_DEFAULT("gpu.service"), |
105 name.c_str(), static_cast<int>(source), | 113 name.c_str(), local_trace_id, |
106 "gl_category", category.c_str(), | 114 "gl_category", category.c_str(), |
107 "channel", kGpuTraceSourceNames[source]); | 115 "channel", kGpuTraceSourceNames[source]); |
108 } | 116 } |
109 | 117 |
110 GPUTrace::GPUTrace(scoped_refptr<Outputter> outputter, | 118 GPUTrace::GPUTrace(scoped_refptr<Outputter> outputter, |
111 gfx::GPUTimingClient* gpu_timing_client, | 119 gfx::GPUTimingClient* gpu_timing_client, |
112 const GpuTracerSource source, | 120 const GpuTracerSource source, |
113 const std::string& category, | 121 const std::string& category, |
114 const std::string& name, | 122 const std::string& name, |
115 const bool tracing_service, | 123 const bool tracing_service, |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 void GPUTracer::IssueProcessTask() { | 406 void GPUTracer::IssueProcessTask() { |
399 if (finished_traces_.empty() || process_posted_) | 407 if (finished_traces_.empty() || process_posted_) |
400 return; | 408 return; |
401 | 409 |
402 process_posted_ = true; | 410 process_posted_ = true; |
403 PostTask(); | 411 PostTask(); |
404 } | 412 } |
405 | 413 |
406 } // namespace gles2 | 414 } // namespace gles2 |
407 } // namespace gpu | 415 } // namespace gpu |
OLD | NEW |