OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "ui/gl/gpu_timing.h" | 5 #include "ui/gl/gpu_timing.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
10 #include "ui/gl/gl_version_info.h" | 10 #include "ui/gl/gl_version_info.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Returns true when UpdateQueryResults() is ready to be called. | 196 // Returns true when UpdateQueryResults() is ready to be called. |
197 bool IsAvailable(GPUTimingImpl* gpu_timing) override { | 197 bool IsAvailable(GPUTimingImpl* gpu_timing) override { |
198 if (gpu_timing->GetElapsedQueryCount() != 0 && | 198 if (gpu_timing->GetElapsedQueryCount() != 0 && |
199 gpu_timing->GetLastElapsedQuery() == this) { | 199 gpu_timing->GetLastElapsedQuery() == this) { |
200 // Cannot query if result is available if EndQuery has not been called. | 200 // Cannot query if result is available if EndQuery has not been called. |
201 // Since only one query is going on at a time, the end query is only not | 201 // Since only one query is going on at a time, the end query is only not |
202 // called for the very last query when ongoing query counter is not 0. | 202 // called for the very last query when ongoing query counter is not 0. |
203 return false; | 203 return false; |
204 } | 204 } |
205 | 205 |
206 GLint done = 0; | 206 GLuint done = 0; |
207 glGetQueryObjectiv(gl_query_id_, GL_QUERY_RESULT_AVAILABLE, &done); | 207 glGetQueryObjectuiv(gl_query_id_, GL_QUERY_RESULT_AVAILABLE, &done); |
208 return !!done; | 208 return !!done; |
209 } | 209 } |
210 | 210 |
211 // Fills out query result start and end, called after IsAvailable() is true. | 211 // Fills out query result start and end, called after IsAvailable() is true. |
212 void UpdateQueryResults(GPUTimingImpl* gpu_timing) override { | 212 void UpdateQueryResults(GPUTimingImpl* gpu_timing) override { |
213 DCHECK(IsAvailable(gpu_timing)); | |
214 | |
215 GLuint64 result_value = 0; | 213 GLuint64 result_value = 0; |
216 glGetQueryObjectui64v(gl_query_id_, GL_QUERY_RESULT, &result_value); | 214 glGetQueryObjectui64v(gl_query_id_, GL_QUERY_RESULT, &result_value); |
217 const int64_t micro_results = NanoToMicro(result_value); | 215 const int64_t micro_results = NanoToMicro(result_value); |
218 | 216 |
219 // Adjust prev query end time if it is before the current max. | 217 // Adjust prev query end time if it is before the current max. |
220 const int64_t start_time = | 218 const int64_t start_time = |
221 std::max(first_top_level_query_ ? query_begin_cpu_time_ : 0, | 219 std::max(first_top_level_query_ ? query_begin_cpu_time_ : 0, |
222 std::max(prev_query_end_time_, | 220 std::max(prev_query_end_time_, |
223 gpu_timing->GetMaxTimeStamp())); | 221 gpu_timing->GetMaxTimeStamp())); |
224 | 222 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 268 } |
271 | 269 |
272 scoped_refptr<QueryResult> DoQuery() { | 270 scoped_refptr<QueryResult> DoQuery() { |
273 glQueryCounter(gl_query_id_, GL_TIMESTAMP); | 271 glQueryCounter(gl_query_id_, GL_TIMESTAMP); |
274 query_result_ = new QueryResult(); | 272 query_result_ = new QueryResult(); |
275 return query_result_; | 273 return query_result_; |
276 } | 274 } |
277 | 275 |
278 // Returns true when UpdateQueryResults() is ready to be called. | 276 // Returns true when UpdateQueryResults() is ready to be called. |
279 bool IsAvailable(GPUTimingImpl* gpu_timing) override { | 277 bool IsAvailable(GPUTimingImpl* gpu_timing) override { |
280 GLint done = 0; | 278 GLuint done = 0; |
281 glGetQueryObjectiv(gl_query_id_, GL_QUERY_RESULT_AVAILABLE, &done); | 279 glGetQueryObjectuiv(gl_query_id_, GL_QUERY_RESULT_AVAILABLE, &done); |
282 return !!done; | 280 return !!done; |
283 } | 281 } |
284 | 282 |
285 // Fills out query result start and end, called after IsAvailable() is true. | 283 // Fills out query result start and end, called after IsAvailable() is true. |
286 void UpdateQueryResults(GPUTimingImpl* gpu_timing) override { | 284 void UpdateQueryResults(GPUTimingImpl* gpu_timing) override { |
287 DCHECK(IsAvailable(gpu_timing)); | 285 DCHECK(IsAvailable(gpu_timing)); |
288 | 286 |
289 GLuint64 result_value = 0; | 287 GLuint64 result_value = 0; |
290 glGetQueryObjectui64v(gl_query_id_, GL_QUERY_RESULT, &result_value); | 288 glGetQueryObjectui64v(gl_query_id_, GL_QUERY_RESULT, &result_value); |
291 const int64_t micro_results = NanoToMicro(result_value); | 289 const int64_t micro_results = NanoToMicro(result_value); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 | 596 |
599 void GPUTimingClient::ForceTimeElapsedQuery() { | 597 void GPUTimingClient::ForceTimeElapsedQuery() { |
600 DCHECK(gpu_timing_); | 598 DCHECK(gpu_timing_); |
601 gpu_timing_->ForceTimeElapsedQuery(); | 599 gpu_timing_->ForceTimeElapsedQuery(); |
602 } | 600 } |
603 | 601 |
604 GPUTimingClient::~GPUTimingClient() { | 602 GPUTimingClient::~GPUTimingClient() { |
605 } | 603 } |
606 | 604 |
607 } // namespace gfx | 605 } // namespace gfx |
OLD | NEW |