Bug 1955057 - feat(webgpu): add GPUAdapterInfo.isFallbackAdapter r=webgpu-reviewers,webidl,smaug,teoxoy

Differential Revision: https://phabricator.services.mozilla.com/D242390
This commit is contained in:
Erich Gubler
2025-03-24 17:56:33 +00:00
parent 41b5cead85
commit 920660bd58
3 changed files with 14 additions and 0 deletions

View File

@@ -21,6 +21,18 @@ namespace mozilla::webgpu {
GPU_IMPL_CYCLE_COLLECTION(AdapterInfo, mParent)
GPU_IMPL_JS_WRAP(AdapterInfo)
bool AdapterInfo::IsFallbackAdapter() const {
if (GetParentObject()->ShouldResistFingerprinting(
RFPTarget::WebGPUIsFallbackAdapter)) {
// Always report hardware support for WebGPU.
// This behaviour matches with media capabilities API.
return false;
}
return mAboutSupportInfo->device_type ==
ffi::WGPUDeviceType::WGPUDeviceType_Cpu;
}
void AdapterInfo::GetWgpuName(nsString& s) const {
s = mAboutSupportInfo->name;
}

View File

@@ -63,6 +63,7 @@ class AdapterInfo final : public nsWrapperCache, public ChildOf<Adapter> {
void GetArchitecture(nsString& s) const { s = nsString(); }
void GetDevice(nsString& s) const { s = nsString(); }
void GetDescription(nsString& s) const { s = nsString(); }
bool IsFallbackAdapter() const;
// Non-standard field getters; see also TODO BUGZILLA LINK
void GetWgpuName(nsString&) const;

View File

@@ -70,6 +70,7 @@ interface GPUAdapterInfo {
readonly attribute DOMString architecture;
readonly attribute DOMString device;
readonly attribute DOMString description;
readonly attribute boolean isFallbackAdapter;
// Non-standard; see <https://bugzilla.mozilla.org/show_bug.cgi?id=1831994>.
[ChromeOnly] readonly attribute DOMString wgpuName;