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

Side by Side Diff: gpu/command_buffer/service/query_manager.cc

Issue 16831004: Perform glReadPixels with PBOs in the gpu, if PBOs are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix cc_unittests Created 7 years, 5 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 | Annotate | Revision Log
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/service/query_manager.h" 5 #include "gpu/command_buffer/service/query_manager.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 mem_params.shared_memory = buffer.shared_memory; 216 mem_params.shared_memory = buffer.shared_memory;
217 mem_params.shm_size = buffer.size; 217 mem_params.shm_size = buffer.size;
218 mem_params.shm_data_offset = shm_offset(); 218 mem_params.shm_data_offset = shm_offset();
219 mem_params.shm_data_size = sizeof(QuerySync); 219 mem_params.shm_data_size = sizeof(QuerySync);
220 220
221 // Ask AsyncPixelTransferDelegate to run completion callback after all 221 // Ask AsyncPixelTransferDelegate to run completion callback after all
222 // previous async transfers are done. No guarantee that callback is run 222 // previous async transfers are done. No guarantee that callback is run
223 // on the current thread. 223 // on the current thread.
224 manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion( 224 manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion(
225 mem_params, 225 mem_params,
226 base::Bind(AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe, 226 base::Bind(&AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe,
227 submit_count)); 227 submit_count));
228
229 return AddToPendingTransferQueue(submit_count); 228 return AddToPendingTransferQueue(submit_count);
230 } 229 }
231 230
232 bool AsyncPixelTransfersCompletedQuery::Process() { 231 bool AsyncPixelTransfersCompletedQuery::Process() {
233 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>( 232 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>(
234 shm_id(), shm_offset(), sizeof(*sync)); 233 shm_id(), shm_offset(), sizeof(*sync));
235 if (!sync) 234 if (!sync)
236 return false; 235 return false;
237 236
238 // Check if completion callback has been run. sync->process_count atomicity 237 // Check if completion callback has been run. sync->process_count atomicity
239 // is guaranteed as this is already used to notify client of a completed 238 // is guaranteed as this is already used to notify client of a completed
240 // query. 239 // query.
241 if (sync->process_count != submit_count()) 240 if (sync->process_count != submit_count())
242 return true; 241 return true;
243 242
244 UnmarkAsPending(); 243 UnmarkAsPending();
245 return true; 244 return true;
246 } 245 }
247 246
248 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { 247 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) {
249 if (!IsDeleted()) { 248 if (!IsDeleted()) {
250 MarkAsDeleted(); 249 MarkAsDeleted();
251 } 250 }
252 } 251 }
253 252
254 AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() { 253 AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() {
255 } 254 }
256 255
256 class AsyncReadPixelsCompletedQuery
257 : public QueryManager::Query,
258 public base::SupportsWeakPtr<AsyncReadPixelsCompletedQuery> {
259 public:
260 AsyncReadPixelsCompletedQuery(
261 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset);
262
263 virtual bool Begin() OVERRIDE;
264 virtual bool End(uint32 submit_count) OVERRIDE;
265 virtual bool Process() OVERRIDE;
266 virtual void Destroy(bool have_context) OVERRIDE;
267
268 protected:
269 void Complete();
270 virtual ~AsyncReadPixelsCompletedQuery();
271 };
272
273 AsyncReadPixelsCompletedQuery::AsyncReadPixelsCompletedQuery(
274 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset)
275 : Query(manager, target, shm_id, shm_offset) {
276 }
277
278 bool AsyncReadPixelsCompletedQuery::Begin() {
279 return true;
280 }
281
282 bool AsyncReadPixelsCompletedQuery::End(uint32 submit_count) {
283 manager()->decoder()->WaitForReadPixels(
284 base::Bind(&AsyncReadPixelsCompletedQuery::Complete,
285 AsWeakPtr()));
286
287 return AddToPendingTransferQueue(submit_count);
288 }
289
290 void AsyncReadPixelsCompletedQuery::Complete() {
291 MarkAsCompleted(1);
292 }
293
294 bool AsyncReadPixelsCompletedQuery::Process() {
295 return !pending();
296 }
297
298 void AsyncReadPixelsCompletedQuery::Destroy(bool /* have_context */) {
299 if (!IsDeleted()) {
300 MarkAsDeleted();
301 }
302 }
303
304 AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() {
305 }
306
307
257 class GetErrorQuery : public QueryManager::Query { 308 class GetErrorQuery : public QueryManager::Query {
258 public: 309 public:
259 GetErrorQuery( 310 GetErrorQuery(
260 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); 311 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset);
261 312
262 virtual bool Begin() OVERRIDE; 313 virtual bool Begin() OVERRIDE;
263 virtual bool End(uint32 submit_count) OVERRIDE; 314 virtual bool End(uint32 submit_count) OVERRIDE;
264 virtual bool Process() OVERRIDE; 315 virtual bool Process() OVERRIDE;
265 virtual void Destroy(bool have_context) OVERRIDE; 316 virtual void Destroy(bool have_context) OVERRIDE;
266 317
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 case GL_COMMANDS_ISSUED_CHROMIUM: 389 case GL_COMMANDS_ISSUED_CHROMIUM:
339 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset); 390 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset);
340 break; 391 break;
341 case GL_LATENCY_QUERY_CHROMIUM: 392 case GL_LATENCY_QUERY_CHROMIUM:
342 query = new CommandLatencyQuery(this, target, shm_id, shm_offset); 393 query = new CommandLatencyQuery(this, target, shm_id, shm_offset);
343 break; 394 break;
344 case GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM: 395 case GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM:
345 query = new AsyncPixelTransfersCompletedQuery( 396 query = new AsyncPixelTransfersCompletedQuery(
346 this, target, shm_id, shm_offset); 397 this, target, shm_id, shm_offset);
347 break; 398 break;
399 case GL_ASYNC_READ_PIXELS_COMPLETED_CHROMIUM:
400 query = new AsyncReadPixelsCompletedQuery(
401 this, target, shm_id, shm_offset);
402 break;
348 case GL_GET_ERROR_QUERY_CHROMIUM: 403 case GL_GET_ERROR_QUERY_CHROMIUM:
349 query = new GetErrorQuery(this, target, shm_id, shm_offset); 404 query = new GetErrorQuery(this, target, shm_id, shm_offset);
350 break; 405 break;
351 default: { 406 default: {
352 GLuint service_id = 0; 407 GLuint service_id = 0;
353 glGenQueriesARB(1, &service_id); 408 glGenQueriesARB(1, &service_id);
354 DCHECK_NE(0u, service_id); 409 DCHECK_NE(0u, service_id);
355 query = new AllSamplesPassedQuery( 410 query = new AllSamplesPassedQuery(
356 this, target, shm_id, shm_offset, service_id); 411 this, target, shm_id, shm_offset, service_id);
357 break; 412 break;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 bool QueryManager::EndQuery(Query* query, uint32 submit_count) { 631 bool QueryManager::EndQuery(Query* query, uint32 submit_count) {
577 DCHECK(query); 632 DCHECK(query);
578 if (!RemovePendingQuery(query)) { 633 if (!RemovePendingQuery(query)) {
579 return false; 634 return false;
580 } 635 }
581 return query->End(submit_count); 636 return query->End(submit_count);
582 } 637 }
583 638
584 } // namespace gles2 639 } // namespace gles2
585 } // namespace gpu 640 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h ('k') | gpu/config/gpu_driver_bug_list_json.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698