diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-25 01:51:13 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-25 01:51:13 +0000 |
commit | d35e6a7278ce43a8f211a056335a07133405010a (patch) | |
tree | 5a8544840d19a711082bac01437a5fdfc633ef0a /gpu | |
parent | fc6b0c0bf4252ebbe46f38c427498ea3b906ecdb (diff) | |
download | chromium_src-d35e6a7278ce43a8f211a056335a07133405010a.zip chromium_src-d35e6a7278ce43a8f211a056335a07133405010a.tar.gz chromium_src-d35e6a7278ce43a8f211a056335a07133405010a.tar.bz2 |
Make glGetQueryObjectuivEXT return true for GL_QUERY_RESULT_AVAILABLE_EXT
This is so a client waiting for the result to be available
does not wait forever if the context is lost.
BUG=144731
Review URL: https://chromiumcodereview.appspot.com/10883036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper.cc | 8 | ||||
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper_test.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 21 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/client/query_tracker.cc | 3 |
6 files changed, 29 insertions, 17 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc index 3eba54f..3dcc318 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper.cc @@ -22,9 +22,17 @@ CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) last_put_sent_(0), commands_issued_(0), usable_(true), + context_lost_(false), last_flush_time_(0) { } +bool CommandBufferHelper::IsContextLost() { + if (!context_lost_) { + context_lost_ = error::IsError(command_buffer()->GetLastError()); + } + return context_lost_; +} + bool CommandBufferHelper::AllocateRingBuffer() { if (!usable()) { return false; diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h index 1ba1bf7..9922794 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.h +++ b/gpu/command_buffer/client/cmd_buffer_helper.h @@ -44,6 +44,9 @@ class GPU_EXPORT CommandBufferHelper { // buffer. bool Initialize(int32 ring_buffer_size); + // True if the context is lost. + bool IsContextLost(); + // Asynchronously flushes the commands, setting the put pointer to let the // buffer interface know that new commands have been added. After a flush // returns, the command buffer service is aware of all pending commands. @@ -288,6 +291,7 @@ class GPU_EXPORT CommandBufferHelper { int32 last_put_sent_; int commands_issued_; bool usable_; + bool context_lost_; // Using C runtime instead of base because this file cannot depend on base. clock_t last_flush_time_; diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc index a180c96..927f4a2 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc @@ -352,4 +352,10 @@ TEST_F(CommandBufferHelperTest, Noop) { } } +TEST_F(CommandBufferHelperTest, IsContextLost) { + EXPECT_FALSE(helper_->IsContextLost()); + command_buffer_->SetParseError(error::kGenericError); + EXPECT_TRUE(helper_->IsContextLost()); +} + } // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 1f31f8c..604d3d9 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -422,8 +422,7 @@ GLES2Implementation::GLES2Implementation( debug_(false), use_count_(0), current_query_(NULL), - error_message_callback_(NULL), - context_lost_(false) { + error_message_callback_(NULL) { GPU_DCHECK(helper); GPU_DCHECK(transfer_buffer); @@ -1097,12 +1096,13 @@ void GLES2Implementation::Finish() { } bool GLES2Implementation::MustBeContextLost() { - if (!context_lost_) { + bool context_lost = helper_->IsContextLost(); + if (!context_lost) { FinishHelper(); - context_lost_ = error::IsError(helper_->command_buffer()->GetLastError()); + context_lost = helper_->IsContextLost(); } - GPU_CHECK(context_lost_); - return context_lost_; + GPU_CHECK(context_lost); + return context_lost; } void GLES2Implementation::FinishHelper() { @@ -3088,7 +3088,7 @@ void GLES2Implementation::DeleteQueriesEXTHelper( MustBeContextLost(); } } - query_tracker_->RemoveQuery(queries[ii], context_lost_); + query_tracker_->RemoveQuery(queries[ii], helper_->IsContextLost()); } helper_->DeleteQueriesEXTImmediate(n, queries); } @@ -3153,7 +3153,7 @@ void GLES2Implementation::EndQueryEXT(GLenum target) { GPU_CLIENT_LOG("[" << GetLogPrefix() << "] EndQueryEXT(" << GLES2Util::GetStringQueryTarget(target) << ")"); // Don't do anything if the context is lost. - if (context_lost_) { + if (helper_->IsContextLost()) { return; } @@ -3196,11 +3196,6 @@ void GLES2Implementation::GetQueryObjectuivEXT( << GLES2Util::GetStringQueryObjectParameter(pname) << ", " << static_cast<const void*>(params) << ")"); - // exit if the context is lost. - if (context_lost_) { - return; - } - QueryTracker::Query* query = query_tracker_->GetQuery(id); if (!query) { SetGLError(GL_INVALID_OPERATION, "glQueryObjectuivEXT", "unknown query id"); diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 1685ba0..1a05ff9 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -468,7 +468,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation { void FinishHelper(); - // Checks if the context is lost. + // Asserts that the context is lost. // NOTE: This is an expensive call and should only be called // for error checking. bool MustBeContextLost(); @@ -567,8 +567,6 @@ class GLES2_IMPL_EXPORT GLES2Implementation { ErrorMessageCallback* error_message_callback_; - bool context_lost_; - DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); }; diff --git a/gpu/command_buffer/client/query_tracker.cc b/gpu/command_buffer/client/query_tracker.cc index d57d416..71017ff 100644 --- a/gpu/command_buffer/client/query_tracker.cc +++ b/gpu/command_buffer/client/query_tracker.cc @@ -109,7 +109,8 @@ void QueryTracker::Query::End(GLES2Implementation* gl) { bool QueryTracker::Query::CheckResultsAvailable( CommandBufferHelper* helper) { if (Pending()) { - if (info_.sync->process_count == submit_count_) { + if (info_.sync->process_count == submit_count_ || + helper->IsContextLost()) { // Need a MemoryBarrier here so that sync->result read after // sync->process_count. gpu::MemoryBarrier(); |