Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: gpu/command_buffer/service/gpu_tracer.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/gpu_timing.cc ('k') | gpu/command_buffer/service/gpu_tracer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque>
9 #include <string> 10 #include <string>
11 #include <vector>
10 12
11 #include "base/basictypes.h" 13 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
18 #include "gpu/command_buffer/service/gpu_timing.h"
16 #include "gpu/gpu_export.h" 19 #include "gpu/gpu_export.h"
17 #include "ui/gl/gl_bindings.h" 20 #include "ui/gl/gl_bindings.h"
18 21
19 namespace gpu { 22 namespace gpu {
20 namespace gles2 { 23 namespace gles2 {
21 24
22 class Outputter; 25 class Outputter;
23 class GPUTrace; 26 class GPUTrace;
24 27
25 // Id used to keep trace namespaces separate 28 // Id used to keep trace namespaces separate
26 enum GpuTracerSource { 29 enum GpuTracerSource {
27 kTraceGroupInvalid = -1, 30 kTraceGroupInvalid = -1,
28 31
29 kTraceGroupMarker = 0, 32 kTraceGroupMarker = 0,
30 kTraceCHROMIUM = 1, 33 kTraceCHROMIUM = 1,
31 kTraceDecoder = 2, 34 kTraceDecoder = 2,
32 35
33 NUM_TRACER_SOURCES 36 NUM_TRACER_SOURCES
34 }; 37 };
35 38
36 enum GpuTracerType {
37 kTracerTypeInvalid = -1,
38
39 kTracerTypeARBTimer,
40 kTracerTypeDisjointTimer
41 };
42
43 // Central accesser to CPU Time
44 class GPU_EXPORT CPUTime
45 : public base::RefCounted<CPUTime> {
46 public:
47 CPUTime();
48
49 virtual int64 GetCurrentTime();
50
51 protected:
52 virtual ~CPUTime();
53 friend class base::RefCounted<CPUTime>;
54
55 DISALLOW_COPY_AND_ASSIGN(CPUTime);
56 };
57
58 // Marker structure for a Trace. 39 // Marker structure for a Trace.
59 struct TraceMarker { 40 struct TraceMarker {
60 TraceMarker(const std::string& category, const std::string& name); 41 TraceMarker(const std::string& category, const std::string& name);
61 ~TraceMarker(); 42 ~TraceMarker();
62 43
63 std::string category_; 44 std::string category_;
64 std::string name_; 45 std::string name_;
65 scoped_refptr<GPUTrace> trace_; 46 scoped_refptr<GPUTrace> trace_;
66 }; 47 };
67 48
(...skipping 19 matching lines...) Expand all
87 68
88 virtual bool IsTracing(); 69 virtual bool IsTracing();
89 70
90 // Retrieve the name of the current open trace. 71 // Retrieve the name of the current open trace.
91 // Returns empty string if no current open trace. 72 // Returns empty string if no current open trace.
92 const std::string& CurrentCategory(GpuTracerSource source) const; 73 const std::string& CurrentCategory(GpuTracerSource source) const;
93 const std::string& CurrentName(GpuTracerSource source) const; 74 const std::string& CurrentName(GpuTracerSource source) const;
94 75
95 protected: 76 protected:
96 // Trace Processing. 77 // Trace Processing.
97 scoped_refptr<GPUTrace> CreateTrace(const std::string& category,
98 const std::string& name);
99 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name); 78 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name);
100 virtual scoped_refptr<CPUTime> CreateCPUTime();
101 virtual GpuTracerType DetermineTracerType();
102 virtual void PostTask(); 79 virtual void PostTask();
103 80
104 void Process(); 81 void Process();
105 void ProcessTraces(); 82 void ProcessTraces();
106 83
107 void CalculateTimerOffset();
108 void IssueProcessTask(); 84 void IssueProcessTask();
109 85
110 scoped_refptr<Outputter> outputter_; 86 scoped_refptr<Outputter> outputter_;
111 scoped_refptr<CPUTime> cpu_time_;
112 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; 87 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES];
113 std::deque<scoped_refptr<GPUTrace> > traces_; 88 std::deque<scoped_refptr<GPUTrace> > traces_;
114 89
115 const unsigned char* gpu_trace_srv_category; 90 const unsigned char* gpu_trace_srv_category;
116 const unsigned char* gpu_trace_dev_category; 91 const unsigned char* gpu_trace_dev_category;
117 gles2::GLES2Decoder* decoder_; 92 gles2::GLES2Decoder* decoder_;
93 gpu::GPUTiming gpu_timing_;
118 94
119 int64 timer_offset_;
120
121 GpuTracerType tracer_type_;
122 bool gpu_timing_synced_;
123 bool gpu_executing_; 95 bool gpu_executing_;
124 bool process_posted_; 96 bool process_posted_;
125 97
98 private:
126 DISALLOW_COPY_AND_ASSIGN(GPUTracer); 99 DISALLOW_COPY_AND_ASSIGN(GPUTracer);
127 }; 100 };
128 101
129 class Outputter : public base::RefCounted<Outputter> { 102 class Outputter : public base::RefCounted<Outputter> {
130 public: 103 public:
131 virtual void TraceDevice(const std::string& category, 104 virtual void TraceDevice(const std::string& category,
132 const std::string& name, 105 const std::string& name,
133 int64 start_time, 106 int64 start_time,
134 int64 end_time) = 0; 107 int64 end_time) = 0;
135 108
(...skipping 23 matching lines...) Expand all
159 const std::string& name) override; 132 const std::string& name) override;
160 133
161 protected: 134 protected:
162 friend class base::RefCounted<Outputter>; 135 friend class base::RefCounted<Outputter>;
163 explicit TraceOutputter(const std::string& name); 136 explicit TraceOutputter(const std::string& name);
164 ~TraceOutputter() override; 137 ~TraceOutputter() override;
165 138
166 base::Thread named_thread_; 139 base::Thread named_thread_;
167 uint64 local_trace_id_; 140 uint64 local_trace_id_;
168 141
142 private:
169 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); 143 DISALLOW_COPY_AND_ASSIGN(TraceOutputter);
170 }; 144 };
171 145
172 class GPU_EXPORT GPUTrace 146 class GPU_EXPORT GPUTrace
173 : public base::RefCounted<GPUTrace> { 147 : public base::RefCounted<GPUTrace> {
174 public: 148 public:
175 GPUTrace(scoped_refptr<Outputter> outputter, 149 GPUTrace(scoped_refptr<Outputter> outputter,
176 scoped_refptr<CPUTime> cpu_time, 150 gpu::GPUTiming* gpu_timing,
177 const std::string& category, 151 const std::string& category,
178 const std::string& name, 152 const std::string& name,
179 int64 offset, 153 const bool enabled);
180 GpuTracerType tracer_type);
181
182 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; }
183 154
184 void Start(bool trace_service); 155 void Start(bool trace_service);
185 void End(bool tracing_service); 156 void End(bool tracing_service);
186 bool IsAvailable(); 157 bool IsAvailable();
158 bool IsEnabled() { return enabled_; }
187 void Process(); 159 void Process();
188 160
189 private: 161 private:
190 ~GPUTrace(); 162 ~GPUTrace();
191 163
192 void Output(); 164 void Output();
193 165
194 friend class base::RefCounted<GPUTrace>; 166 friend class base::RefCounted<GPUTrace>;
195 167
196 std::string category_; 168 std::string category_;
197 std::string name_; 169 std::string name_;
198 scoped_refptr<Outputter> outputter_; 170 scoped_refptr<Outputter> outputter_;
199 scoped_refptr<CPUTime> cpu_time_; 171 scoped_ptr<gpu::GPUTimer> gpu_timer_;
200 172 const bool enabled_ = false;
201 int64 offset_;
202 int64 start_time_;
203 int64 end_time_;
204 GpuTracerType tracer_type_;
205 bool end_requested_;
206
207 GLuint queries_[2];
208 173
209 DISALLOW_COPY_AND_ASSIGN(GPUTrace); 174 DISALLOW_COPY_AND_ASSIGN(GPUTrace);
210 }; 175 };
211 176
212 class ScopedGPUTrace { 177 class ScopedGPUTrace {
213 public: 178 public:
214 ScopedGPUTrace(GPUTracer* gpu_tracer, GpuTracerSource source, 179 ScopedGPUTrace(GPUTracer* gpu_tracer,
215 const std::string& category, const std::string& name) 180 GpuTracerSource source,
216 : gpu_tracer_(gpu_tracer), 181 const std::string& category,
217 source_(source) { 182 const std::string& name)
218 gpu_tracer_->Begin(category, name, source_); 183 : gpu_tracer_(gpu_tracer), source_(source) {
219 } 184 gpu_tracer_->Begin(category, name, source_);
185 }
220 186
221 ~ScopedGPUTrace() { 187 ~ScopedGPUTrace() { gpu_tracer_->End(source_); }
222 gpu_tracer_->End(source_);
223 }
224 188
225 private: 189 private:
226 GPUTracer* gpu_tracer_; 190 GPUTracer* gpu_tracer_;
227 GpuTracerSource source_; 191 GpuTracerSource source_;
228 }; 192 };
229 193
230 } // namespace gles2 194 } // namespace gles2
231 } // namespace gpu 195 } // namespace gpu
232 196
233 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ 197 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_timing.cc ('k') | gpu/command_buffer/service/gpu_tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698