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

Unified Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 10830147: Handle CONTEXT LOST issue with Queries (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/gles2_implementation.cc
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index de8be7e762c3b0bf4b728130c9d1ae86aead5727..ce7b6f589ecc86161f167819a0cb5f7a6f02e73a 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");
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698