Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

SenorBlanco
Copy link
Contributor

Update the Compatibility Mode proposal to use featureLevel instead of the compatibilityMode boolean.

Now that GPUAdapter.featureLevel has landed in the core spec, remove
the GPUAdapter.compatibilityMode IDL change from the proposal.
Explain that setting GPUAdapter.featureLevel to "compatibility"
enables Compatibility Mode validation. Change the
GPUAdapter.isCompatibilityMode boolean to a "featureLevel" DOMString.
@SenorBlanco SenorBlanco requested a review from kainino0x December 5, 2024 22:13
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Previews, as seen when this build job started (d011a7e):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt


As a convenience to the developer, the Adapter returned will have the `isCompatibilityMode` property set to `true`.

As a convenience to the developer, the Adapter returned will have the `featureLevel` property set to `"compatibility"`.
Copy link
Contributor

@greggman greggman Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be moved to GPUAdapterInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Added some more reviewers for thoughts.

It's symmetrical with forceFallbackAdapter / isFallbackAdapter where it is, but perhaps that's because those predate GPUAdapterInfo.

Copy link

@mwyrzykowski mwyrzykowski Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way is fine with me. Slight preference to GPUAdapter due to consistency with isFallbackAdapter

Copy link
Contributor

@greggman greggman Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should isFallbackAdapter be moved to GPUAdapterInfo? #4971

I feel like the reasons we added GPUAdapterInfo to device certainly exist for featureLevel. #4810 A library might want/need to know if they're in compat mode. The CTS has had to workaround the fact that this info is not on the device.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly feel that items should only be in GPUAdapterInfo if they also apply to the device, because we expose device.adapterInfo. That's true of vendor/etc., and of isFallbackAdapter (so indeed it probably should be duplicated there), but not features/limits. Similarly it is not necessarily true of featureLevel, because whether the device is "compatibility mode" depends on what features/limits are enabled on it. This is another reason I don't really think we should expose something like adapter.isCompatibilityMode/adapter.featureLevel and should instead expose it via the features system. Example:

adapter = await navigator.gpu.requestAdapter({ featureLevel: "compatibility" });
device = await navigator.gpu.requestDevice({ /* forward all limits/features from the adapter */ });

device.adapterInfo.featureLevel will return "compatibility", but if the system supports core then that will be incorrect information about the device, which is not a compatibility device.

