这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@kainino0x
Copy link
Contributor

@kainino0x kainino0x commented Sep 12, 2024

The initial landing of GPURequestAdapterOptions.featureLevel allowed any because we don't know what the shape of future feature level requests will be.

Brandon pointed out that we don't need to use any to achieve this. Instead, we can add sibling members such that you request something like:
{ featureLevel: 'foo', featureLevelFooOptions: { /* ... */ } }

There was a similar change in WebXR's history; discussion on that seems to start roughly here:
immersive-web/webxr#1205 (comment)

(It is a DOMString rather than an enum so that we can return null meaning "cannot fulfill adapter request" rather than rejecting. This makes it consistent between older browsers, and newer browsers on older hardware.)

EDIT: This additionally makes representing the value in an implementation much simpler: since featureLevel will (presumably) only ever allow strings from some fixed set, it can be converted to an enum (e.g. C++ enum) internally.

Issue #4656. Milestone 1, because while it's technically possible for an application to exist which this PR changes from getting null to getting a rejection, we don't need to consider that a breaking change because featureLevel is currently useless. (It's almost exactly like adding a member to a dictionary, except that the dictionary member name isn't new.)

The initial landing of GPURequestAdapterOptions.featureLevel allowed
`any` because we don't know what the shape of future feature level
requests will be.

Brandon pointed out that we don't need to use `any` to achieve this.
Instead, we can add sibling members such that you request something
like:
`{ featureLevel: 'foo', featureLevelFooOptions: { /* ... */ } }`

There was a similar change in WebXR's history; discussion on that seems
to start roughly here:
immersive-web/webxr#1205 (comment)

(It is a DOMString rather than an enum so that we can return `null`
meaning "cannot fulfill adapter request" rather than rejecting. This
makes it consistent between older browsers, and newer browsers on older
hardware.)

Issue: 4656
@kainino0x kainino0x added proposal api WebGPU API labels Sep 12, 2024
@kainino0x kainino0x added this to the Milestone 1 milestone Sep 12, 2024
@kainino0x kainino0x marked this pull request as ready for review September 12, 2024 23:23
@github-actions
Copy link
Contributor

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

@kainino0x
Copy link
Contributor Author

EDIT: This additionally makes representing the value in an implementation much simpler: since featureLevel will (presumably) only ever allow strings from some fixed set, it can be converted to an enum (e.g. C++ enum) internally.

kainino0x added a commit to kainino0x/gpuweb that referenced this pull request Sep 12, 2024
@Kangz
Copy link
Contributor

Kangz commented Sep 24, 2024

GPU Web WG 2024-09-18
  • JB: Mike and I approved.
  • CW: Don't need to talk much about it.

@kainino0x kainino0x merged commit db2f243 into gpuweb:main Sep 25, 2024
@kainino0x kainino0x deleted the feature-level-string branch September 25, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api WebGPU API proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants