You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should WGSL have different types of extensions? #2310
The community group has not expressed a stance on how extensions can developed, nor has it expressed a stance on who can develop extensions.
Who can write an extension for WGSL? Can just the community group publish the extensions? Implementors? Anyone?
If more than just the community group can produce extensions, how much input should the community group have? Should we simply host a registry of extensions or a registry of curated extensions?
GL for example, has many types of extensions: KHR, EXT and vendor extensions. It does not restrict who can write extensions, though not all extensions are expected to be widely supported. Implementations can choose which extensions to support (e.g. vendor X is unlikely to support vendor Y's extensions).
Some extensions will be preliminary, existing for the purpose of getting developer feedback.
These will live for a short time, may be modified iteratively and eventually withdrawn, or promoted to broad support.
Here broad support can be a synonym for: has approval from W3C and is implemented widely (on platforms that can support the feature).
It's important that "preliminary" extensions use an "enable" name that is clearly different from "broad support" extensions. So we need a naming convention.
Example: Anything starting with an underscore is preliminary. Within that you can have other conventions, e.g. name your org, e.g. _google_frobnar
Example: Java does namespacing by URL, but reversely. com.google.blah.snoobar
Example: I'm sure there's more.
By their nature, preliminary extensions are not controlled by W3C. W3C should not host a registry of them.
Will there be extensions somewhere between preliminary and "broad support"? Possibly, but anything short of "broad support" is not under the control of W3C, and W3C should not be involved with them.
Of course, the health of the web platform depends on trying to avoid needless fragmentation.
The problem with shipping vendor-prefixed things without a flag is that sites start using them, and relying on their quirks. Other browsers have to reverse-engineer the vendor-prefixed things in order to be web-compatible.
Putting these experimental extensions behind a browser flag alleviates all the above concerns. All experimental (or, in the previous parlance, preliminary) extensions should be behind a flag. Beyond that, if a browser wants to start their experimental extensions with an underscore or a vendor name, that's their decision.
An extension which does not aspire to be implemented by multiple browser engines has no business being in a W3C repository. Single browser engine functionality is not a standard, even if it is written down in a specification. Individual browser engines are certainly capable of implementing single vendor functionality, but the description of that functionality should live in that browser engine's own developer documentation - not the W3C.
Of course, any new functionality has to be implemented in a single place before it can be implemented in multiple places. If functionality was designed with the collaboration of the CG, and aspires to be implemented by multiple browser engines / native APIs (for hardware which supports it), then the specification of that functionality does belong in the W3C (even if it only happens to exist in a single UA currently).
One of the relevant discussions here is the definition of "implementation."
When discussing this, it's important to have commonly-understood terminology. Here, I'll be using these terms:
"native API" indicates "D3D / Vulkan / Metal"
"browser engine" means "(Blink and Dawn) / (Gecko and wgpu (and maybe more?)) / (WebKit and WebGPU.framework) / etc."
"driver" means "the device-specific code inside the native API"
"device vendor" means "Intel / Nvidia / AMD / Apple / Qualcomm / etc."
Our CTS tests end-to-end behavior, as a black box. This end-to-end behavior flows through the browser, through the native graphics API, and though the driver. Our CTS tests don't just test whether or not a particular WebGPU call got turned into a particular D3D call. Therefore, the definition of "implementation" should not just equal "browser engine," but should be more sophisticated than that.
Here's a proposal, based on the above observation:
A single browser engine cannot be considered to be multiple implementations, even if that browser runs on multiple native APIs or drivers. (Rationale: One browser engine should not be able to unilaterally add functionality to the web platform.)
A single native API cannot be considered to be multiple implementations, even if that API is accessed through different browser engines, and even if that API runs on top of different drivers / device vendors. (Rationale: For example, a D3D12-only extension would only run on Windows, contrary to the portability goals of the web.)
A single device vendor cannot be considered to be multiple implementations, even if that vendor's code is accessed through different native APIs, and even if the device vendor wrote multiple different drivers which expose the same API. (Rationale: Just as above, an AMD-only extension (just as an example - I don't mean to pick on any one in particular) would also be contrary to the portability goals of the web. And, if the same device vendor writes two implementations, that doesn't indicate that the implementations are interoperable with other device vendors; it just indicates that a particular person/company can make the same mistake twice.)
Therefore, this proposal would require that every extension be implemented 1) on multiple browser engines 2) on multiple native APIs 3) and on multiple device vendors.
If a proposed extension meets these requirements, or aspires to meet these requirements, then it is a fit for being worked on by this CG/WG. Otherwise, it does not fit, and must instead be published outside of this CG/WG.
Preliminary extensions should not be exposed by default. (Guard them by a flag, for example)
W3C of course gets involved when the intent is broad support.
The naming convention idea is about declaring within source code that the code is using preliminary support, and the source code will require porting to use the standardized feature. But since by definition preliminary support is outside the control of W3C we can't require anything of those extensions. So W3C can still enforce something by promising that no standard extension will have an enable name has a certain pattern. E.g. "no W3C enable name will start with underscore"
DN: W3C has opinions on certain things. I think we should probably officially have no extensions within W3C, and we would have no official extension registry, except for the features that would make it into the spec.
MM: I think it’s not quite accurate to say that W3C is not concerned with features still-in-flight. (e.g. WebGPU is still in-flight) But for example if someone wanted to write a raytracing feature, we could prototype it, even if it’s not ready or has limited support preliminarily. However the W3C isn’t interested in speccing things which have no aspirations to be supported in many places/backends.
AB: How do we draw the line of reach. (e.g. 70% of some denominator). How important is broad reach. Defining new things vs. stuff that’s not everywhere yet.
MM: Intentionally didn’t use a metric of number of devices. There are lots of browsers with much smaller numbers of users. Those browsers count in considering W3C spec. Don’t use market share.
AB: I think we should, to an extent. Let’s say NVIDIA (they like to run ahead) manages to get a feature on all (denominator?). It meets the bar of wide, but should not be considered broad adoption.
MM: Proposed 3 criteria
Multiple browsers
Multiple APIs
Multiple device vendors.
MM: So an NVIDIA-only extension would not be enough. But if they got together with AMD to make something common, then that would be enough.
AB: Would like mobile included. Mobile vs. Desktop should be considered.
KG: That’s something we’ve wrestled with a lot in Web(GL?GPU). Strong split between shader texel buffer fetch. Am much more comfortable with Myles’ set of criteria. Would like to set a aspire to bridge the portability gap between desktop and mobile, but don’t think we can make that strict criteria.
MM: Apple has same arch on mobile and desktop
KG: another way to slice / proxy is discrete, integrated
AB: Come from context where very wide portability is very important. When thinking of adding a feature, have to think hard about when something is blessed by W3C. In GLSL’ism there are EXTs that typically are groups of vendors, but not really “everywhere”.
MM: Feel if something is optional it’s likely to be optional forever. Can see extension packs. But still optional.
AB: Think there’s value in different levels of blessing. “This thing is something you should think about taking advantage of, expected to be in majority of hardware <blah criteria>” Being able to talk about those buckets is valuable.
KG: Let’s focus on what this group needs to do. E.g. develop dev-only features. Kind of exists outside this spec. But should be aware of what we’re going to be asked to be guaranteed here. E.g. for WebGL, we have checks to make sure that you don’t offer more than you’re allowed to offer. E.g. extensions which were not official extensions (in our registry), that could be a problem. Have a nebulous bar about what’s included in the registry. Have mechanism for “draft extension” which are not exposed, and community-ratified extension. We do track extensions that are draft,
GR: Is there an experimental/developer mode to allow experimentation.
KG: All browsers do. Chrome has command line flag. Firefox has a preference. about://flags
RC: Chromium has command flags and about://flags and more of the former than latter.
MM: Safari has a menu: a big list of checkboxes.
GR: Somem pretty security concerns about enabling an extension willy nilly.
RC: All these mechanisms, the end user has to take action to enable them.
GR: All those vendor extensions should be enable-able behind a flag.
MM: Yes, behind a flag is fine.
KG: What matters is what we test in our test suite. Have to test that you don’t get any more features than you’re allowed. Can do
DN: Can we reserve a prefix that we promise W3C won’t bless one that starts with underscore.
KG: Do we test that. Get the extensions and require none of them to start with an underscore.
MM: Sounds smelly, but ok. (?)
MM: Should test with as close to final implementation. So should exclude underscore-pattern extension.
KG: It’s up to us what negative tests to add. We have list of known extensions. And test only those come back.
MM: The audience of the policy is us. We can change if needed. Can accept the strict policy for now, and relax in future if needed.
DN: Does the API allow you to enumerate the extensions?
MM: Yes, there’s a vector of strings and an enum.
AB: Are all WGSL extensions tied to an API extension? Or can you have WGSL-only extensions.
MM: Propose that all extensions should go through WebGPU. If you want to enable a WGSL feature, you have to enable it at WebGPU device creation time.
AB: Think that’s reasonable.
GR: Think that’s reasonable.
GR: DirectX officially has no extensions, but NV and others have done so for decades. Folks will find a way.
KG: We can’t prevent folks who are very determined.
MM: Can that happen on the web? (an extra JavaScript API to WebGL)
KG: You’d have to do something ugly, like populating a signature string in a buffer. (Can’t do it in the shader transpiler.)
KG: What do we have here. Some criteria for “broad support”
MM: Audience is different from shader authors. Should be on wiki?
KG: Put it in the spec.
MM: I can send a PR. Don’t want to touch the desktop/mobile divide.
AB: Thanks for the discussion. We’ll work through policy/process when we try to add the first extension.
Activity
dneto0 commentedon Nov 16, 2021
Reminder: WGSL describes extensions generally, and provides the "enable" mechanism to declare that a particular source module uses an extension. See https://gpuweb.github.io/gpuweb/wgsl/#language-extensions
dneto0 commentedon Nov 16, 2021
Somewhat related, but doesn't seem to have touched on process is: #600
dneto0 commentedon Dec 2, 2021
I think:
Extensions are inevitable
Some extensions will be preliminary, existing for the purpose of getting developer feedback.
Here broad support can be a synonym for: has approval from W3C and is implemented widely (on platforms that can support the feature).
It's important that "preliminary" extensions use an "enable" name that is clearly different from "broad support" extensions. So we need a naming convention.
_google_frobnarcom.google.blah.snoobarBy their nature, preliminary extensions are not controlled by W3C. W3C should not host a registry of them.
Will there be extensions somewhere between preliminary and "broad support"? Possibly, but anything short of "broad support" is not under the control of W3C, and W3C should not be involved with them.
litherum commentedon Dec 7, 2021
Vendor prefixes in shipping browsers (without a flag) are generally considered harmful on the web. This has some background, which links to this. WebKit has a policy against them, and I believe Chrome does too. The Launching Features wiki page on chromium.org says "start checking in prototype code to Chromium under a runtime flag." (Chrome's prefixing policy seems to have been at http://www.chromium.org/blink#vendor-prefixes but the link appears to be stale, and I can't seem to find an up-to-date version. Archive.org indicates it used to say "instead of enabling a feature by default with a vendor prefix, we will instead keep the (unprefixed) feature behind the “enable experimental web platform features” flag.") The MDN article on vendor prefixes says "Browser vendors are working to stop using vendor prefixes for experimental features."
The problem with shipping vendor-prefixed things without a flag is that sites start using them, and relying on their quirks. Other browsers have to reverse-engineer the vendor-prefixed things in order to be web-compatible.
Putting these experimental extensions behind a browser flag alleviates all the above concerns. All experimental (or, in the previous parlance, preliminary) extensions should be behind a flag. Beyond that, if a browser wants to start their experimental extensions with an underscore or a vendor name, that's their decision.
An extension which does not aspire to be implemented by multiple browser engines has no business being in a W3C repository. Single browser engine functionality is not a standard, even if it is written down in a specification. Individual browser engines are certainly capable of implementing single vendor functionality, but the description of that functionality should live in that browser engine's own developer documentation - not the W3C.
Of course, any new functionality has to be implemented in a single place before it can be implemented in multiple places. If functionality was designed with the collaboration of the CG, and aspires to be implemented by multiple browser engines / native APIs (for hardware which supports it), then the specification of that functionality does belong in the W3C (even if it only happens to exist in a single UA currently).
litherum commentedon Dec 7, 2021
One of the relevant discussions here is the definition of "implementation."
When discussing this, it's important to have commonly-understood terminology. Here, I'll be using these terms:
Our CTS tests end-to-end behavior, as a black box. This end-to-end behavior flows through the browser, through the native graphics API, and though the driver. Our CTS tests don't just test whether or not a particular WebGPU call got turned into a particular D3D call. Therefore, the definition of "implementation" should not just equal "browser engine," but should be more sophisticated than that.
Here's a proposal, based on the above observation:
Therefore, this proposal would require that every extension be implemented 1) on multiple browser engines 2) on multiple native APIs 3) and on multiple device vendors.
If a proposed extension meets these requirements, or aspires to meet these requirements, then it is a fit for being worked on by this CG/WG. Otherwise, it does not fit, and must instead be published outside of this CG/WG.
[-]Should WGSL have the different types of extensions?[/-][+]Should WGSL have different types of extensions?[/+]dneto0 commentedon Dec 7, 2021
I think we're in good alignment. Particularly:
The naming convention idea is about declaring within source code that the code is using preliminary support, and the source code will require porting to use the standardized feature. But since by definition preliminary support is outside the control of W3C we can't require anything of those extensions. So W3C can still enforce something by promising that no standard extension will have an
enablename has a certain pattern. E.g. "no W3C enable name will start with underscore"kdashg commentedon Dec 8, 2021
WGSL meeting minutes 2021-12-07
kdashg commentedon Mar 28, 2022
Is there anything more we want to clarify here?