Commit b5fa07d8 authored by jchen10's avatar jchen10 Committed by Commit Bot

ParallelCompile: Adjust the max compiler threads for WebGL

If the extension hasn't been requested, the limit is 2, otherwise
at least 4 and no more than half of hardware_concurrency().

Bug: 953687
Change-Id: I3051a4ee18b10c6c21487f7e06a6170aed1b5e87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1575970
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653669}
parent b4201eeb
......@@ -25,6 +25,8 @@
#include "third_party/blink/renderer/modules/webgl/khr_parallel_shader_compile.h"
#include <thread>
#include "gpu/command_buffer/client/gles2_interface.h"
namespace blink {
......@@ -34,8 +36,9 @@ KHRParallelShaderCompile::KHRParallelShaderCompile(
: WebGLExtension(context) {
context->ExtensionsUtil()->EnsureExtensionEnabled(
"GL_KHR_parallel_shader_compile");
// Use 2 background threads per WebGL context by default.
context->ContextGL()->MaxShaderCompilerThreadsKHR(2);
GLuint max_threads = std::max(4u, std::thread::hardware_concurrency() / 2);
context->ContextGL()->MaxShaderCompilerThreadsKHR(max_threads);
}
WebGLExtensionName KHRParallelShaderCompile::GetName() const {
......
......@@ -1226,6 +1226,11 @@ void WebGLRenderingContextBase::InitializeNewContext() {
for (int i = 0; i < kWebGLExtensionNameCount; ++i)
extension_enabled_[i] = false;
// This limits the count of threads if the extension is yet to be requested.
if (String(ContextGL()->GetString(GL_EXTENSIONS))
.Contains("GL_KHR_parallel_shader_compile")) {
ContextGL()->MaxShaderCompilerThreadsKHR(2);
}
is_web_gl2_formats_types_added_ = false;
is_web_gl2_tex_image_source_formats_types_added_ = false;
is_web_gl2_internal_formats_copy_tex_image_added_ = false;
......
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