Skip to content

Conversation

@kainino0x
Copy link
Contributor

@kainino0x kainino0x commented Dec 16, 2020

Proposes (again) returning multiple adapters in response to an adapter request.

See #524 for previous discussion and rationale. (But note this PR differs in some small ways.)

  • requestAdapters is not any more prone to fingerprinting. The UA can choose to put whichever adapters it wants in the list. Any adapters returned from it could have been found by searching the space of possible requestAdapter calls.
  • Many applications would end up trying to get every adapter they can find (by searching the space ...) and then using their own logic to pick among them. This prevents apps from needing that pattern.
  • requestAdapters still allows an easy default: e.g. ask for "low-power", then get adapter [0].
  • requestAdapter is hostile to any situation where the UA does want to give a little more trust to the app, perhaps Electron, Node, or even installed PWAs.

It is now our opinion that this is the right solution. Like #1273, it's a highly flexible API that allows UAs to do device bucketing ahead of time, or even lazily during accesses to the returned array. Most apps will use item [0], and such behavior can be observed by the UA if needed.

This design should avoid any pitfalls that would cause an otherwise well-written app (which chooses adapters properly on various hardware configurations, which is not hard) to fail on a UA which chooses to limit the set of returned adapters in any way; such a response would look equivalent to some other reasonable hardware configuration (e.g. a 2-gpu system looking like a 1-gpu system).

New in this PR, it requires specific predictable behavior, so that developers don't have to worry about some UAs e.g. requiring multiple calls to requestAdapters where others would not. (powerPreference must not affect the set of adapters returned, only the order.) I have further changes to propose after this that will require more predictable behavior for when device creation should fail, as well.


Preview | Diff

@github-actions
Copy link
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
90a7d65

@kainino0x
Copy link
Contributor Author

Another thing to note: This doesn't preclude the addition of some kind of navigator.gpu.requestDevice which automatically picks from adapters.

  • Possibly picking based on the features and limits in a provided GPUDeviceDescriptor, but it's an open question whether that's a good idea. (Most engines don't have an exact set of required features, so need to look at the adapter capabilities. It could also encourage apps to end up on the high-performance GPU (which has additional features) when they really would have preferred the low-power GPU with fewer features.)
  • Possibly just picking [0] from what would have been returned by requestAdapters.

@Kangz
Copy link
Contributor

Kangz commented Dec 16, 2020

Note this note about ordering of requested/discovered devices in the TAG design guidelines.

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

This sounds reasonable to me.

@kainino0x
Copy link
Contributor Author

Closing in favor of #1660

@kainino0x kainino0x closed this Apr 23, 2021
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This PR adds unimplemented stubs for the `atanh` builtin.

Issue: gpuweb#1223
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.

3 participants