However this is an orthogonal concern to this PR, so this PR LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(https://github.com/gpuweb/gpuweb/pull/4898/files is where I concretely suggested a "webgpu-core" feature which, if available and requested, upgrades all features and limits to their core values.)

Anyway, I just remembered that if we end up including this, there is one naming concern I have that I forgot about: adapter.featureLevel sounds like it tells you the maximum feature level of the adapter, but I don't think that's what we want.

I believe what we want is to tell you whether your featureLevel request was obeyed or ignored - that is, whether requestDevice() with no args will give you compat or core. This is hard to convey in naming, but could be defaultDeviceFeatureLevel or something.

However it may not be necessary; in the PR above I said:

Applications that do need to check that compat is enforced (such as tests) should create a device and then check whether the "webgpu-core" feature is enabled on the device.

The question becomes whether applications ever need to know this before requesting a device.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find it odd to request property "foo" and get back property "defaultDeviceFoo". Why are we not requesting property "defaultDeviceFoo" in requestAdapter(), in that case?

Naming aside, hopefully if we do things correctly, most people won't need to know what the returned featureLevel is. They'll use individual Features to give them broader (ie., finer grained) reach above Compat, if they need it.

I see this as:

  1. A failsafe against late-added Compat features which Core-only browsers don't know about, so people have to use this for feature detection. (Hopefully we spec them all, so this use case is minimal.)
  2. Useful for metrics gathering, a la webgpureport.org.

In either case, testing against a Feature seems asymmetrical when other things in GPURequestAdapterOptions end up as GPUAdapter properties.

(Let me know if I've missed any use cases.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find it odd to request property "foo" and get back property "defaultDeviceFoo". Why are we not requesting property "defaultDeviceFoo" in requestAdapter(), in that case?

That's essentially the reason I think they should have different names. One is the feature level you requested - the adapter you get must have at least that feature level, but it may also be upgraded. The other is the feature level that requestDevice will default to, i.e. the post-upgrade result.

It is somewhat similar to forceFallbackAdapter vs isFallbackAdapter which are also differently named.
powerPreference and xrCompatible are not surfaced on GPUAdapter.

1. A failsafe against late-added Compat features which Core-only browsers don't know about, so people have to use this for feature detection. (Hopefully we spec them all, so this use case is minimal.)

Do you mean apps would check adapter.featureLevel === "compatibility" before requesting "some-compat-feature-we-missed"? If that's the case they should more straightforwardly just check adapter.features.has("some-compat-feature-we-missed"). (They don't need to know whether the browser knows the feature, unless it's actually supported on the system.) If I'm misunderstanding, sorry and please correct me.

2. Useful for metrics gathering, a la webgpureport.org.

As long as there is some not-too-verbose way to get the answer, I don't think it really matters if metrics gathering code is slightly simpler. I still like adapter.features.has("webgpu-core").

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stephen and I talked about the naming concern. I think there are three things that adapter.featureLevel could mean, none of which are obvious, that the developer could potentially think it means:

  • The exact value requested in requestAdapter. This wouldn't be very useful so devs are less likely to think this is it.
  • The feature level of the default "compatibility" if the featureLevel requested in requestAdapter() was obeyed, and "core" if it was ignored. (This is what I think it should mean.)
  • Whether the max capabilities of the adapter are above or below core. This would be the same as adapter.has('webgpu-core') assuming we add that. It would be very easy to think this is the meaning initially, but trying it out in a compat-supporting browser should disprove this quickly.

So given that, I still prefer a more specific name like deviceDefaultFeatureLevel but I am fine with featureLevel.

(This is of course all assuming we keep this attribute, which I think is unnecessary, but as I mentioned before that's orthogonal to this PR.

kainino0x
kainino0x previously approved these changes Dec 10, 2024
```webidl
partial interface GPUAdapter {
readonly attribute boolean isCompatibilityMode;
readonly attribute DOMstring featureLevel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly attribute DOMstring featureLevel;
readonly attribute DOMString featureLevel;


As a convenience to the developer, the Adapter returned will have the `isCompatibilityMode` property set to `true`.

As a convenience to the developer, the Adapter returned will have the `featureLevel` property set to `"compatibility"`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly feel that items should only be in GPUAdapterInfo if they also apply to the device, because we expose device.adapterInfo. That's true of vendor/etc., and of isFallbackAdapter (so indeed it probably should be duplicated there), but not features/limits. Similarly it is not necessarily true of featureLevel, because whether the device is "compatibility mode" depends on what features/limits are enabled on it. This is another reason I don't really think we should expose something like adapter.isCompatibilityMode/adapter.featureLevel and should instead expose it via the features system. Example:

adapter = await navigator.gpu.requestAdapter({ featureLevel: "compatibility" });
device = await navigator.gpu.requestDevice({ /* forward all limits/features from the adapter */ });

device.adapterInfo.featureLevel will return "compatibility", but if the system supports core then that will be incorrect information about the device, which is not a compatibility device.

However this is an orthogonal concern to this PR, so this PR LGTM.

@SenorBlanco SenorBlanco requested a review from kdashg December 11, 2024 15:20
@SenorBlanco
Copy link
Contributor Author

Thanks for your comments! I'd love to hear from Mozilla folks if they have thoughts here.

@kainino0x
Copy link
Contributor

LGTM despite preference for different naming, but please fix the DOMString capitalization before landing

@kainino0x
Copy link
Contributor

(i.e. resolve all open comment threads)

@SenorBlanco SenorBlanco merged commit 254de56 into gpuweb:main Dec 19, 2024
4 checks passed
aarongable pushed a commit to chromium/chromium that referenced this pull request Dec 19, 2024
This CL adds the GPUAdapter featureLevel attribute behind the
WebGPU Experimental Features flag, disabled by default.

Spec PR: gpuweb/gpuweb#5012

Bug: 366151404, 382291443
Change-Id: Iea06fc16ab4ae3cda59acddf78e14281f32b8f78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6088045
Reviewed-by: Stephen White <[email protected]>
Commit-Queue: Fr <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1398673}
copybara-service bot pushed a commit to google/dawn that referenced this pull request Jan 4, 2025
Spec PR: gpuweb/gpuweb#5012

Bug: 366151404, 382291443
Change-Id: I9ece689cbc4a90abcc935ec7ad551a7abc541a8e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/220434
Reviewed-by: Kai Ninomiya <[email protected]>
Commit-Queue: Fr <[email protected]>
copybara-service bot pushed a commit to google/dawn that referenced this pull request Jan 7, 2025
Spec PR: gpuweb/gpuweb#5012

Bug: 366151404, 382291443
Change-Id: Ic37e4b62d6391622612f2a3f5e6a327d0ec337e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/220895
Commit-Queue: Fr <[email protected]>
Reviewed-by: Kai Ninomiya <[email protected]>
@Kangz
Copy link
Contributor

Kangz commented Jan 27, 2025

GPU Web WG 2025-01-22 Atlantic-time
  • Nothing new to add.

@kainino0x kainino0x added the compat WebGPU Compatibility Mode label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat WebGPU Compatibility Mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants