Skip to content

Commit

Permalink
Don't call GL query functions unless the extensions are present.
Browse files Browse the repository at this point in the history
Validate that the OpenGL query extensions are present before calling the
entry points in gl(Begin|End|Gen|Delete)Queries.  Some operations like
glGenQueries are no-oped because the command decoder still emulates some
query types without native support.

BUG=1026911

Change-Id: I09f88aa0f7cc5be3812595892cb1c1c76900ce81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929432
Reviewed-by: James Darpinian <jdarpinian@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721229}
  • Loading branch information
vonture authored and Commit Bot committed Dec 3, 2019
1 parent a30ddd4 commit 09b55b1
Showing 1 changed file with 53 additions and 14 deletions.
67 changes: 53 additions & 14 deletions gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3380,10 +3380,19 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage2DImageCHROMIUM(
error::Error GLES2DecoderPassthroughImpl::DoGenQueriesEXT(
GLsizei n,
volatile GLuint* queries) {
return GenHelper(n, queries, &query_id_map_,
[this](GLsizei n, GLuint* queries) {
api()->glGenQueriesFn(n, queries);
});
return GenHelper(
n, queries, &query_id_map_, [this](GLsizei n, GLuint* queries) {
if (feature_info_->feature_flags().occlusion_query_boolean) {
// glGenQueries is not loaded unless GL_EXT_occlusion_query_boolean is
// present. All queries must be emulated so they don't need to be
// generated.
api()->glGenQueriesFn(n, queries);
} else {
for (GLsizei i = 0; i < n; i++) {
queries[i] = 0;
}
}
});
}

error::Error GLES2DecoderPassthroughImpl::DoDeleteQueriesEXT(
Expand Down Expand Up @@ -3419,10 +3428,16 @@ error::Error GLES2DecoderPassthroughImpl::DoDeleteQueriesEXT(

RemovePendingQuery(query_service_id);
}
return DeleteHelper(queries_copy.size(), queries_copy.data(), &query_id_map_,
[this](GLsizei n, GLuint* queries) {
api()->glDeleteQueriesFn(n, queries);
});
return DeleteHelper(
queries_copy.size(), queries_copy.data(), &query_id_map_,
[this](GLsizei n, GLuint* queries) {
if (feature_info_->feature_flags().occlusion_query_boolean) {
// glDeleteQueries is not loaded unless GL_EXT_occlusion_query_boolean
// is present. All queries must be emulated so they don't need to be
// deleted.
api()->glDeleteQueriesFn(n, queries);
}
});
}

error::Error GLES2DecoderPassthroughImpl::DoQueryCounterEXT(
Expand All @@ -3441,14 +3456,25 @@ error::Error GLES2DecoderPassthroughImpl::DoQueryCounterEXT(

GLuint service_id = GetQueryServiceID(id, &query_id_map_);

// Flush all previous errors
CheckErrorCallbackState();
if (IsEmulatedQueryTarget(target)) {
DCHECK_EQ(target,
static_cast<GLenum>(GL_COMMANDS_ISSUED_TIMESTAMP_CHROMIUM));
} else {
// glQueryCounter is not loaded unless GL_EXT_disjoint_timer_query is present
if (!feature_info_->feature_flags().ext_disjoint_timer_query) {
InsertError(GL_INVALID_ENUM, "Invalid query target.");
return error::kNoError;
}

api()->glQueryCounterFn(service_id, target);
// Flush all previous errors
CheckErrorCallbackState();

// Check if a new error was generated
if (CheckErrorCallbackState()) {
return error::kNoError;
api()->glQueryCounterFn(service_id, target);

// Check if a new error was generated
if (CheckErrorCallbackState()) {
return error::kNoError;
}
}

QueryInfo* query_info = &query_info_map_[service_id];
Expand Down Expand Up @@ -3507,6 +3533,13 @@ error::Error GLES2DecoderPassthroughImpl::DoBeginQueryEXT(
return error::kNoError;
}
} else {
// glBeginQuery is not loaded unless GL_EXT_occlusion_query_boolean is
// present
if (!feature_info_->feature_flags().occlusion_query_boolean) {
InsertError(GL_INVALID_ENUM, "Invalid query target.");
return error::kNoError;
}

// Flush all previous errors
CheckErrorCallbackState();

Expand Down Expand Up @@ -3556,6 +3589,12 @@ error::Error GLES2DecoderPassthroughImpl::DoEndQueryEXT(GLenum target,
query_service_id);
}
} else {
// glEndQuery is not loaded unless GL_EXT_occlusion_query_boolean is present
if (!feature_info_->feature_flags().occlusion_query_boolean) {
InsertError(GL_INVALID_ENUM, "Invalid query target.");
return error::kNoError;
}

// Flush all previous errors
CheckErrorCallbackState();

Expand Down

0 comments on commit 09b55b1

Please sign in to comment.