Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[g-webgl] HAL 支持 WebGPU #863

Closed
xiaoiver opened this issue Jan 24, 2022 · 2 comments
Closed

[g-webgl] HAL 支持 WebGPU #863

xiaoiver opened this issue Jan 24, 2022 · 2 comments
Assignees

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented Jan 24, 2022

Chrome 94 的一项重大更新就是将之前预览版本实现的 WebGPU 纳入了正式版,Firefox、Safari、Edge 目前在预览版本也可以体验(所有浏览器厂商达成共识不容易):
https://developer.chrome.com/blog/new-in-chrome-94/#webgpu
升级后通过在页面中添加 origin trial meta 标签使用。

与此同时,iOS 15 也终于支持了 WebGL2:
https://developer.apple.com/documentation/safari-release-notes/safari-15-release-notes#Web-APIs

目前 G 按照 WebGPU -> WebGL2 -> WebGL1 自动降级:#851

为了通过 origin trial 使用 WebGPU,在 G 官网中增加了如下脚本:

// origin trial for WebGPU
// @see https://github.com/GoogleChrome/OriginTrials/blob/gh-pages/developer-guide.md#16-can-i-provide-tokens-by-running-script
const tokenElement1 = document.createElement('meta');
tokenElement1.httpEquiv = 'origin-trial';
tokenElement1.content =
  // https://localhost:8000
  'AqCnZyPTDPRK7MVw+bbVJoQkYndOjHKTarXCp+JTVy4VPAKv/E1SJDuFzsJGm0COxapIEanHG7oF0W+HT0ANwQUAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjQzMTU1MTk5fQ==';
document.head.appendChild(tokenElement1);

这样在 Chrome 开发者工具 “应用” -> "帧" 中可以查看 origin trial:
截屏2022-01-24 上午11 40 16

@xiaoiver xiaoiver self-assigned this Jan 24, 2022
@xiaoiver
Copy link
Contributor Author

xiaoiver commented Jan 24, 2022

WGSL 语法有一些变化,例如使用 @ 代替 [[]]:
https://github.com/gpuweb/gpuweb/pull/2517/files

需要等 Chrome 实现更新,否则现在新语法会报错:
截屏2022-01-24 下午3 07 52

#1103

xiaoiver added a commit that referenced this issue Jun 14, 2023
* fix: WebGPU HAL & handle lost context #863 & #1362

* fix: wait for context lost promise

* fix: create renderer3d component in picking plugin #1094

* feat: add onContextLost callback to constructor options of WebGL & WebGPU renderer #1362

* fix: copy glsl_wgsl_compiler_bg.wasm to dist dir of g-webgpu #1369
@xiaoiver
Copy link
Contributor Author

xiaoiver commented Jun 29, 2023

由于 WebGPU 使用 [0, 1] 而非 OpenGL / WebGL 的 [-1, 1] 作为深度范围,Camera 生成投影矩阵时也应作出区分:

// WebGL
mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far);

// WebGPU
mat4.orthoZO(this.projectionMatrix, left, right, bottom, top, near, far);

#1399
#1400

xiaoiver added a commit that referenced this issue Jul 6, 2023
* fix: make pick async to support impl in WebGPU (#1398)

* fix: skip loading Box2D if it's already existed #1393

* fix: update latest physx

* fix: support 2 kinds of clip z range #863

* fix: make pick async to support impl in WebGPU #1400

* fix: use async readpixels in webgl2

* fix: use premultiplied alpha in WebGL & WebGPU #1399

* fix: use createImageBitmap to create texture if possible #1401

* chore: add test case for ssr with g-webgl

* chore: adjust examples of performance block (#1402)

* chore: adjust examples of performance block

* fix: reset transform with keyword none

* chore: add ga4 key

* fix: createImageBitmap should account for error of SVG failure

* fix: avoid overriding defXY when parsing path (#1405)

* fix: avoid overriding defXY when parsing path #1404

* chore: commit changeset

* chore(release): bump version (#1403)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant