Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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() { | |
| 420 return true; | |
| 421 } | |
| 422 | |
| 423 bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) { | |
| 424 fence_.reset(gfx::GLFence::CreateWithoutFlush()); | |
|
no sievers
2014/04/15 23:53:37
Make sure piman@ is ok with this being used here :
piman
2014/04/16 00:32:03
The client only forces a shallow flush, because th
reveman
2014/04/16 01:28:47
Ah, looked like QueryTracker::Query::CheckResultsA
| |
| 425 DCHECK(fence_); | |
|
piman
2014/04/16 00:32:03
gfx::GLFence::Create (with or without flush) will
reveman
2014/04/16 01:28:47
Got it.
| |
| 426 return AddToPendingQueue(submit_count); | |
| 427 } | |
| 428 | |
| 429 bool CommandsCompletedQuery::Process() { | |
| 430 if (fence_ && !fence_->HasCompleted()) | |
| 431 return true; | |
| 432 return MarkAsCompleted(0); | |
| 433 } | |
| 434 | |
| 435 void CommandsCompletedQuery::Destroy(bool have_context) { | |
| 436 if (have_context && !IsDeleted()) { | |
| 437 fence_.reset(); | |
| 438 MarkAsDeleted(); | |
| 439 } | |
| 440 } | |
| 441 | |
| 442 CommandsCompletedQuery::~CommandsCompletedQuery() {} | |
| 443 | |
| 392 QueryManager::QueryManager( | 444 QueryManager::QueryManager( |
| 393 GLES2Decoder* decoder, | 445 GLES2Decoder* decoder, |
| 394 FeatureInfo* feature_info) | 446 FeatureInfo* feature_info) |
| 395 : decoder_(decoder), | 447 : decoder_(decoder), |
| 396 use_arb_occlusion_query2_for_occlusion_query_boolean_( | 448 use_arb_occlusion_query2_for_occlusion_query_boolean_( |
| 397 feature_info->feature_flags( | 449 feature_info->feature_flags( |
| 398 ).use_arb_occlusion_query2_for_occlusion_query_boolean), | 450 ).use_arb_occlusion_query2_for_occlusion_query_boolean), |
| 399 use_arb_occlusion_query_for_occlusion_query_boolean_( | 451 use_arb_occlusion_query_for_occlusion_query_boolean_( |
| 400 feature_info->feature_flags( | 452 feature_info->feature_flags( |
| 401 ).use_arb_occlusion_query_for_occlusion_query_boolean), | 453 ).use_arb_occlusion_query_for_occlusion_query_boolean), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 query = new AsyncPixelTransfersCompletedQuery( | 489 query = new AsyncPixelTransfersCompletedQuery( |
| 438 this, target, shm_id, shm_offset); | 490 this, target, shm_id, shm_offset); |
| 439 break; | 491 break; |
| 440 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: | 492 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
| 441 query = new AsyncReadPixelsCompletedQuery( | 493 query = new AsyncReadPixelsCompletedQuery( |
| 442 this, target, shm_id, shm_offset); | 494 this, target, shm_id, shm_offset); |
| 443 break; | 495 break; |
| 444 case GL_GET_ERROR_QUERY_CHROMIUM: | 496 case GL_GET_ERROR_QUERY_CHROMIUM: |
| 445 query = new GetErrorQuery(this, target, shm_id, shm_offset); | 497 query = new GetErrorQuery(this, target, shm_id, shm_offset); |
| 446 break; | 498 break; |
| 499 case GL_COMMANDS_COMPLETED_CHROMIUM: | |
| 500 query = new CommandsCompletedQuery(this, target, shm_id, shm_offset); | |
| 501 break; | |
| 447 default: { | 502 default: { |
| 448 GLuint service_id = 0; | 503 GLuint service_id = 0; |
| 449 glGenQueriesARB(1, &service_id); | 504 glGenQueriesARB(1, &service_id); |
| 450 DCHECK_NE(0u, service_id); | 505 DCHECK_NE(0u, service_id); |
| 451 query = new AllSamplesPassedQuery( | 506 query = new AllSamplesPassedQuery( |
| 452 this, target, shm_id, shm_offset, service_id); | 507 this, target, shm_id, shm_offset, service_id); |
| 453 break; | 508 break; |
| 454 } | 509 } |
| 455 } | 510 } |
| 456 std::pair<QueryMap::iterator, bool> result = | 511 std::pair<QueryMap::iterator, bool> result = |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { | 727 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { |
| 673 DCHECK(query); | 728 DCHECK(query); |
| 674 if (!RemovePendingQuery(query)) { | 729 if (!RemovePendingQuery(query)) { |
| 675 return false; | 730 return false; |
| 676 } | 731 } |
| 677 return query->End(submit_count); | 732 return query->End(submit_count); |
| 678 } | 733 } |
| 679 | 734 |
| 680 } // namespace gles2 | 735 } // namespace gles2 |
| 681 } // namespace gpu | 736 } // namespace gpu |
| OLD | NEW |