Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

opengl - 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?

question from:https://stackoverflow.com/questions/65871044/how-does-chrome-support-webgl-on-macos

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...