简体   繁体   中英

How does Chrome support webgl on macOS?

I found libGLESv2.dylib libswiftshader_libGLESv2.dylib libvk_swiftshader.dylib in Chrome.app. And in https://webglreport.com/?v=2 it says:

Vendor: WebKit
Renderer:   WebKit WebGL
Unmasked Vendor:    ATI Technologies Inc.
Unmasked Renderer:  AMD Radeon Pro 560X OpenGL Engine
Antialiasing:   Available
ANGLE:  No

I heard that chrome uses angle on windows. Here angle is not used on macOS. So how does chrome run webgl?

There is no way to detect ANGLE. WebGLReport guesses and its guess are wrong. Here is their code

function getAngle(gl) {
  var lineWidthRange = describeRange(gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE));

  // Heuristic: ANGLE is only on Windows, not in IE, and not in Edge, and does not implement line width greater than one.
  var angle = ((navigator.platform === 'Win32') || (navigator.platform === 'Win64')) &&
    (gl.getParameter(gl.RENDERER) !== 'Internet Explorer') &&
    (gl.getParameter(gl.RENDERER) !== 'Microsoft Edge') &&
    (lineWidthRange === describeRange([1, 1]));

  if (angle) {
    // Heuristic: D3D11 backend does not appear to reserve uniforms like the D3D9 backend, e.g.,
    // D3D11 may have 1024 uniforms per stage, but D3D9 has 254 and 221.
    //
    // We could also test for WEBGL_draw_buffers, but many systems do not have it yet
    // due to driver bugs, etc.
    if (isPowerOfTwo(gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS)) && isPowerOfTwo(gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS))) {
      return 'Yes, D3D11';
    } else {
      return 'Yes, D3D9';
    }
  }

  return 'No';
}

It's wrong and years out of date.

The first guess is looking at lineWidthRange which even when they wrote it was only a guess. The spec says it is valid to have only lines of width 1. Back when WebGL shipped it was common that ANGLE supported just lines of size 1 and OpenGL supported others. But, that changed when WebGL2 shipped because WebGL2, when running on top of desktop OpenGL, required using the "Core" profile and the "Core" profile disallows lines other than size 1 period.

From the spec

E.2.1 Deprecated But Still Supported Features

The following features are deprecated, but still present in the core profile. They may be removed from a future version of OpenGL, and are removed in a forwardcompatible context implementing the core profile.

  • Wide lines - LineWidth values greater than 1.0 will generate an INVALID_VALUE error

Their second guess is looking at the browser. That's obviously no longer valid. Edge is now based on Chromium and further Safari now uses ANGLE as well .

The last one is one more guess that ANGLE is being used because it assumes ANGLE is running on top of D3D and that certain limits were therefore special but ANGLE is now used on all platforms and can run on top of Desktop OpenGL, D3D, OpenGL ES, Metal, and Vulkan. From the chart on the angle project as of January 2021

Level of OpenGL ES support via backing renderers

Direct3D 9 Direct3D 11 Desktop GL GL ES Vulkan Metal
OpenGL ES 2.0 complete complete complete complete complete complete
OpenGL ES 3.0 complete complete complete complete in progress
OpenGL ES 3.1 incomplete complete complete complete
OpenGL ES 3.2 in progress in progress in progress

And here is the list of platforms ANGLE currently supports

Platform support via backing renderers

Direct3D 9 Direct3D 11 Desktop GL GL ES Vulkan Metal
Windows complete complete complete complete complete
Linux complete complete
Mac OS X complete in progress
iOS planned
Chrome OS complete planned
Android complete complete
GGP (Stadia) complete
Fuchsia in progress

So, you shouldn't believe WebGLReport. Maybe you should go file a bug.

Chrome is able to use desktop OpenGL on MacOS to run WebGL but AFAIK ANGLE is used on all Chrome platforms at this point in time including MacOS. ANGLE was even added to Safari recently to enable Safari's WebGL2 support and to fix a bunch of bugs with their WebGL1 support

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM