Add DeviceBase::APIGetAdapter

Adds a way to query the adapter from a device. Only valid in Dawn Native.
Returns a new reference to the caller. The caller is responsible for
releasing it.

This is needed so in Chrome, SharedImage can query the WGPUAdapter from
the WGPUDevice, and then WGPUAdapterProperties may be queried from the
WGPUAdapter.

Change-Id: I719a8728eff06ab7a22be3db5fb5cfd2ebb2f0f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99703
Reviewed-by: Zhenyao Mo <zmo@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2022-08-18 18:02:00 +00:00 committed by Dawn LUCI CQ
parent 1ac1514ad2
commit bf3243568c
6 changed files with 19 additions and 0 deletions

View File

@ -1141,6 +1141,11 @@
{"name": "features", "type": "feature name", "annotation": "*"}
]
},
{
"name": "get adapter",
"returns": "adapter",
"tags": ["dawn"]
},
{
"name": "get queue",
"returns": "queue"

View File

@ -224,6 +224,7 @@
"DeviceCreateQuerySet",
"DeviceCreateTexture",
"DeviceCreateErrorTexture",
"DeviceGetAdapter",
"DeviceGetQueue",
"DeviceInjectError"
],

View File

@ -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);

View File

@ -269,6 +269,7 @@ class DeviceBase : public RefCountedWithExternalCount {
ExternalTextureBase* APICreateErrorExternalTexture();
TextureBase* APICreateErrorTexture(const TextureDescriptor* desc);
AdapterBase* APIGetAdapter();
QueueBase* APIGetQueue();
bool APIGetLimits(SupportedLimits* limits) const;

View File

@ -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

View File

@ -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;