Allow only strings in featureLevel
#4874
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The initial landing of GPURequestAdapterOptions.featureLevel allowed
anybecause we don't know what the shape of future feature level requests will be.Brandon pointed out that we don't need to use
anyto 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
nullmeaning "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
nullto getting a rejection, we don't need to consider that a breaking change becausefeatureLevelis currently useless. (It's almost exactly like adding a member to a dictionary, except that the dictionary member name isn't new.)