Skip to content

Commit

Permalink
Add LINK_STATUS to completion query
Browse files Browse the repository at this point in the history
This stores program LINK_STATUS to the GL_QUERY_RESULT of
GL_PROGRAM_COMPLETION_QUERY_CHROMIUM. WebGL useProgram checks
the status before using it. By caching this status, useProgram
no longer stalls on the round-trip to the GPU thread.

Bug: 962337
Change-Id: Ifcc15044b1e6e6813e0599d90a76556b2401396a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1607573
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661134}
  • Loading branch information
jchen10 authored and Commit Bot committed May 18, 2019
1 parent be8d487 commit 38c637e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
7 changes: 6 additions & 1 deletion gpu/GLES2/extensions/CHROMIUM/CHROMIUM_completion_query.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ Overview
glEndQueryEXT(PROGRAM_COMPLETION_QUERY_CHROMIUM);
GLuint available = 0u;
glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE, &available);
if (available)
{
GLuint result = 0u;
glGetQueryObjectuivEXT(query, GL_QUERY_RESULT, &result);
}
If 'available' returns true, that's equivalent to COMPLETION_STATUS_KHR
returning true.
returning true. Then LINK_STATUS can be obtained from 'result'.

New Procedures and Functions

Expand Down
7 changes: 6 additions & 1 deletion gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2156,8 +2156,13 @@ error::Error GLES2DecoderPassthroughImpl::ProcessQueries(bool did_finish) {
} else {
program_completion_query_deferred = true;
}
result = 0;
} else {
GLint link_status = 0;
api()->glGetProgramivFn(query.program_service_id, GL_LINK_STATUS,
&link_status);
result = link_status;
}
result = 0;
break;

default:
Expand Down
12 changes: 10 additions & 2 deletions third_party/blink/renderer/modules/webgl/webgl_program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@ void WebGLProgram::CacheInfoIfNeeded(WebGLRenderingContextBase* context) {
if (!object_)
return;
gpu::gles2::GLES2Interface* gl = context->ContextGL();
link_status_ = 0;
gl->GetProgramiv(object_, GL_LINK_STATUS, &link_status_);
GLint link_status = 0;
gl->GetProgramiv(object_, GL_LINK_STATUS, &link_status);
setLinkStatus(link_status);
}

void WebGLProgram::setLinkStatus(bool link_status) {
if (info_valid_)
return;

link_status_ = link_status;
if (link_status_ == GL_TRUE) {
required_transform_feedback_buffer_count_ =
required_transform_feedback_buffer_count_after_next_link_;
Expand Down
1 change: 1 addition & 0 deletions third_party/blink/renderer/modules/webgl/webgl_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WebGLProgram final : public WebGLSharedPlatform3DObject {
static WebGLProgram* Create(WebGLRenderingContextBase*);

bool LinkStatus(WebGLRenderingContextBase*);
void setLinkStatus(bool link_status);

bool CompletionStatus(WebGLRenderingContextBase*);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8210,6 +8210,11 @@ bool WebGLRenderingContextBase::checkProgramCompletionQueryAvailable(
GLuint available;
ContextGL()->GetQueryObjectuivEXT(id, GL_QUERY_RESULT_AVAILABLE,
&available);
if (available) {
GLuint result = 0u;
ContextGL()->GetQueryObjectuivEXT(id, GL_QUERY_RESULT, &result);
program->setLinkStatus(result);
}
*completed = (available == GL_TRUE);
return true;
}
Expand Down

0 comments on commit 38c637e

Please sign in to comment.