Commit 133ddca5 authored by gman@chromium.org's avatar gman@chromium.org

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
parent faaefd5b
......@@ -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");
......
......@@ -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);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment