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. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | 86 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
80 std::deque<scoped_refptr<GPUTrace> > traces_; | 87 std::deque<scoped_refptr<GPUTrace> > traces_; |
81 | 88 |
82 const unsigned char* gpu_trace_srv_category; | 89 const unsigned char* gpu_trace_srv_category; |
83 const unsigned char* gpu_trace_dev_category; | 90 const unsigned char* gpu_trace_dev_category; |
84 gles2::GLES2Decoder* decoder_; | 91 gles2::GLES2Decoder* decoder_; |
85 | 92 |
86 int64 timer_offset_; | 93 int64 timer_offset_; |
87 GpuTracerSource last_tracer_source_; | 94 GpuTracerSource last_tracer_source_; |
88 | 95 |
89 bool enabled_; | 96 GpuTracerType tracer_type_; |
90 bool gpu_timing_synced_; | 97 bool gpu_timing_synced_; |
91 bool gpu_executing_; | 98 bool gpu_executing_; |
92 bool process_posted_; | 99 bool process_posted_; |
93 | 100 |
94 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 101 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
95 }; | 102 }; |
96 | 103 |
97 class Outputter : public base::RefCounted<Outputter> { | 104 class Outputter : public base::RefCounted<Outputter> { |
98 public: | 105 public: |
99 virtual void Trace(const std::string& name, | 106 virtual void Trace(const std::string& name, |
(...skipping 19 matching lines...) Expand all Loading... |
119 | 126 |
120 base::Thread named_thread_; | 127 base::Thread named_thread_; |
121 uint64 local_trace_id_; | 128 uint64 local_trace_id_; |
122 | 129 |
123 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); | 130 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); |
124 }; | 131 }; |
125 | 132 |
126 class GPU_EXPORT GPUTrace | 133 class GPU_EXPORT GPUTrace |
127 : public base::RefCounted<GPUTrace> { | 134 : public base::RefCounted<GPUTrace> { |
128 public: | 135 public: |
129 explicit GPUTrace(const std::string& name); | |
130 GPUTrace(scoped_refptr<Outputter> outputter, | 136 GPUTrace(scoped_refptr<Outputter> outputter, |
131 const std::string& name, | 137 const std::string& name, |
132 int64 offset); | 138 int64 offset, |
| 139 GpuTracerType tracer_type); |
133 | 140 |
134 bool IsEnabled() { return enabled_; } | 141 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; } |
135 const std::string& name() { return name_; } | 142 const std::string& name() { return name_; } |
136 | 143 |
137 void Start(); | 144 void Start(); |
138 void End(); | 145 void End(); |
139 bool IsAvailable(); | 146 bool IsAvailable(); |
140 void Process(); | 147 void Process(); |
141 | 148 |
142 private: | 149 private: |
143 ~GPUTrace(); | 150 ~GPUTrace(); |
144 | 151 |
145 void Output(); | 152 void Output(); |
146 | 153 |
147 friend class base::RefCounted<GPUTrace>; | 154 friend class base::RefCounted<GPUTrace>; |
148 | 155 |
149 std::string name_; | 156 std::string name_; |
150 scoped_refptr<Outputter> outputter_; | 157 scoped_refptr<Outputter> outputter_; |
151 | 158 |
152 int64 offset_; | 159 int64 offset_; |
153 int64 start_time_; | 160 int64 start_time_; |
154 int64 end_time_; | 161 int64 end_time_; |
| 162 GpuTracerType tracer_type_; |
155 bool end_requested_; | 163 bool end_requested_; |
156 bool enabled_; | |
157 | 164 |
158 GLuint queries_[2]; | 165 GLuint queries_[2]; |
159 | 166 |
160 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 167 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
161 }; | 168 }; |
162 | 169 |
163 } // namespace gles2 | 170 } // namespace gles2 |
164 } // namespace gpu | 171 } // namespace gpu |
165 | 172 |
166 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 173 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
OLD | NEW |