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

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

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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
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 <string> 9 #include <string>
10 10
(...skipping 22 matching lines...) Expand all
33 NUM_TRACER_SOURCES 33 NUM_TRACER_SOURCES
34 }; 34 };
35 35
36 enum GpuTracerType { 36 enum GpuTracerType {
37 kTracerTypeInvalid = -1, 37 kTracerTypeInvalid = -1,
38 38
39 kTracerTypeARBTimer, 39 kTracerTypeARBTimer,
40 kTracerTypeDisjointTimer 40 kTracerTypeDisjointTimer
41 }; 41 };
42 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
43 // Marker structure for a Trace. 58 // Marker structure for a Trace.
44 struct TraceMarker { 59 struct TraceMarker {
45 TraceMarker(const std::string& category, const std::string& name); 60 TraceMarker(const std::string& category, const std::string& name);
46 ~TraceMarker(); 61 ~TraceMarker();
47 62
48 std::string category_; 63 std::string category_;
49 std::string name_; 64 std::string name_;
50 scoped_refptr<GPUTrace> trace_; 65 scoped_refptr<GPUTrace> trace_;
51 }; 66 };
52 67
53 // Traces GPU Commands. 68 // Traces GPU Commands.
54 class GPUTracer : public base::SupportsWeakPtr<GPUTracer> { 69 class GPU_EXPORT GPUTracer
70 : public base::SupportsWeakPtr<GPUTracer> {
55 public: 71 public:
56 explicit GPUTracer(gles2::GLES2Decoder* decoder); 72 explicit GPUTracer(gles2::GLES2Decoder* decoder);
57 ~GPUTracer(); 73 virtual ~GPUTracer();
58 74
59 // Scheduled processing in decoder begins. 75 // Scheduled processing in decoder begins.
60 bool BeginDecoding(); 76 bool BeginDecoding();
61 77
62 // Scheduled processing in decoder ends. 78 // Scheduled processing in decoder ends.
63 bool EndDecoding(); 79 bool EndDecoding();
64 80
65 // Begin a trace marker. 81 // Begin a trace marker.
66 bool Begin(const std::string& category, const std::string& name, 82 bool Begin(const std::string& category, const std::string& name,
67 GpuTracerSource source); 83 GpuTracerSource source);
68 84
69 // End the last started trace marker. 85 // End the last started trace marker.
70 bool End(GpuTracerSource source); 86 bool End(GpuTracerSource source);
71 87
72 bool IsTracing(); 88 virtual bool IsTracing();
73 89
74 // Retrieve the name of the current open trace. 90 // Retrieve the name of the current open trace.
75 // Returns empty string if no current open trace. 91 // Returns empty string if no current open trace.
76 const std::string& CurrentCategory() const; 92 const std::string& CurrentCategory(GpuTracerSource source) const;
77 const std::string& CurrentName() const; 93 const std::string& CurrentName(GpuTracerSource source) const;
78 94
79 private: 95 protected:
80 // Trace Processing. 96 // Trace Processing.
81 scoped_refptr<GPUTrace> CreateTrace(const std::string& category, 97 scoped_refptr<GPUTrace> CreateTrace(const std::string& category,
82 const std::string& name); 98 const std::string& name);
99 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name);
100 virtual scoped_refptr<CPUTime> CreateCPUTime();
101 virtual GpuTracerType DetermineTracerType();
102 virtual void PostTask();
103
83 void Process(); 104 void Process();
84 void ProcessTraces(); 105 void ProcessTraces();
85 106
86 void CalculateTimerOffset(); 107 void CalculateTimerOffset();
87 void IssueProcessTask(); 108 void IssueProcessTask();
88 109
89 scoped_refptr<Outputter> outputter_; 110 scoped_refptr<Outputter> outputter_;
111 scoped_refptr<CPUTime> cpu_time_;
90 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; 112 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES];
91 std::deque<scoped_refptr<GPUTrace> > traces_; 113 std::deque<scoped_refptr<GPUTrace> > traces_;
92 114
93 const unsigned char* gpu_trace_srv_category; 115 const unsigned char* gpu_trace_srv_category;
94 const unsigned char* gpu_trace_dev_category; 116 const unsigned char* gpu_trace_dev_category;
95 gles2::GLES2Decoder* decoder_; 117 gles2::GLES2Decoder* decoder_;
96 118
97 int64 timer_offset_; 119 int64 timer_offset_;
98 GpuTracerSource last_tracer_source_;
99 120
100 GpuTracerType tracer_type_; 121 GpuTracerType tracer_type_;
101 bool gpu_timing_synced_; 122 bool gpu_timing_synced_;
102 bool gpu_executing_; 123 bool gpu_executing_;
103 bool process_posted_; 124 bool process_posted_;
104 125
105 DISALLOW_COPY_AND_ASSIGN(GPUTracer); 126 DISALLOW_COPY_AND_ASSIGN(GPUTracer);
106 }; 127 };
107 128
108 class Outputter : public base::RefCounted<Outputter> { 129 class Outputter : public base::RefCounted<Outputter> {
109 public: 130 public:
110 virtual void Trace(const std::string& category, 131 virtual void TraceDevice(const std::string& category,
111 const std::string& name, 132 const std::string& name,
112 int64 start_time, 133 int64 start_time,
113 int64 end_time) = 0; 134 int64 end_time) = 0;
135
136 virtual void TraceServiceBegin(const std::string& category,
137 const std::string& name,
138 void* id) = 0;
139
140 virtual void TraceServiceEnd(const std::string& category,
141 const std::string& name,
142 void* id) = 0;
114 143
115 protected: 144 protected:
116 virtual ~Outputter() {} 145 virtual ~Outputter() {}
117 friend class base::RefCounted<Outputter>; 146 friend class base::RefCounted<Outputter>;
118 }; 147 };
119 148
120 class TraceOutputter : public Outputter { 149 class TraceOutputter : public Outputter {
121 public: 150 public:
122 static scoped_refptr<TraceOutputter> Create(const std::string& name); 151 static scoped_refptr<TraceOutputter> Create(const std::string& name);
123 void Trace(const std::string& category, 152 void TraceDevice(const std::string& category,
124 const std::string& name, 153 const std::string& name,
125 int64 start_time, 154 int64 start_time,
126 int64 end_time) override; 155 int64 end_time) override;
156
157 void TraceServiceBegin(const std::string& category,
158 const std::string& name,
159 void* id) override;
160
161 void TraceServiceEnd(const std::string& category,
162 const std::string& name,
163 void* id) override;
127 164
128 protected: 165 protected:
129 friend class base::RefCounted<Outputter>; 166 friend class base::RefCounted<Outputter>;
130 explicit TraceOutputter(const std::string& name); 167 explicit TraceOutputter(const std::string& name);
131 ~TraceOutputter() override; 168 ~TraceOutputter() override;
132 169
133 base::Thread named_thread_; 170 base::Thread named_thread_;
134 uint64 local_trace_id_; 171 uint64 local_trace_id_;
135 172
136 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); 173 DISALLOW_COPY_AND_ASSIGN(TraceOutputter);
137 }; 174 };
138 175
139 class GPU_EXPORT GPUTrace 176 class GPU_EXPORT GPUTrace
140 : public base::RefCounted<GPUTrace> { 177 : public base::RefCounted<GPUTrace> {
141 public: 178 public:
142 GPUTrace(scoped_refptr<Outputter> outputter, 179 GPUTrace(scoped_refptr<Outputter> outputter,
180 scoped_refptr<CPUTime> cpu_time,
143 const std::string& category, 181 const std::string& category,
144 const std::string& name, 182 const std::string& name,
145 int64 offset, 183 int64 offset,
146 GpuTracerType tracer_type); 184 GpuTracerType tracer_type);
147 185
148 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; } 186 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; }
149 187
150 const std::string& category() { return category_; }
151 const std::string& name() { return name_; }
152
153 void Start(bool trace_service); 188 void Start(bool trace_service);
154 void End(bool tracing_service); 189 void End(bool tracing_service);
155 bool IsAvailable(); 190 bool IsAvailable();
156 void Process(); 191 void Process();
157 192
158 private: 193 private:
159 ~GPUTrace(); 194 ~GPUTrace();
160 195
161 void Output(); 196 void Output();
162 197
163 friend class base::RefCounted<GPUTrace>; 198 friend class base::RefCounted<GPUTrace>;
164 199
165 std::string category_; 200 std::string category_;
166 std::string name_; 201 std::string name_;
167 scoped_refptr<Outputter> outputter_; 202 scoped_refptr<Outputter> outputter_;
203 scoped_refptr<CPUTime> cpu_time_;
168 204
169 int64 offset_; 205 int64 offset_;
170 int64 start_time_; 206 int64 start_time_;
171 int64 end_time_; 207 int64 end_time_;
172 GpuTracerType tracer_type_; 208 GpuTracerType tracer_type_;
173 bool end_requested_; 209 bool end_requested_;
174 210
175 GLuint queries_[2]; 211 GLuint queries_[2];
176 212
177 DISALLOW_COPY_AND_ASSIGN(GPUTrace); 213 DISALLOW_COPY_AND_ASSIGN(GPUTrace);
178 }; 214 };
179 215
180 } // namespace gles2 216 } // namespace gles2
181 } // namespace gpu 217 } // namespace gpu
182 218
183 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ 219 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/command_buffer/service/gpu_tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698