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

Skip to content

Commit d00996f

Browse files
beaufortfrancoisChromium LUCI CQ
authored andcommitted
webgpu: Validate featureLevel is an allowed feature level string value
Spec PR: gpuweb/gpuweb#4897 CTS PR: gpuweb/cts#4077 Bug: 366151404 Change-Id: I451a5e66f85468cb433b9f20edf7c09644ac8cd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6067690 Reviewed-by: Kai Ninomiya <[email protected]> Commit-Queue: Kai Ninomiya <[email protected]> Cr-Commit-Position: refs/heads/main@{#1392500}
1 parent 433f83e commit d00996f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

third_party/blink/renderer/modules/webgpu/gpu.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,11 @@ void GPU::RequestAdapterImpl(
280280
ScriptPromiseResolver<IDLNullable<GPUAdapter>>* resolver) {
281281
ExecutionContext* execution_context = ExecutionContext::From(script_state);
282282

283-
// Validate that the featureLevel is undefined. If not return a null adapter.
284-
// This logic will evolve as feature levels are added in the future.
285-
if (options->hasFeatureLevel()) {
283+
// Validate that the featureLevel is an allowed feature level string value. If
284+
// not return a null adapter. This logic will evolve as feature levels are
285+
// added in the future.
286+
if (options->hasFeatureLevel() && options->featureLevel() != "core" &&
287+
options->featureLevel() != "compatibility") {
286288
OnRequestAdapterCallback(script_state, options, resolver,
287289
wgpu::RequestAdapterStatus::Error, nullptr,
288290
"Unknown feature level");

third_party/blink/renderer/modules/webgpu/gpu_request_adapter_options.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enum GPUPowerPreference {
1010
};
1111

1212
dictionary GPURequestAdapterOptions {
13-
[RuntimeEnabled=WebGPUExperimentalFeatures] DOMString featureLevel;
13+
[RuntimeEnabled=WebGPUExperimentalFeatures] DOMString featureLevel = "core";
1414
GPUPowerPreference powerPreference;
1515
boolean forceFallbackAdapter = false;
1616
[RuntimeEnabled=WebGPUExperimentalFeatures] boolean compatibilityMode = false;

0 commit comments

Comments
 (0)