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

WebGPURenderer: Add Enable Directive/Enable-Extension Support #28615

Merged
merged 5 commits into from
Jul 18, 2024

Conversation

cmhhelgeson
Copy link
Contributor

Related issue: #28578

According to the WGSL specification, enable extensions are features required to utilize certain features like f16 floats and clip_distances. These extensions can be utilized within a shader if the shader calls its corresponding enable directive and the corresponding feature is enabled on the GPUDevice. There are a few upsides and downsides to providing WGSLNodeBuilder the ability to create shaders with enable directives.

Downsides:

  • As WGSL continues to develop, features only accessible through enable extensions may become standard features, no longer necessitating explicit requests via enable directives.
  • Enable extensions are often only available on the latest versions of Chromium. Older versions will not be able to access them.
  • Potential need to sync available device features with shader language, or fallback to different graphics backend if a Three.js application requires an enable-extension that the device does not support (i.e if the current GPUDevice does not support clip-distances, fallback to the WebGPURenderer's WebGLBackend or throw an error).

Upsides:

  • Supporting enable extensions helps facilitate the development of new features before they're widely available.
  • Helps with back-porting. If an enable extension becomes a standard feature in a newer version of Chromium or WGSL, applications using older versions will still have access to that feature.

Description

The implementation is effectively just a simplified version of WGSLNodeBuilders' builtins code. Directives were only added to vertex and compute shaders since they seem to be the only shader stages that currently have directives associated with them.

@RenaudRohlinger
Copy link
Collaborator

Related in #28578
https://github.com/mrdoob/three.js/pull/28578/files#diff-7be08fb77941a250952d221db6723969bebb4f02d5dbbc9ce17d91bdbc390bdcR609-R624

@cmhhelgeson cmhhelgeson marked this pull request as ready for review June 12, 2024 16:50
@cmhhelgeson cmhhelgeson force-pushed the webgpu_add_directives branch from 7564b3d to 9d26be7 Compare July 4, 2024 23:38
Copy link

github-actions bot commented Jul 4, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
683.7 kB (169.3 kB) 683.7 kB (169.3 kB) +0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
460.9 kB (111.2 kB) 460.9 kB (111.2 kB) +0 B

@Mugen87 Mugen87 added this to the r167 milestone Jul 18, 2024
@sunag sunag merged commit 3237189 into mrdoob:dev Jul 18, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants