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

Unified Diff: ui/gl/gpu_timing.cc

Issue 1687353002: Force time elapsed queries on certain drivers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gpu_tracer_unittest.cc ('k') | ui/gl/gpu_timing_fake.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gpu_timing.cc
diff --git a/ui/gl/gpu_timing.cc b/ui/gl/gpu_timing.cc
index 45908c985188f56baaac43086cc62e9c01929248..c6e574ac578efcc96906398f92076d150a3a55ee 100644
--- a/ui/gl/gpu_timing.cc
+++ b/ui/gl/gpu_timing.cc
@@ -20,6 +20,12 @@ int64_t NanoToMicro(uint64_t nano_seconds) {
return static_cast<int64_t>(up / base::Time::kNanosecondsPerMicrosecond);
}
+int32_t QueryTimestampBits() {
+ GLint timestamp_bits;
+ glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &timestamp_bits);
+ return static_cast<int32_t>(timestamp_bits);
+}
+
class GPUTimingImpl : public GPUTiming {
public:
GPUTimingImpl(GLContextReal* context);
@@ -73,6 +79,7 @@ class GPUTimingImpl : public GPUTiming {
int64_t offset_ = 0; // offset cache when timer_type_ == kTimerTypeARB
bool offset_valid_ = false;
bool force_time_elapsed_query_ = false;
+ int32_t timestamp_bit_count_gl_ = -1; // gl implementation timestamp bits
uint32_t next_timer_query_id_ = 0;
uint32_t next_good_timer_query_id_ = 0; // identify bad ids for disjoints.
@@ -318,6 +325,7 @@ GPUTimingImpl::GPUTimingImpl(GLContextReal* context) {
} else if (context->HasExtension("GL_EXT_timer_query")) {
timer_type_ = GPUTiming::kTimerTypeEXT;
force_time_elapsed_query_ = true;
+ timestamp_bit_count_gl_ = 0;
}
}
@@ -392,6 +400,15 @@ void GPUTimingImpl::EndElapsedTimeQuery(scoped_refptr<QueryResult> result) {
scoped_refptr<QueryResult> GPUTimingImpl::DoTimeStampQuery() {
DCHECK(timer_type_ != GPUTiming::kTimerTypeInvalid);
+ // Certain GL drivers have timestamp bit count set to 0 which means timestamps
+ // aren't supported. Emulate them with time elapsed queries if that is the
+ // case.
+ if (timestamp_bit_count_gl_ == -1) {
+ DCHECK(timer_type_ != GPUTiming::kTimerTypeEXT);
+ timestamp_bit_count_gl_ = QueryTimestampBits();
no sievers 2016/02/17 23:08:45 Do you have to do that every time though? Isn't GL
David Yen 2016/02/17 23:10:52 It only lazily initializes it once. It's done lazi
Ian Ewell 2016/02/17 23:11:53 It is only called once and then timestamp_bit_coun
+ force_time_elapsed_query_ = (timestamp_bit_count_gl_ == 0);
+ }
+
if (force_time_elapsed_query_) {
// Replace with elapsed timer queries instead.
scoped_refptr<QueryResult> result = BeginElapsedTimeQuery();
« no previous file with comments | « gpu/command_buffer/service/gpu_tracer_unittest.cc ('k') | ui/gl/gpu_timing_fake.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698