Commit 363f2431 authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

ExitCommandProcessingEarly after Shader::DoCompile

Shader::DoCompile is a source of frequent watchdog hangs (it involves
both ANGLE shader translation, as well as driver compilation steps).

Adding ExitCommandProcessingEarly after any calls to Shader::DoCompile.

Bug: 844780
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I58eae185384db7859f9ab451496e25da7c556c9c
Reviewed-on: https://chromium-review.googlesource.com/1144530Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577028}
parent 3fbccfbc
......@@ -2360,6 +2360,9 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
void ReadBackBuffersIntoShadowCopies(
base::flat_set<scoped_refptr<Buffer>> buffers_to_shadow_copy);
// Compiles the given shader and exits command processing early.
void CompileShaderAndExitCommandProcessingEarly(Shader* shader);
// Generate a member function prototype for each command in an automated and
// typesafe way.
#define GLES2_CMD_OP(name) \
......@@ -11030,7 +11033,7 @@ void GLES2DecoderImpl::DoGetShaderiv(GLuint shader_id,
case GL_COMPILE_STATUS:
case GL_INFO_LOG_LENGTH:
case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
shader->DoCompile();
CompileShaderAndExitCommandProcessingEarly(shader);
break;
default:
......@@ -11096,7 +11099,7 @@ error::Error GLES2DecoderImpl::HandleGetTranslatedShaderSourceANGLE(
}
// Make sure translator has been utilized in compile.
shader->DoCompile();
CompileShaderAndExitCommandProcessingEarly(shader);
bucket->SetFromString(shader->translated_source().c_str());
return error::kNoError;
......@@ -11135,7 +11138,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
}
// Shader must be compiled in order to get the info log.
shader->DoCompile();
CompileShaderAndExitCommandProcessingEarly(shader);
bucket->SetFromString(shader->log_info().c_str());
return error::kNoError;
......@@ -20251,6 +20254,21 @@ void GLES2DecoderImpl::DoSetReadbackBufferShadowAllocationINTERNAL(
writes_submitted_but_not_completed_.insert(buffer);
}
void GLES2DecoderImpl::CompileShaderAndExitCommandProcessingEarly(
Shader* shader) {
// No need to call DoCompile or exit command processing early if the call
// to DoCompile will be a no-op.
if (!shader->CanCompile())
return;
shader->DoCompile();
// Shader compilation can be very slow (see https://crbug.com/844780), Exit
// command processing to allow for context preemption and GPU watchdog
// checks.
ExitCommandProcessingEarly();
}
// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
// instead of having to edit some template or the code generator.
......
......@@ -75,9 +75,7 @@ void Shader::RequestCompile(scoped_refptr<ShaderTranslatorInterface> translator,
}
void Shader::DoCompile() {
// We require that RequestCompile() must be called before DoCompile(),
// so we can return early if the shader state is not what we expect.
if (shader_state_ != kShaderStateCompileRequested) {
if (!CanCompile()) {
return;
}
......
......@@ -53,6 +53,9 @@ class GPU_GLES2_EXPORT Shader : public base::RefCounted<Shader> {
void RequestCompile(scoped_refptr<ShaderTranslatorInterface> translator,
TranslatedShaderSourceType type);
// Returns true if we are ready to call DoCompile. If we have not yet called
// RequestCompile or if we've already compiled, returns false.
bool CanCompile() { return shader_state_ == kShaderStateCompileRequested; }
void DoCompile();
void RefreshTranslatedShaderSource();
......
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