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

Side by Side Diff: ui/gl/gpu_timing.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « ui/gl/gl_mock_autogen_gl.h ('k') | no next file » | 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) 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 26 matching lines...) Expand all
37 GLint disjoint_value = 0; 37 GLint disjoint_value = 0;
38 glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint_value); 38 glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint_value);
39 if (disjoint_value) { 39 if (disjoint_value) {
40 disjoint_counter_++; 40 disjoint_counter_++;
41 } 41 }
42 } 42 }
43 return disjoint_counter_; 43 return disjoint_counter_;
44 } 44 }
45 45
46 GPUTimer::~GPUTimer() { 46 GPUTimer::~GPUTimer() {
47 glDeleteQueriesARB(2, queries_); 47 glDeleteQueries(2, queries_);
48 } 48 }
49 49
50 void GPUTimer::Start() { 50 void GPUTimer::Start() {
51 switch (gpu_timing_client_->gpu_timing_->timer_type_) { 51 switch (gpu_timing_client_->gpu_timing_->timer_type_) {
52 case GPUTiming::kTimerTypeARB: 52 case GPUTiming::kTimerTypeARB:
53 case GPUTiming::kTimerTypeDisjoint: 53 case GPUTiming::kTimerTypeDisjoint:
54 // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value. 54 // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value.
55 glQueryCounter(queries_[0], GL_TIMESTAMP); 55 glQueryCounter(queries_[0], GL_TIMESTAMP);
56 break; 56 break;
57 case GPUTiming::kTimerTypeEXT: 57 case GPUTiming::kTimerTypeEXT:
(...skipping 19 matching lines...) Expand all
77 default: 77 default:
78 NOTREACHED(); 78 NOTREACHED();
79 } 79 }
80 } 80 }
81 81
82 bool GPUTimer::IsAvailable() { 82 bool GPUTimer::IsAvailable() {
83 if (!gpu_timing_client_->IsAvailable() || !end_requested_) { 83 if (!gpu_timing_client_->IsAvailable() || !end_requested_) {
84 return false; 84 return false;
85 } 85 }
86 GLint done = 0; 86 GLint done = 0;
87 glGetQueryObjectivARB(queries_[1] ? queries_[1] : queries_[0], 87 glGetQueryObjectiv(queries_[1] ? queries_[1] : queries_[0],
88 GL_QUERY_RESULT_AVAILABLE, &done); 88 GL_QUERY_RESULT_AVAILABLE, &done);
89 return done != 0; 89 return done != 0;
90 } 90 }
91 91
92 void GPUTimer::GetStartEndTimestamps(int64* start, int64* end) { 92 void GPUTimer::GetStartEndTimestamps(int64* start, int64* end) {
93 DCHECK(start && end); 93 DCHECK(start && end);
94 DCHECK(IsAvailable()); 94 DCHECK(IsAvailable());
95 DCHECK(gpu_timing_client_->gpu_timing_); 95 DCHECK(gpu_timing_client_->gpu_timing_);
96 DCHECK(gpu_timing_client_->gpu_timing_->timer_type_ != 96 DCHECK(gpu_timing_client_->gpu_timing_->timer_type_ !=
97 GPUTiming::kTimerTypeEXT); 97 GPUTiming::kTimerTypeEXT);
98 GLuint64 begin_stamp = 0; 98 GLuint64 begin_stamp = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 case GPUTiming::kTimerTypeARB: 138 case GPUTiming::kTimerTypeARB:
139 case GPUTiming::kTimerTypeDisjoint: 139 case GPUTiming::kTimerTypeDisjoint:
140 queries = 2; 140 queries = 2;
141 break; 141 break;
142 case GPUTiming::kTimerTypeEXT: 142 case GPUTiming::kTimerTypeEXT:
143 queries = 1; 143 queries = 1;
144 break; 144 break;
145 default: 145 default:
146 NOTREACHED(); 146 NOTREACHED();
147 } 147 }
148 glGenQueriesARB(queries, queries_); 148 glGenQueries(queries, queries_);
149 } 149 }
150 150
151 GPUTimingClient::GPUTimingClient(GPUTiming* gpu_timing) 151 GPUTimingClient::GPUTimingClient(GPUTiming* gpu_timing)
152 : gpu_timing_(gpu_timing) { 152 : gpu_timing_(gpu_timing) {
153 if (gpu_timing) { 153 if (gpu_timing) {
154 timer_type_ = gpu_timing->GetTimerType(); 154 timer_type_ = gpu_timing->GetTimerType();
155 disjoint_counter_ = gpu_timing_->GetDisjointCount(); 155 disjoint_counter_ = gpu_timing_->GetDisjointCount();
156 } 156 }
157 } 157 }
158 158
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 void GPUTimingClient::SetCpuTimeForTesting( 215 void GPUTimingClient::SetCpuTimeForTesting(
216 const base::Callback<int64(void)>& cpu_time) { 216 const base::Callback<int64(void)>& cpu_time) {
217 cpu_time_for_testing_ = cpu_time; 217 cpu_time_for_testing_ = cpu_time;
218 } 218 }
219 219
220 GPUTimingClient::~GPUTimingClient() { 220 GPUTimingClient::~GPUTimingClient() {
221 } 221 }
222 222
223 } // namespace gfx 223 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_mock_autogen_gl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698