summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-03 00:57:44 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-03 00:57:44 +0000
commit133ddca5e0dd084a830ca941f44790ee9d58fed2 (patch)
treed0cb255166338ec9f809950d35fc59163d98d3a1
parentfaaefd5b96f481183d938f1615c1768c5b29aca4 (diff)
downloadchromium_src-133ddca5e0dd084a830ca941f44790ee9d58fed2.zip
chromium_src-133ddca5e0dd084a830ca941f44790ee9d58fed2.tar.gz
chromium_src-133ddca5e0dd084a830ca941f44790ee9d58fed2.tar.bz2
If the context is lost allocation of query may fail so
certain things needed to be done. Hopefully this fixes these bugs. BUG=140116,139791 Review URL: https://chromiumcodereview.appspot.com/10830147 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149755 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc30
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h7
2 files changed, 35 insertions, 2 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index de8be7e..ce7b6f5 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -405,7 +405,8 @@ GLES2Implementation::GLES2Implementation(
debug_(false),
use_count_(0),
current_query_(NULL),
- error_message_callback_(NULL) {
+ error_message_callback_(NULL),
+ context_lost_(false) {
GPU_DCHECK(helper);
GPU_DCHECK(transfer_buffer);
GPU_CLIENT_LOG_CODE_BLOCK({
@@ -1068,6 +1069,15 @@ void GLES2Implementation::Finish() {
FinishHelper();
}
+bool GLES2Implementation::MustBeContextLost() {
+ if (!context_lost_) {
+ FinishHelper();
+ context_lost_ = error::IsError(helper_->command_buffer()->GetLastError());
+ }
+ GPU_CHECK(context_lost_);
+ return context_lost_;
+}
+
void GLES2Implementation::FinishHelper() {
GPU_CLIENT_LOG("[" << this << "] glFinish()");
TRACE_EVENT0("gpu", "GLES2::Finish");
@@ -3044,7 +3054,10 @@ void GLES2Implementation::DeleteQueriesEXTHelper(
for (GLsizei ii = 0; ii < n; ++ii) {
QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]);
if (query && query->Pending()) {
- GPU_CHECK(query->CheckResultsAvailable(helper_));
+ if (!query->CheckResultsAvailable(helper_)) {
+ // Should only get here on context lost.
+ MustBeContextLost();
+ }
}
query_tracker_->RemoveQuery(queries[ii]);
}
@@ -3091,6 +3104,10 @@ void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) {
QueryTracker::Query* query = query_tracker_->GetQuery(id);
if (!query) {
query = query_tracker_->CreateQuery(id, target);
+ if (!query) {
+ MustBeContextLost();
+ return;
+ }
} else if (query->target() != target) {
SetGLError(
GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
@@ -3106,6 +3123,10 @@ void GLES2Implementation::EndQueryEXT(GLenum target) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << this << "] EndQueryEXT("
<< GLES2Util::GetStringQueryTarget(target) << ")");
+ // Don't do anything if the context is lost.
+ if (context_lost_) {
+ return;
+ }
if (!current_query_) {
SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "no active query");
@@ -3146,6 +3167,11 @@ 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 9b07a32..a5d5e6a7 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -477,6 +477,11 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
void FinishHelper();
+ // Checks if the context is lost.
+ // NOTE: This is an expensive call and should only be called
+ // for error checking.
+ bool MustBeContextLost();
+
GLES2Util util_;
GLES2CmdHelper* helper_;
TransferBufferInterface* transfer_buffer_;
@@ -567,6 +572,8 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
ErrorMessageCallback* error_message_callback_;
+ bool context_lost_;
+
DISALLOW_COPY_AND_ASSIGN(GLES2Implementation);
};