summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer')
-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);
};