diff --git a/third_party/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc b/third_party/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc index 132e1b3..df6818f 100644 --- a/third_party/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc +++ b/third_party/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc @@ -13,6 +13,7 @@ #include "gpu/command_buffer/client/gles2_interface.h" #include "third_party/blink/public/platform/web_graphics_context_3d_provider.h" #include "third_party/blink/renderer/bindings/modules/v8/webgl_any.h" +#include "third_party/blink/renderer/platform/graphics/managed_gpu_profile.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h" @@ -4774,8 +4775,13 @@ ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* script_state, GLenum pname) { if (isContextLost()) return ScriptValue::CreateNull(script_state->GetIsolate()); + const ManagedGPUProfile* managed_gpu_profile = GetManagedGPUProfile(); switch (pname) { case GL_SHADING_LANGUAGE_VERSION: { + if (managed_gpu_profile) { + return WebGLAny(script_state, + String(managed_gpu_profile->webgl_shading_language_webgl2)); + } return WebGLAny( script_state, StrCat({"WebGL GLSL ES 3.00 (", @@ -4783,6 +4789,10 @@ ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* script_state, ")"})); } case GL_VERSION: + if (managed_gpu_profile) { + return WebGLAny(script_state, + String(managed_gpu_profile->webgl_version_webgl2)); + } return WebGLAny( script_state, StrCat({"WebGL 2.0 (", String(ContextGL()->GetString(GL_VERSION)), diff --git a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc index 469fc4d..5103cf9 100644 --- a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc +++ b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc @@ -112,6 +112,7 @@ #include "third_party/blink/renderer/modules/webgl/webgl_debug_shaders.h" #include "third_party/blink/renderer/modules/webgl/webgl_depth_texture.h" #include "third_party/blink/renderer/modules/webgl/webgl_draw_buffers.h" +#include "third_party/blink/renderer/platform/graphics/managed_gpu_profile.h" #include "third_party/blink/renderer/modules/webgl/webgl_framebuffer.h" #include "third_party/blink/renderer/modules/webgl/webgl_lose_context.h" #include "third_party/blink/renderer/modules/webgl/webgl_program.h" @@ -3768,6 +3769,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state, GLenum pname) { if (isContextLost()) return ScriptValue::CreateNull(script_state->GetIsolate()); + const ManagedGPUProfile* managed_gpu_profile = GetManagedGPUProfile(); const int kIntZero = 0; switch (pname) { case GL_ACTIVE_TEXTURE: @@ -3899,6 +3901,10 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state, case GL_SCISSOR_TEST: return GetBooleanParameter(script_state, pname); case GL_SHADING_LANGUAGE_VERSION: + if (managed_gpu_profile) { + return WebGLAny(script_state, + String(managed_gpu_profile->webgl_shading_language_webgl1)); + } return WebGLAny( script_state, StrCat({"WebGL GLSL ES 1.0 (", @@ -3961,6 +3967,10 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state, case GL_VENDOR: return WebGLAny(script_state, String("WebKit")); case GL_VERSION: + if (managed_gpu_profile) { + return WebGLAny(script_state, + String(managed_gpu_profile->webgl_version_webgl1)); + } return WebGLAny( script_state, StrCat({"WebGL 1.0 (", String(ContextGL()->GetString(GL_VERSION)), @@ -3977,6 +3987,11 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state, return ScriptValue::CreateNull(script_state->GetIsolate()); case WebGLDebugRendererInfo::kUnmaskedRendererWebgl: if (ExtensionEnabled(kWebGLDebugRendererInfoName)) { + if (managed_gpu_profile) { + return WebGLAny( + script_state, + String(managed_gpu_profile->webgl_unmasked_renderer)); + } return WebGLAny(script_state, String(ContextGL()->GetString(GL_RENDERER))); } @@ -3986,6 +4001,11 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state, return ScriptValue::CreateNull(script_state->GetIsolate()); case WebGLDebugRendererInfo::kUnmaskedVendorWebgl: if (ExtensionEnabled(kWebGLDebugRendererInfoName)) { + if (managed_gpu_profile) { + return WebGLAny( + script_state, + String(managed_gpu_profile->webgl_unmasked_vendor)); + } return WebGLAny(script_state, String(ContextGL()->GetString(GL_VENDOR))); } diff --git a/third_party/blink/renderer/modules/webgpu/gpu.cc b/third_party/blink/renderer/modules/webgpu/gpu.cc index 4aae58a..d3837b9 100644 --- a/third_party/blink/renderer/modules/webgpu/gpu.cc +++ b/third_party/blink/renderer/modules/webgpu/gpu.cc @@ -38,6 +38,7 @@ #include "third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h" #include "third_party/blink/renderer/platform/graphics/gpu/webgpu_callback.h" #include "third_party/blink/renderer/platform/graphics/gpu/webgpu_cpp.h" +#include "third_party/blink/renderer/platform/graphics/managed_gpu_profile.h" #include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_provider_util.h" #include "third_party/blink/renderer/platform/heap/cross_thread_handle.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" @@ -138,6 +139,10 @@ const char GPU::kSupplementName[] = "GPU"; // static GPU* GPU::gpu(NavigatorBase& navigator) { + if (const ManagedGPUProfile* managed_gpu_profile = GetManagedGPUProfile(); + managed_gpu_profile && managed_gpu_profile->hide_webgpu) { + return nullptr; + } GPU* gpu = Supplement::From(navigator); if (!gpu) { gpu = MakeGarbageCollected(navigator); diff --git a/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc b/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc index c189005..e3658c5 100644 --- a/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc +++ b/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc @@ -22,6 +22,7 @@ #include "third_party/blink/renderer/modules/webgpu/gpu_supported_features.h" #include "third_party/blink/renderer/modules/webgpu/gpu_supported_limits.h" #include "third_party/blink/renderer/modules/webgpu/string_utils.h" +#include "third_party/blink/renderer/platform/graphics/managed_gpu_profile.h" #include "third_party/blink/renderer/platform/graphics/gpu/webgpu_callback.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" @@ -103,6 +104,14 @@ GPUAdapter::GPUAdapter( } description_ = String::FromUTF8(info.device); driver_ = String::FromUTF8(info.description); + if (const ManagedGPUProfile* managed_gpu_profile = GetManagedGPUProfile()) { + vendor_ = String::FromUTF8(managed_gpu_profile->webgpu_vendor); + architecture_ = + String::FromUTF8(managed_gpu_profile->webgpu_architecture); + device_ = String::FromUTF8(managed_gpu_profile->webgpu_device); + description_ = String::FromUTF8(managed_gpu_profile->webgpu_description); + driver_ = "Mesa 25.0"; + } if (supportsPropertiesD3D) { d3d_shader_model_ = d3dProperties.shaderModel; } diff --git a/third_party/blink/renderer/platform/graphics/managed_gpu_profile.h b/third_party/blink/renderer/platform/graphics/managed_gpu_profile.h new file mode 100644 index 0000000..0040ccc --- /dev/null +++ b/third_party/blink/renderer/platform/graphics/managed_gpu_profile.h @@ -0,0 +1,73 @@ +// Copyright 2026 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_MANAGED_GPU_PROFILE_H_ +#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_MANAGED_GPU_PROFILE_H_ + +#include +#include + +#include "base/environment.h" +#include "base/strings/string_util.h" + +namespace blink { + +struct ManagedGPUProfile { + const char* webgl_unmasked_vendor; + const char* webgl_unmasked_renderer; + const char* webgl_version_webgl1; + const char* webgl_version_webgl2; + const char* webgl_shading_language_webgl1; + const char* webgl_shading_language_webgl2; + const char* webgpu_vendor; + const char* webgpu_architecture; + const char* webgpu_device; + const char* webgpu_description; + bool hide_webgpu; +}; + +inline const ManagedGPUProfile* GetManagedGPUProfile() { + static const std::optional profile = [] { + auto environment = base::Environment::Create(); + std::optional selector = + environment->GetVar("BASTION_CHROMIUM_GPU_PROFILE"); + if (!selector) { + return std::optional{}; + } + + std::string selector_value = *selector; + base::TrimWhitespaceASCII(selector_value, base::TRIM_ALL, &selector_value); + if (selector_value.empty() || selector_value == "off") { + return std::optional{}; + } + + if (selector_value == "intel-mesa-hd-620" || + selector_value == "mesa-intel-hd-620") { + return std::optional{ManagedGPUProfile{ + "Intel Open Source Technology Center", + "Mesa DRI Intel(R) HD Graphics 620 (KBL GT2)", + "WebGL 1.0 (OpenGL ES 2.0 Chromium)", + "WebGL 2.0 (OpenGL ES 3.0 Chromium)", + "WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)", + "WebGL GLSL ES 3.00 (OpenGL ES GLSL ES 3.0 Chromium)", + "intel", + "gen-9", + "0x5916", + "Mesa DRI Intel(R) HD Graphics 620 (KBL GT2)", + true, + }}; + } + + return std::optional{}; + }(); + + if (!profile.has_value()) { + return nullptr; + } + return &profile.value(); +} + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_MANAGED_GPU_PROFILE_H_