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 // This file contains the GPUTrace class. | 5 // This file contains the GPUTrace class. |
6 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 6 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
7 #define GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 7 #define GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
16 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
17 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
18 | 18 |
19 namespace gpu { | 19 namespace gpu { |
20 namespace gles2 { | 20 namespace gles2 { |
21 | 21 |
| 22 class Outputter; |
| 23 class GPUTrace; |
| 24 |
22 // Id used to keep trace namespaces separate | 25 // Id used to keep trace namespaces separate |
23 enum GpuTracerSource { | 26 enum GpuTracerSource { |
| 27 kTraceGroupInvalid = -1, |
| 28 |
24 kTraceGroupMarker = 0, | 29 kTraceGroupMarker = 0, |
25 kTraceCHROMIUM = 1, | 30 kTraceCHROMIUM = 1, |
26 kTraceDecoder = 2, | 31 kTraceDecoder = 2, |
| 32 |
| 33 NUM_TRACER_SOURCES |
| 34 }; |
| 35 |
| 36 // Marker structure for a Trace. |
| 37 struct TraceMarker { |
| 38 TraceMarker(const std::string& name); |
| 39 ~TraceMarker(); |
| 40 |
| 41 std::string name_; |
| 42 scoped_refptr<GPUTrace> trace_; |
27 }; | 43 }; |
28 | 44 |
29 // Traces GPU Commands. | 45 // Traces GPU Commands. |
30 class GPUTracer { | 46 class GPUTracer : public base::SupportsWeakPtr<GPUTracer> { |
31 public: | 47 public: |
32 static scoped_ptr<GPUTracer> Create(gles2::GLES2Decoder* decoder); | 48 explicit GPUTracer(gles2::GLES2Decoder* decoder); |
33 | 49 ~GPUTracer(); |
34 GPUTracer(); | |
35 virtual ~GPUTracer(); | |
36 | 50 |
37 // Scheduled processing in decoder begins. | 51 // Scheduled processing in decoder begins. |
38 virtual bool BeginDecoding() = 0; | 52 bool BeginDecoding(); |
39 | 53 |
40 // Scheduled processing in decoder ends. | 54 // Scheduled processing in decoder ends. |
41 virtual bool EndDecoding() = 0; | 55 bool EndDecoding(); |
42 | 56 |
43 // Begin a trace marker. | 57 // Begin a trace marker. |
44 virtual bool Begin(const std::string& name, GpuTracerSource source) = 0; | 58 bool Begin(const std::string& name, GpuTracerSource source); |
45 | 59 |
46 // End the last started trace marker. | 60 // End the last started trace marker. |
47 virtual bool End(GpuTracerSource source) = 0; | 61 bool End(GpuTracerSource source); |
48 | 62 |
49 virtual bool IsTracing() = 0; | 63 bool IsTracing(); |
50 | 64 |
51 // Retrieve the name of the current open trace. | 65 // Retrieve the name of the current open trace. |
52 // Returns empty string if no current open trace. | 66 // Returns empty string if no current open trace. |
53 virtual const std::string& CurrentName() const = 0; | 67 const std::string& CurrentName() const; |
54 | 68 |
55 private: | 69 private: |
| 70 // Trace Processing. |
| 71 scoped_refptr<GPUTrace> CreateTrace(const std::string& name); |
| 72 void Process(); |
| 73 void ProcessTraces(); |
| 74 |
| 75 void CalculateTimerOffset(); |
| 76 void IssueProcessTask(); |
| 77 |
| 78 scoped_refptr<Outputter> outputter_; |
| 79 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
| 80 std::deque<scoped_refptr<GPUTrace> > traces_; |
| 81 |
| 82 const unsigned char* gpu_trace_srv_category; |
| 83 const unsigned char* gpu_trace_dev_category; |
| 84 gles2::GLES2Decoder* decoder_; |
| 85 |
| 86 int64 timer_offset_; |
| 87 GpuTracerSource last_tracer_source_; |
| 88 |
| 89 bool enabled_; |
| 90 bool gpu_timing_synced_; |
| 91 bool gpu_executing_; |
| 92 bool process_posted_; |
| 93 |
56 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 94 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
57 }; | 95 }; |
58 | 96 |
59 class Outputter : public base::RefCounted<Outputter> { | 97 class Outputter : public base::RefCounted<Outputter> { |
60 public: | 98 public: |
61 virtual void Trace(const std::string& name, | 99 virtual void Trace(const std::string& name, |
62 int64 start_time, | 100 int64 start_time, |
63 int64 end_time) = 0; | 101 int64 end_time) = 0; |
64 | 102 |
65 protected: | 103 protected: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 157 |
120 GLuint queries_[2]; | 158 GLuint queries_[2]; |
121 | 159 |
122 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 160 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
123 }; | 161 }; |
124 | 162 |
125 } // namespace gles2 | 163 } // namespace gles2 |
126 } // namespace gpu | 164 } // namespace gpu |
127 | 165 |
128 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 166 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
OLD | NEW |