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

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

Issue 1315713007: gpu: Reduce GL context switches used to check pending queries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: webview fix Created 5 years, 3 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
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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 QueryManager* GetQueryManager() override { return query_manager_.get(); } 660 QueryManager* GetQueryManager() override { return query_manager_.get(); }
661 VertexArrayManager* GetVertexArrayManager() override { 661 VertexArrayManager* GetVertexArrayManager() override {
662 return vertex_array_manager_.get(); 662 return vertex_array_manager_.get();
663 } 663 }
664 ImageManager* GetImageManager() override { return image_manager_.get(); } 664 ImageManager* GetImageManager() override { return image_manager_.get(); }
665 665
666 ValuebufferManager* GetValuebufferManager() override { 666 ValuebufferManager* GetValuebufferManager() override {
667 return valuebuffer_manager(); 667 return valuebuffer_manager();
668 } 668 }
669 669
670 bool ProcessPendingQueries(bool did_finish) override; 670 bool HasPendingQueries() const override;
671 void ProcessPendingQueries(bool did_finish) override;
671 672
672 bool HasMoreIdleWork() override; 673 bool HasMoreIdleWork() const override;
673 void PerformIdleWork() override; 674 void PerformIdleWork() override;
674 675
675 void WaitForReadPixels(base::Closure callback) override; 676 void WaitForReadPixels(base::Closure callback) override;
676 677
677 void SetResizeCallback( 678 void SetResizeCallback(
678 const base::Callback<void(gfx::Size, float)>& callback) override; 679 const base::Callback<void(gfx::Size, float)>& callback) override;
679 680
680 Logger* GetLogger() override; 681 Logger* GetLogger() override;
681 682
682 void BeginDecoding() override; 683 void BeginDecoding() override;
(...skipping 11201 matching lines...) Expand 10 before | Expand all | Expand 10 after
11884 return true; 11885 return true;
11885 } 11886 }
11886 11887
11887 void GLES2DecoderImpl::DeleteQueriesEXTHelper( 11888 void GLES2DecoderImpl::DeleteQueriesEXTHelper(
11888 GLsizei n, const GLuint* client_ids) { 11889 GLsizei n, const GLuint* client_ids) {
11889 for (GLsizei ii = 0; ii < n; ++ii) { 11890 for (GLsizei ii = 0; ii < n; ++ii) {
11890 query_manager_->RemoveQuery(client_ids[ii]); 11891 query_manager_->RemoveQuery(client_ids[ii]);
11891 } 11892 }
11892 } 11893 }
11893 11894
11894 bool GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) { 11895 bool GLES2DecoderImpl::HasPendingQueries() const {
11895 if (query_manager_.get() == NULL) { 11896 return query_manager_.get() && query_manager_->HavePendingQueries();
11896 return false; 11897 }
11897 } 11898
11898 if (!query_manager_->ProcessPendingQueries(did_finish)) { 11899 void GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) {
11900 if (!query_manager_.get())
dshwang 2015/09/01 08:56:10 if (!HasPendingQueries())
reveman 2015/09/01 15:54:11 It's up to the caller to do that check if needed.
11901 return;
11902 if (!query_manager_->ProcessPendingQueries(did_finish))
11899 current_decoder_error_ = error::kOutOfBounds; 11903 current_decoder_error_ = error::kOutOfBounds;
11900 }
11901 return query_manager_->HavePendingQueries();
11902 } 11904 }
11903 11905
11904 // Note that if there are no pending readpixels right now, 11906 // Note that if there are no pending readpixels right now,
11905 // this function will call the callback immediately. 11907 // this function will call the callback immediately.
11906 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) { 11908 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) {
11907 if (features().use_async_readpixels && !pending_readpixel_fences_.empty()) { 11909 if (features().use_async_readpixels && !pending_readpixel_fences_.empty()) {
11908 pending_readpixel_fences_.back()->callbacks.push_back(callback); 11910 pending_readpixel_fences_.back()->callbacks.push_back(callback);
11909 } else { 11911 } else {
11910 callback.Run(); 11912 callback.Run();
11911 } 11913 }
11912 } 11914 }
11913 11915
11914 void GLES2DecoderImpl::ProcessPendingReadPixels(bool did_finish) { 11916 void GLES2DecoderImpl::ProcessPendingReadPixels(bool did_finish) {
11915 // Note: |did_finish| guarantees that the GPU has passed the fence but 11917 // Note: |did_finish| guarantees that the GPU has passed the fence but
11916 // we cannot assume that GLFence::HasCompleted() will return true yet as 11918 // we cannot assume that GLFence::HasCompleted() will return true yet as
11917 // that's not guaranteed by all GLFence implementations. 11919 // that's not guaranteed by all GLFence implementations.
11918 while (!pending_readpixel_fences_.empty() && 11920 while (!pending_readpixel_fences_.empty() &&
11919 (did_finish || 11921 (did_finish ||
11920 pending_readpixel_fences_.front()->fence->HasCompleted())) { 11922 pending_readpixel_fences_.front()->fence->HasCompleted())) {
11921 std::vector<base::Closure> callbacks = 11923 std::vector<base::Closure> callbacks =
11922 pending_readpixel_fences_.front()->callbacks; 11924 pending_readpixel_fences_.front()->callbacks;
11923 pending_readpixel_fences_.pop(); 11925 pending_readpixel_fences_.pop();
11924 for (size_t i = 0; i < callbacks.size(); i++) { 11926 for (size_t i = 0; i < callbacks.size(); i++) {
11925 callbacks[i].Run(); 11927 callbacks[i].Run();
11926 } 11928 }
11927 } 11929 }
11928 } 11930 }
11929 11931
11930 bool GLES2DecoderImpl::HasMoreIdleWork() { 11932 bool GLES2DecoderImpl::HasMoreIdleWork() const {
11931 return !pending_readpixel_fences_.empty() || 11933 return !pending_readpixel_fences_.empty() ||
11932 gpu_tracer_->HasTracesToProcess(); 11934 gpu_tracer_->HasTracesToProcess();
11933 } 11935 }
11934 11936
11935 void GLES2DecoderImpl::PerformIdleWork() { 11937 void GLES2DecoderImpl::PerformIdleWork() {
11936 gpu_tracer_->ProcessTraces(); 11938 gpu_tracer_->ProcessTraces();
11937 ProcessPendingReadPixels(false); 11939 ProcessPendingReadPixels(false);
11938 } 11940 }
11939 11941
11940 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32 immediate_data_size, 11942 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32 immediate_data_size,
(...skipping 2726 matching lines...) Expand 10 before | Expand all | Expand 10 after
14667 return error::kNoError; 14669 return error::kNoError;
14668 } 14670 }
14669 14671
14670 // Include the auto-generated part of this file. We split this because it means 14672 // Include the auto-generated part of this file. We split this because it means
14671 // we can easily edit the non-auto generated parts right here in this file 14673 // we can easily edit the non-auto generated parts right here in this file
14672 // instead of having to edit some template or the code generator. 14674 // instead of having to edit some template or the code generator.
14673 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 14675 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
14674 14676
14675 } // namespace gles2 14677 } // namespace gles2
14676 } // namespace gpu 14678 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698