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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 enum GpuTracerSource { | 26 enum GpuTracerSource { |
27 kTraceGroupInvalid = -1, | 27 kTraceGroupInvalid = -1, |
28 | 28 |
29 kTraceGroupMarker = 0, | 29 kTraceGroupMarker = 0, |
30 kTraceCHROMIUM = 1, | 30 kTraceCHROMIUM = 1, |
31 kTraceDecoder = 2, | 31 kTraceDecoder = 2, |
32 | 32 |
33 NUM_TRACER_SOURCES | 33 NUM_TRACER_SOURCES |
34 }; | 34 }; |
35 | 35 |
| 36 enum GpuTracerType { |
| 37 kTracerTypeInvalid = -1, |
| 38 |
| 39 kTracerTypeARBTimer, |
| 40 kTracerTypeDisjointTimer |
| 41 }; |
| 42 |
36 // Marker structure for a Trace. | 43 // Marker structure for a Trace. |
37 struct TraceMarker { | 44 struct TraceMarker { |
38 TraceMarker(const std::string& name); | 45 TraceMarker(const std::string& name); |
39 ~TraceMarker(); | 46 ~TraceMarker(); |
40 | 47 |
41 std::string name_; | 48 std::string name_; |
42 scoped_refptr<GPUTrace> trace_; | 49 scoped_refptr<GPUTrace> trace_; |
43 }; | 50 }; |
44 | 51 |
45 // Traces GPU Commands. | 52 // Traces GPU Commands. |
46 class GPUTracer : public base::SupportsWeakPtr<GPUTracer> { | 53 class GPUTracer : public base::SupportsWeakPtr<GPUTracer> { |
47 public: | 54 public: |
48 explicit GPUTracer(gles2::GLES2Decoder* decoder); | 55 explicit GPUTracer(gles2::GLES2Decoder* decoder); |
49 ~GPUTracer(); | 56 ~GPUTracer(); |
50 | 57 |
51 // Scheduled processing in decoder begins. | 58 // Scheduled processing in decoder begins. |
52 bool BeginDecoding(); | 59 bool BeginDecoding(); |
53 | 60 |
54 // Scheduled processing in decoder ends. | 61 // Scheduled processing in decoder ends. |
55 bool EndDecoding(); | 62 bool EndDecoding(); |
56 | 63 |
57 // Begin a trace marker. | 64 // Begin a trace marker. |
58 bool Begin(const std::string& name, GpuTracerSource source); | 65 bool Begin(const std::string& name, GpuTracerSource source); |
59 | 66 |
60 // End the last started trace marker. | 67 // End the last started trace marker. |
61 bool End(GpuTracerSource source); | 68 bool End(GpuTracerSource source); |
62 | 69 |
| 70 // Discard data obtained from current trace. |
| 71 void DiscardTrace(); |
| 72 |
63 bool IsTracing(); | 73 bool IsTracing(); |
64 | 74 |
65 // Retrieve the name of the current open trace. | 75 // Retrieve the name of the current open trace. |
66 // Returns empty string if no current open trace. | 76 // Returns empty string if no current open trace. |
67 const std::string& CurrentName() const; | 77 const std::string& CurrentName() const; |
68 | 78 |
69 private: | 79 private: |
70 // Trace Processing. | 80 // Trace Processing. |
71 scoped_refptr<GPUTrace> CreateTrace(const std::string& name); | 81 scoped_refptr<GPUTrace> CreateTrace(const std::string& name); |
72 void Process(); | 82 void Process(); |
73 void ProcessTraces(); | 83 void ProcessTraces(); |
74 | 84 |
75 void CalculateTimerOffset(); | 85 void CalculateTimerOffset(); |
76 void IssueProcessTask(); | 86 void IssueProcessTask(); |
77 | 87 |
78 scoped_refptr<Outputter> outputter_; | 88 scoped_refptr<Outputter> outputter_; |
79 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | 89 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
80 std::deque<scoped_refptr<GPUTrace> > traces_; | 90 std::deque<scoped_refptr<GPUTrace> > traces_; |
81 | 91 |
82 const unsigned char* gpu_trace_srv_category; | 92 const unsigned char* gpu_trace_srv_category; |
83 const unsigned char* gpu_trace_dev_category; | 93 const unsigned char* gpu_trace_dev_category; |
84 gles2::GLES2Decoder* decoder_; | 94 gles2::GLES2Decoder* decoder_; |
85 | 95 |
86 int64 timer_offset_; | 96 int64 timer_offset_; |
87 GpuTracerSource last_tracer_source_; | 97 GpuTracerSource last_tracer_source_; |
88 | 98 |
89 bool enabled_; | 99 GpuTracerType tracer_type_; |
90 bool gpu_timing_synced_; | 100 bool gpu_timing_synced_; |
91 bool gpu_executing_; | 101 bool gpu_executing_; |
92 bool process_posted_; | 102 bool process_posted_; |
93 | 103 |
94 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 104 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
95 }; | 105 }; |
96 | 106 |
97 class Outputter : public base::RefCounted<Outputter> { | 107 class Outputter : public base::RefCounted<Outputter> { |
98 public: | 108 public: |
99 virtual void Trace(const std::string& name, | 109 virtual void Trace(const std::string& name, |
(...skipping 19 matching lines...) Expand all Loading... |
119 | 129 |
120 base::Thread named_thread_; | 130 base::Thread named_thread_; |
121 uint64 local_trace_id_; | 131 uint64 local_trace_id_; |
122 | 132 |
123 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); | 133 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); |
124 }; | 134 }; |
125 | 135 |
126 class GPU_EXPORT GPUTrace | 136 class GPU_EXPORT GPUTrace |
127 : public base::RefCounted<GPUTrace> { | 137 : public base::RefCounted<GPUTrace> { |
128 public: | 138 public: |
129 explicit GPUTrace(const std::string& name); | |
130 GPUTrace(scoped_refptr<Outputter> outputter, | 139 GPUTrace(scoped_refptr<Outputter> outputter, |
131 const std::string& name, | 140 const std::string& name, |
132 int64 offset); | 141 int64 offset, |
| 142 GpuTracerType tracer_type); |
133 | 143 |
134 bool IsEnabled() { return enabled_; } | 144 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; } |
135 const std::string& name() { return name_; } | 145 const std::string& name() { return name_; } |
136 | 146 |
137 void Start(); | 147 void Start(); |
138 void End(); | 148 void End(); |
139 bool IsAvailable(); | 149 bool IsAvailable(); |
140 void Process(); | 150 void Process(); |
| 151 void DiscardTrace(); |
141 | 152 |
142 private: | 153 private: |
143 ~GPUTrace(); | 154 ~GPUTrace(); |
144 | 155 |
145 void Output(); | 156 void Output(); |
146 | 157 |
147 friend class base::RefCounted<GPUTrace>; | 158 friend class base::RefCounted<GPUTrace>; |
148 | 159 |
149 std::string name_; | 160 std::string name_; |
150 scoped_refptr<Outputter> outputter_; | 161 scoped_refptr<Outputter> outputter_; |
151 | 162 |
152 int64 offset_; | 163 int64 offset_; |
153 int64 start_time_; | 164 int64 start_time_; |
154 int64 end_time_; | 165 int64 end_time_; |
| 166 GpuTracerType tracer_type_; |
155 bool end_requested_; | 167 bool end_requested_; |
156 bool enabled_; | 168 bool discard_trace_; |
157 | 169 |
158 GLuint queries_[2]; | 170 GLuint queries_[2]; |
159 | 171 |
160 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 172 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
161 }; | 173 }; |
162 | 174 |
163 } // namespace gles2 | 175 } // namespace gles2 |
164 } // namespace gpu | 176 } // namespace gpu |
165 | 177 |
166 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 178 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
OLD | NEW |