webgpu.h: Add WGPURequestAdapterOptions featureLevel option
Spec PR: https://github.com/webgpu-native/webgpu-headers/pull/399
Bug: 366151404
Change-Id: I6c19179b80bd20540080eee69b4ca9177bbd5caf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218534
Commit-Queue: Fr <beaufort.francois@gmail.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
diff --git a/docs/dawn/features/adapter_options.md b/docs/dawn/features/adapter_options.md
index 22de658..31e7ec2 100644
--- a/docs/dawn/features/adapter_options.md
+++ b/docs/dawn/features/adapter_options.md
@@ -12,6 +12,7 @@
`dawn::native::Instance::EnumerateAdapters` is a Dawn native-only API that may be used to synchronously
get a list of adapters according to the RequestAdapterOptions. The members are treated as follows:
- `RequestAdapterOptions::compatibleSurface` is ignored.
+ - `RequestAdapterOptions::featureLevel` all returned adapters must support the features and limits in the requested feature level. Devices created from the adapter will default to the capabilities of this feature level.
- `RequestAdapterOptions::powerPreference` adapters are sorted according to powerPreference such that
preferred adapters are at the front of the list. It is a preference - so if
wgpu::PowerPreference::LowPower is passed, the list may contain only integrated GPUs, fallback adapters, or a mix of everything. Implementations *should* try to avoid returning any discrete GPUs when low power is requested if at least one integrated GPU is available.
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index a68c1f9..01443f6 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -74,6 +74,7 @@
"extensible": "in",
"members": [
{"name": "compatible surface", "type": "surface", "optional": true},
+ {"name": "feature level", "type": "feature level", "default": "core"},
{"name": "power preference", "type": "power preference", "default": "undefined"},
{"name": "backend type", "type": "backend type", "default": "undefined"},
{"name": "force fallback adapter", "type": "bool", "default": "false"},
diff --git a/src/dawn/native/Instance.cpp b/src/dawn/native/Instance.cpp
index 8422716..37806fb 100644
--- a/src/dawn/native/Instance.cpp
+++ b/src/dawn/native/Instance.cpp
@@ -373,9 +373,13 @@
UnpackedPtr<RequestAdapterOptions> unpacked = Unpack(options);
auto* togglesDesc = unpacked.Get<DawnTogglesDescriptor>();
- wgpu::FeatureLevel featureLevel = (options->compatibilityMode && !options->forceFallbackAdapter)
- ? wgpu::FeatureLevel::Compatibility
- : wgpu::FeatureLevel::Core;
+ wgpu::FeatureLevel featureLevel = wgpu::FeatureLevel::Core;
+ if ((options->featureLevel == wgpu::FeatureLevel::Compatibility ||
+ options->compatibilityMode) &&
+ !options->forceFallbackAdapter) {
+ featureLevel = wgpu::FeatureLevel::Compatibility;
+ }
+
std::vector<Ref<AdapterBase>> adapters;
for (const auto& physicalDevice : EnumeratePhysicalDevices(unpacked)) {
DAWN_ASSERT(physicalDevice->SupportsFeatureLevel(featureLevel));
diff --git a/src/dawn/native/opengl/BackendGL.cpp b/src/dawn/native/opengl/BackendGL.cpp
index 8139846..5eb4db7 100644
--- a/src/dawn/native/opengl/BackendGL.cpp
+++ b/src/dawn/native/opengl/BackendGL.cpp
@@ -58,7 +58,7 @@
if (options->forceFallbackAdapter) {
return {};
}
- if (!options->compatibilityMode) {
+ if (!options->compatibilityMode && options->featureLevel != wgpu::FeatureLevel::Compatibility) {
// Return an empty vector since GL physical devices can only support compatibility mode.
return {};
}