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

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

Issue 732423002: Update from chromium https://crrev.com/304586 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
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"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 bool Begin() override; 401 bool Begin() override;
402 bool End(base::subtle::Atomic32 submit_count) override; 402 bool End(base::subtle::Atomic32 submit_count) override;
403 bool Process(bool did_finish) override; 403 bool Process(bool did_finish) override;
404 void Destroy(bool have_context) override; 404 void Destroy(bool have_context) override;
405 405
406 protected: 406 protected:
407 ~CommandsCompletedQuery() override; 407 ~CommandsCompletedQuery() override;
408 408
409 private: 409 private:
410 scoped_ptr<gfx::GLFence> fence_; 410 scoped_ptr<gfx::GLFence> fence_;
411 base::TimeTicks begin_time_;
411 }; 412 };
412 413
413 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager, 414 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager,
414 GLenum target, 415 GLenum target,
415 int32 shm_id, 416 int32 shm_id,
416 uint32 shm_offset) 417 uint32 shm_offset)
417 : Query(manager, target, shm_id, shm_offset) {} 418 : Query(manager, target, shm_id, shm_offset) {}
418 419
419 bool CommandsCompletedQuery::Begin() { return true; } 420 bool CommandsCompletedQuery::Begin() {
421 begin_time_ = base::TimeTicks::HighResNow();
422 return true;
423 }
420 424
421 bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) { 425 bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) {
422 fence_.reset(gfx::GLFence::Create()); 426 fence_.reset(gfx::GLFence::Create());
423 DCHECK(fence_); 427 DCHECK(fence_);
424 return AddToPendingQueue(submit_count); 428 return AddToPendingQueue(submit_count);
425 } 429 }
426 430
427 bool CommandsCompletedQuery::Process(bool did_finish) { 431 bool CommandsCompletedQuery::Process(bool did_finish) {
428 // Note: |did_finish| guarantees that the GPU has passed the fence but 432 // Note: |did_finish| guarantees that the GPU has passed the fence but
429 // we cannot assume that GLFence::HasCompleted() will return true yet as 433 // we cannot assume that GLFence::HasCompleted() will return true yet as
430 // that's not guaranteed by all GLFence implementations. 434 // that's not guaranteed by all GLFence implementations.
431 //
432 // TODO(reveman): Add UMA stats to determine how common it is that glFinish()
433 // needs to be called for these queries to complete. crbug.com/431845
434 if (!did_finish && fence_ && !fence_->HasCompleted()) 435 if (!did_finish && fence_ && !fence_->HasCompleted())
435 return true; 436 return true;
436 437
437 return MarkAsCompleted(0); 438 base::TimeDelta elapsed = base::TimeTicks::HighResNow() - begin_time_;
439 return MarkAsCompleted(elapsed.InMicroseconds());
438 } 440 }
439 441
440 void CommandsCompletedQuery::Destroy(bool have_context) { 442 void CommandsCompletedQuery::Destroy(bool have_context) {
441 if (have_context && !IsDeleted()) { 443 if (have_context && !IsDeleted()) {
442 fence_.reset(); 444 fence_.reset();
443 MarkAsDeleted(); 445 MarkAsDeleted();
444 } 446 }
445 } 447 }
446 448
447 CommandsCompletedQuery::~CommandsCompletedQuery() {} 449 CommandsCompletedQuery::~CommandsCompletedQuery() {}
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { 747 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) {
746 DCHECK(query); 748 DCHECK(query);
747 if (!RemovePendingQuery(query)) { 749 if (!RemovePendingQuery(query)) {
748 return false; 750 return false;
749 } 751 }
750 return query->End(submit_count); 752 return query->End(submit_count);
751 } 753 }
752 754
753 } // namespace gles2 755 } // namespace gles2
754 } // namespace gpu 756 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc ('k') | gpu/command_buffer/tests/gl_clear_framebuffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698