Index: ui/gl/gpu_timing.cc |
diff --git a/ui/gl/gpu_timing.cc b/ui/gl/gpu_timing.cc |
index 45908c985188f56baaac43086cc62e9c01929248..8ef6abd569b7a40780776ef9527b7cdf1cb1a9c4 100644 |
--- a/ui/gl/gpu_timing.cc |
+++ b/ui/gl/gpu_timing.cc |
@@ -27,6 +27,7 @@ class GPUTimingImpl : public GPUTiming { |
void ForceTimeElapsedQuery() { force_time_elapsed_query_ = true; } |
bool IsForceTimeElapsedQuery() { return force_time_elapsed_query_; } |
+ bool ShouldForceTimeElapsedQuery(); |
GPUTiming::TimerType GetTimerType() const { return timer_type_; } |
@@ -317,13 +318,31 @@ GPUTimingImpl::GPUTimingImpl(GLContextReal* context) { |
timer_type_ = GPUTiming::kTimerTypeARB; |
} else if (context->HasExtension("GL_EXT_timer_query")) { |
timer_type_ = GPUTiming::kTimerTypeEXT; |
- force_time_elapsed_query_ = true; |
} |
+ force_time_elapsed_query_ = ShouldForceTimeElapsedQuery(); |
} |
GPUTimingImpl::~GPUTimingImpl() { |
} |
+bool GPUTimingImpl::ShouldForceTimeElapsedQuery() { |
+ if (timer_type_ == GPUTiming::kTimerTypeInvalid) { |
+ return false; |
+ } else if (timer_type_ == GPUTiming::kTimerTypeEXT) { |
+ // GL_EXT_timer_query does not support timestamps |
+ return true; |
+ } else { |
+ // Certain drivers such as Mac drivers and ANGLE's D3D11 backend do not |
+ // support timestamps even though queries for them are valid. This is |
+ // indicated by returning 0 when for GL_TIMESTAMP in GL_QUERY_COUNTER_BITS |
+ DCHECK(timer_type_ == GPUTiming::kTimerTypeARB || |
+ timer_type_ == GPUTiming::kTimerTypeDisjoint); |
+ GLint timestamp_bits; |
David Yen
2016/02/11 17:53:20
Could we just make these 3 lines a static function
|
+ glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, ×tamp_bits); |
+ return (timestamp_bits == 0); |
+ } |
+} |
+ |
uint32_t GPUTimingImpl::GetDisjointCount() { |
if (timer_type_ == GPUTiming::kTimerTypeDisjoint) { |
GLint disjoint_value = 0; |