diff --git a/dawn.json b/dawn.json index 3d6ead9f74..e07bb57b75 100644 --- a/dawn.json +++ b/dawn.json @@ -1141,6 +1141,11 @@ {"name": "features", "type": "feature name", "annotation": "*"} ] }, + { + "name": "get adapter", + "returns": "adapter", + "tags": ["dawn"] + }, { "name": "get queue", "returns": "queue" diff --git a/dawn_wire.json b/dawn_wire.json index 55098d006a..c26d4cdcad 100644 --- a/dawn_wire.json +++ b/dawn_wire.json @@ -224,6 +224,7 @@ "DeviceCreateQuerySet", "DeviceCreateTexture", "DeviceCreateErrorTexture", + "DeviceGetAdapter", "DeviceGetQueue", "DeviceInjectError" ], diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index e3145a9246..f737e47d09 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp @@ -1284,6 +1284,11 @@ MaybeError DeviceBase::Tick() { return {}; } +AdapterBase* DeviceBase::APIGetAdapter() { + mAdapter->Reference(); + return mAdapter; +} + QueueBase* DeviceBase::APIGetQueue() { // Backends gave the primary queue during initialization. ASSERT(mQueue != nullptr); diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h index 0a046457b9..b8b145b032 100644 --- a/src/dawn/native/Device.h +++ b/src/dawn/native/Device.h @@ -269,6 +269,7 @@ class DeviceBase : public RefCountedWithExternalCount { ExternalTextureBase* APICreateErrorExternalTexture(); TextureBase* APICreateErrorTexture(const TextureDescriptor* desc); + AdapterBase* APIGetAdapter(); QueueBase* APIGetQueue(); bool APIGetLimits(SupportedLimits* limits) const; diff --git a/src/dawn/wire/client/Device.cpp b/src/dawn/wire/client/Device.cpp index ace00a1839..f2bffe2cdf 100644 --- a/src/dawn/wire/client/Device.cpp +++ b/src/dawn/wire/client/Device.cpp @@ -216,6 +216,12 @@ WGPUTexture Device::CreateErrorTexture(const WGPUTextureDescriptor* descriptor) return Texture::CreateError(this, descriptor); } +WGPUAdapter Device::GetAdapter() { + // Not implemented in the wire. + UNREACHABLE(); + return nullptr; +} + WGPUQueue Device::GetQueue() { // The queue is lazily created because if a Device is created by // Reserve/Inject, we cannot send the GetQueue message until diff --git a/src/dawn/wire/client/Device.h b/src/dawn/wire/client/Device.h index d1af3432fd..6e021feba9 100644 --- a/src/dawn/wire/client/Device.h +++ b/src/dawn/wire/client/Device.h @@ -71,6 +71,7 @@ class Device final : public ObjectBase { void SetLimits(const WGPUSupportedLimits* limits); void SetFeatures(const WGPUFeatureName* features, uint32_t featuresCount); + WGPUAdapter GetAdapter(); // Not implemented in the wire. WGPUQueue GetQueue(); void CancelCallbacksForDisconnect() override;