| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 name.c_str(), | 69 name.c_str(), |
| 70 local_trace_id_, | 70 local_trace_id_, |
| 71 named_thread_.thread_id(), | 71 named_thread_.thread_id(), |
| 72 end_time, | 72 end_time, |
| 73 "gl_category", | 73 "gl_category", |
| 74 category.c_str()); | 74 category.c_str()); |
| 75 ++local_trace_id_; | 75 ++local_trace_id_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void TraceOutputter::TraceServiceBegin(const std::string& category, | 78 void TraceOutputter::TraceServiceBegin(const std::string& category, |
| 79 const std::string& name, | 79 const std::string& name) { |
| 80 void* id) { | 80 TRACE_EVENT_COPY_BEGIN1(TRACE_DISABLED_BY_DEFAULT("gpu.service"), |
| 81 TRACE_EVENT_COPY_ASYNC_BEGIN1(TRACE_DISABLED_BY_DEFAULT("gpu.service"), | 81 name.c_str(), "gl_category", category.c_str()); |
| 82 name.c_str(), this, | |
| 83 "gl_category", category.c_str()); | |
| 84 } | 82 } |
| 85 | 83 |
| 86 void TraceOutputter::TraceServiceEnd(const std::string& category, | 84 void TraceOutputter::TraceServiceEnd(const std::string& category, |
| 87 const std::string& name, | 85 const std::string& name) { |
| 88 void* id) { | 86 TRACE_EVENT_COPY_END1(TRACE_DISABLED_BY_DEFAULT("gpu.service"), |
| 89 TRACE_EVENT_COPY_ASYNC_END1(TRACE_DISABLED_BY_DEFAULT("gpu.service"), | 87 name.c_str(), "gl_category", category.c_str()); |
| 90 name.c_str(), this, | |
| 91 "gl_category", category.c_str()); | |
| 92 } | 88 } |
| 93 | 89 |
| 94 GPUTrace::GPUTrace(scoped_refptr<Outputter> outputter, | 90 GPUTrace::GPUTrace(scoped_refptr<Outputter> outputter, |
| 95 scoped_refptr<CPUTime> cpu_time, | 91 scoped_refptr<CPUTime> cpu_time, |
| 96 const std::string& category, | 92 const std::string& category, |
| 97 const std::string& name, | 93 const std::string& name, |
| 98 int64 offset, | 94 int64 offset, |
| 99 GpuTracerType tracer_type) | 95 GpuTracerType tracer_type) |
| 100 : category_(category), | 96 : category_(category), |
| 101 name_(name), | 97 name_(name), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 125 | 121 |
| 126 case kTracerTypeARBTimer: | 122 case kTracerTypeARBTimer: |
| 127 case kTracerTypeDisjointTimer: | 123 case kTracerTypeDisjointTimer: |
| 128 glDeleteQueriesARB(2, queries_); | 124 glDeleteQueriesARB(2, queries_); |
| 129 break; | 125 break; |
| 130 } | 126 } |
| 131 } | 127 } |
| 132 | 128 |
| 133 void GPUTrace::Start(bool trace_service) { | 129 void GPUTrace::Start(bool trace_service) { |
| 134 if (trace_service) { | 130 if (trace_service) { |
| 135 outputter_->TraceServiceBegin(category_, name_, this); | 131 outputter_->TraceServiceBegin(category_, name_); |
| 136 } | 132 } |
| 137 | 133 |
| 138 switch (tracer_type_) { | 134 switch (tracer_type_) { |
| 139 case kTracerTypeInvalid: | 135 case kTracerTypeInvalid: |
| 140 break; | 136 break; |
| 141 | 137 |
| 142 case kTracerTypeDisjointTimer: | 138 case kTracerTypeDisjointTimer: |
| 143 // For the disjoint timer, GPU idle time does not seem to increment the | 139 // For the disjoint timer, GPU idle time does not seem to increment the |
| 144 // internal counter. We must calculate the offset before any query. The | 140 // internal counter. We must calculate the offset before any query. The |
| 145 // good news is any device that supports disjoint timer will also support | 141 // good news is any device that supports disjoint timer will also support |
| (...skipping 21 matching lines...) Expand all Loading... |
| 167 break; | 163 break; |
| 168 | 164 |
| 169 case kTracerTypeARBTimer: | 165 case kTracerTypeARBTimer: |
| 170 case kTracerTypeDisjointTimer: | 166 case kTracerTypeDisjointTimer: |
| 171 // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value. | 167 // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value. |
| 172 glQueryCounter(queries_[1], GL_TIMESTAMP); | 168 glQueryCounter(queries_[1], GL_TIMESTAMP); |
| 173 break; | 169 break; |
| 174 } | 170 } |
| 175 | 171 |
| 176 if (tracing_service) { | 172 if (tracing_service) { |
| 177 outputter_->TraceServiceEnd(category_, name_, this); | 173 outputter_->TraceServiceEnd(category_, name_); |
| 178 } | 174 } |
| 179 } | 175 } |
| 180 | 176 |
| 181 bool GPUTrace::IsAvailable() { | 177 bool GPUTrace::IsAvailable() { |
| 182 if (tracer_type_ != kTracerTypeInvalid) { | 178 if (tracer_type_ != kTracerTypeInvalid) { |
| 183 if (!end_requested_) | 179 if (!end_requested_) |
| 184 return false; | 180 return false; |
| 185 | 181 |
| 186 GLint done = 0; | 182 GLint done = 0; |
| 187 glGetQueryObjectiv(queries_[1], GL_QUERY_RESULT_AVAILABLE, &done); | 183 glGetQueryObjectiv(queries_[1], GL_QUERY_RESULT_AVAILABLE, &done); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 void GPUTracer::IssueProcessTask() { | 481 void GPUTracer::IssueProcessTask() { |
| 486 if (traces_.empty() || process_posted_) | 482 if (traces_.empty() || process_posted_) |
| 487 return; | 483 return; |
| 488 | 484 |
| 489 process_posted_ = true; | 485 process_posted_ = true; |
| 490 PostTask(); | 486 PostTask(); |
| 491 } | 487 } |
| 492 | 488 |
| 493 } // namespace gles2 | 489 } // namespace gles2 |
| 494 } // namespace gpu | 490 } // namespace gpu |
| OLD | NEW |