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

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

Issue 238933003: Re-land: gpu: Add CHROMIUM_sync_query extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove SyncQueryBasic test as no guarantee this extension is available 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 | 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/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/numerics/safe_math.h" 11 #include "base/numerics/safe_math.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "gpu/command_buffer/common/gles2_cmd_format.h" 14 #include "gpu/command_buffer/common/gles2_cmd_format.h"
15 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" 15 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
16 #include "gpu/command_buffer/service/error_state.h" 16 #include "gpu/command_buffer/service/error_state.h"
17 #include "gpu/command_buffer/service/feature_info.h" 17 #include "gpu/command_buffer/service/feature_info.h"
18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
19 #include "ui/gl/gl_fence.h"
19 20
20 namespace gpu { 21 namespace gpu {
21 namespace gles2 { 22 namespace gles2 {
22 23
23 namespace { 24 namespace {
24 25
25 class AsyncPixelTransferCompletionObserverImpl 26 class AsyncPixelTransferCompletionObserverImpl
26 : public AsyncPixelTransferCompletionObserver { 27 : public AsyncPixelTransferCompletionObserver {
27 public: 28 public:
28 AsyncPixelTransferCompletionObserverImpl(base::subtle::Atomic32 submit_count) 29 AsyncPixelTransferCompletionObserverImpl(base::subtle::Atomic32 submit_count)
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 383
383 void GetErrorQuery::Destroy(bool /* have_context */) { 384 void GetErrorQuery::Destroy(bool /* have_context */) {
384 if (!IsDeleted()) { 385 if (!IsDeleted()) {
385 MarkAsDeleted(); 386 MarkAsDeleted();
386 } 387 }
387 } 388 }
388 389
389 GetErrorQuery::~GetErrorQuery() { 390 GetErrorQuery::~GetErrorQuery() {
390 } 391 }
391 392
393 class CommandsCompletedQuery : public QueryManager::Query {
394 public:
395 CommandsCompletedQuery(QueryManager* manager,
396 GLenum target,
397 int32 shm_id,
398 uint32 shm_offset);
399
400 // Overridden from QueryManager::Query:
401 virtual bool Begin() OVERRIDE;
402 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE;
403 virtual bool Process() OVERRIDE;
404 virtual void Destroy(bool have_context) OVERRIDE;
405
406 protected:
407 virtual ~CommandsCompletedQuery();
408
409 private:
410 scoped_ptr<gfx::GLFence> fence_;
411 };
412
413 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager,
414 GLenum target,
415 int32 shm_id,
416 uint32 shm_offset)
417 : Query(manager, target, shm_id, shm_offset) {}
418
419 bool CommandsCompletedQuery::Begin() { return true; }
420
421 bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) {
422 fence_.reset(gfx::GLFence::Create());
423 DCHECK(fence_);
424 return AddToPendingQueue(submit_count);
425 }
426
427 bool CommandsCompletedQuery::Process() {
428 if (fence_ && !fence_->HasCompleted())
429 return true;
430 return MarkAsCompleted(0);
431 }
432
433 void CommandsCompletedQuery::Destroy(bool have_context) {
434 if (have_context && !IsDeleted()) {
435 fence_.reset();
436 MarkAsDeleted();
437 }
438 }
439
440 CommandsCompletedQuery::~CommandsCompletedQuery() {}
441
392 QueryManager::QueryManager( 442 QueryManager::QueryManager(
393 GLES2Decoder* decoder, 443 GLES2Decoder* decoder,
394 FeatureInfo* feature_info) 444 FeatureInfo* feature_info)
395 : decoder_(decoder), 445 : decoder_(decoder),
396 use_arb_occlusion_query2_for_occlusion_query_boolean_( 446 use_arb_occlusion_query2_for_occlusion_query_boolean_(
397 feature_info->feature_flags( 447 feature_info->feature_flags(
398 ).use_arb_occlusion_query2_for_occlusion_query_boolean), 448 ).use_arb_occlusion_query2_for_occlusion_query_boolean),
399 use_arb_occlusion_query_for_occlusion_query_boolean_( 449 use_arb_occlusion_query_for_occlusion_query_boolean_(
400 feature_info->feature_flags( 450 feature_info->feature_flags(
401 ).use_arb_occlusion_query_for_occlusion_query_boolean), 451 ).use_arb_occlusion_query_for_occlusion_query_boolean),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 query = new AsyncPixelTransfersCompletedQuery( 487 query = new AsyncPixelTransfersCompletedQuery(
438 this, target, shm_id, shm_offset); 488 this, target, shm_id, shm_offset);
439 break; 489 break;
440 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: 490 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
441 query = new AsyncReadPixelsCompletedQuery( 491 query = new AsyncReadPixelsCompletedQuery(
442 this, target, shm_id, shm_offset); 492 this, target, shm_id, shm_offset);
443 break; 493 break;
444 case GL_GET_ERROR_QUERY_CHROMIUM: 494 case GL_GET_ERROR_QUERY_CHROMIUM:
445 query = new GetErrorQuery(this, target, shm_id, shm_offset); 495 query = new GetErrorQuery(this, target, shm_id, shm_offset);
446 break; 496 break;
497 case GL_COMMANDS_COMPLETED_CHROMIUM:
498 query = new CommandsCompletedQuery(this, target, shm_id, shm_offset);
499 break;
447 default: { 500 default: {
448 GLuint service_id = 0; 501 GLuint service_id = 0;
449 glGenQueriesARB(1, &service_id); 502 glGenQueriesARB(1, &service_id);
450 DCHECK_NE(0u, service_id); 503 DCHECK_NE(0u, service_id);
451 query = new AllSamplesPassedQuery( 504 query = new AllSamplesPassedQuery(
452 this, target, shm_id, shm_offset, service_id); 505 this, target, shm_id, shm_offset, service_id);
453 break; 506 break;
454 } 507 }
455 } 508 }
456 std::pair<QueryMap::iterator, bool> result = 509 std::pair<QueryMap::iterator, bool> result =
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { 725 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) {
673 DCHECK(query); 726 DCHECK(query);
674 if (!RemovePendingQuery(query)) { 727 if (!RemovePendingQuery(query)) {
675 return false; 728 return false;
676 } 729 }
677 return query->End(submit_count); 730 return query->End(submit_count);
678 } 731 }
679 732
680 } // namespace gles2 733 } // namespace gles2
681 } // namespace gpu 734 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698