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

Side by Side Diff: gpu/command_buffer/client/query_tracker.cc

Issue 228653004: Reduce the number of flushes while using glQueries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "fix review comment." Created 6 years, 8 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 | « gpu/command_buffer/client/query_tracker.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) 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 #include "gpu/command_buffer/client/query_tracker.h" 5 #include "gpu/command_buffer/client/query_tracker.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 QueryTracker::Query::Query(GLuint id, GLenum target, 88 QueryTracker::Query::Query(GLuint id, GLenum target,
89 const QuerySyncManager::QueryInfo& info) 89 const QuerySyncManager::QueryInfo& info)
90 : id_(id), 90 : id_(id),
91 target_(target), 91 target_(target),
92 info_(info), 92 info_(info),
93 state_(kUninitialized), 93 state_(kUninitialized),
94 submit_count_(0), 94 submit_count_(0),
95 token_(0), 95 token_(0),
96 flushed_(false), 96 last_flush_(0),
97 client_begin_time_us_(0), 97 client_begin_time_us_(0),
98 result_(0) { 98 result_(0) {
99 } 99 }
100 100
101 101
102 void QueryTracker::Query::Begin(GLES2Implementation* gl) { 102 void QueryTracker::Query::Begin(GLES2Implementation* gl) {
103 // init memory, inc count 103 // init memory, inc count
104 MarkAsActive(); 104 MarkAsActive();
105 105
106 switch (target()) { 106 switch (target()) {
(...skipping 26 matching lines...) Expand all
133 // There's an error on the client, no need to bother the service. just 133 // There's an error on the client, no need to bother the service. just
134 // set the query as completed and return the error. 134 // set the query as completed and return the error.
135 if (error != GL_NO_ERROR) { 135 if (error != GL_NO_ERROR) {
136 state_ = kComplete; 136 state_ = kComplete;
137 result_ = error; 137 result_ = error;
138 return; 138 return;
139 } 139 }
140 } 140 }
141 } 141 }
142 } 142 }
143 last_flush_ = gl->helper()->flush_generation();
143 gl->helper()->EndQueryEXT(target(), submit_count()); 144 gl->helper()->EndQueryEXT(target(), submit_count());
144 MarkAsPending(gl->helper()->InsertToken()); 145 MarkAsPending(gl->helper()->InsertToken());
145 } 146 }
146 147
147 bool QueryTracker::Query::CheckResultsAvailable( 148 bool QueryTracker::Query::CheckResultsAvailable(
148 CommandBufferHelper* helper) { 149 CommandBufferHelper* helper) {
149 if (Pending()) { 150 if (Pending()) {
150 if (base::subtle::Acquire_Load(&info_.sync->process_count) == 151 if (base::subtle::Acquire_Load(&info_.sync->process_count) ==
151 submit_count_ || 152 submit_count_ ||
152 helper->IsContextLost()) { 153 helper->IsContextLost()) {
153 switch (target()) { 154 switch (target()) {
154 case GL_COMMANDS_ISSUED_CHROMIUM: 155 case GL_COMMANDS_ISSUED_CHROMIUM:
155 result_ = std::min(info_.sync->result, 156 result_ = std::min(info_.sync->result,
156 static_cast<uint64>(0xFFFFFFFFL)); 157 static_cast<uint64>(0xFFFFFFFFL));
157 break; 158 break;
158 case GL_LATENCY_QUERY_CHROMIUM: 159 case GL_LATENCY_QUERY_CHROMIUM:
159 DCHECK(info_.sync->result >= client_begin_time_us_); 160 DCHECK(info_.sync->result >= client_begin_time_us_);
160 result_ = std::min(info_.sync->result - client_begin_time_us_, 161 result_ = std::min(info_.sync->result - client_begin_time_us_,
161 static_cast<uint64>(0xFFFFFFFFL)); 162 static_cast<uint64>(0xFFFFFFFFL));
162 break; 163 break;
163 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: 164 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM:
164 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: 165 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
165 default: 166 default:
166 result_ = info_.sync->result; 167 result_ = info_.sync->result;
167 break; 168 break;
168 } 169 }
169 state_ = kComplete; 170 state_ = kComplete;
170 } else { 171 } else {
171 if (!flushed_) { 172 uint32 flush_generation = helper->flush_generation();
172 // TODO(gman): We could reduce the number of flushes by having a 173 if (!(flush_generation>last_flush_)) {
173 // flush count, recording that count at the time we insert the
174 // EndQuery command and then only flushing here if we've have not
175 // passed that count yet.
176 flushed_ = true;
177 helper->Flush(); 174 helper->Flush();
175 last_flush_ = helper->flush_generation();
Zhenyao Mo 2014/04/08 21:13:56 My apology for not catching this earlier, but this
rptr 2014/04/08 22:44:16 Done. Problem was updating flush_count_ here. we s
178 } else { 176 } else {
179 // Insert no-ops so that eventually the GPU process will see more work. 177 // Insert no-ops so that eventually the GPU process will see more work.
180 helper->Noop(1); 178 helper->Noop(1);
181 } 179 }
182 } 180 }
183 } 181 }
184 return state_ == kComplete; 182 return state_ == kComplete;
185 } 183 }
186 184
187 uint32 QueryTracker::Query::GetResult() const { 185 uint32 QueryTracker::Query::GetResult() const {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 253 }
256 254
257 query_sync_manager_.Free(query->info_); 255 query_sync_manager_.Free(query->info_);
258 it = removed_queries_.erase(it); 256 it = removed_queries_.erase(it);
259 delete query; 257 delete query;
260 } 258 }
261 } 259 }
262 260
263 } // namespace gles2 261 } // namespace gles2
264 } // namespace gpu 262 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/query_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698