Implement querying WGPUDeviceProperties from dawn_native::Adapter

This patch adds an interface GetAdapterProperties() on Adapter which can
directly return a WGPUDeviceProperties object that includes the
information of the adapter.

BUG=chromium:996713

Change-Id: I9a7b1512d259761e198dfac3eafa718171d47241
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13340
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2019-11-13 01:53:25 +00:00 committed by Commit Bot service account
parent 604072bc2e
commit cfdbaaa376
6 changed files with 25 additions and 1 deletions

View File

@ -56,6 +56,13 @@ namespace dawn_native {
return true;
}
WGPUDeviceProperties AdapterBase::GetAdapterProperties() const {
WGPUDeviceProperties adapterProperties = {};
mSupportedExtensions.InitializeDeviceProperties(&adapterProperties);
return adapterProperties;
}
DeviceBase* AdapterBase::CreateDevice(const DeviceDescriptor* descriptor) {
DeviceBase* result = nullptr;

View File

@ -39,6 +39,7 @@ namespace dawn_native {
ExtensionsSet GetSupportedExtensions() const;
bool SupportsAllRequestedExtensions(
const std::vector<const char*>& requestedExtensions) const;
WGPUDeviceProperties GetAdapterProperties() const;
protected:
PCIInfo mPCIInfo = {};

View File

@ -61,6 +61,10 @@ namespace dawn_native {
return supportedExtensionsSet.GetEnabledExtensionNames();
}
WGPUDeviceProperties Adapter::GetAdapterProperties() const {
return mImpl->GetAdapterProperties();
}
Adapter::operator bool() const {
return mImpl != nullptr;
}

View File

@ -24,6 +24,7 @@ namespace dawn_native {
struct ExtensionEnumAndInfo {
Extension extension;
ExtensionInfo info;
bool WGPUDeviceProperties::*memberInWGPUDeviceProperties;
};
using ExtensionEnumAndInfoList =
@ -32,7 +33,8 @@ namespace dawn_native {
static constexpr ExtensionEnumAndInfoList kExtensionNameAndInfoList = {
{{Extension::TextureCompressionBC,
{"texture_compression_bc", "Support Block Compressed (BC) texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"}}}};
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"},
&WGPUDeviceProperties::textureCompressionBC}}};
} // anonymous namespace
@ -60,6 +62,14 @@ namespace dawn_native {
return enabledExtensionNames;
}
void ExtensionsSet::InitializeDeviceProperties(WGPUDeviceProperties* properties) const {
ASSERT(properties != nullptr);
for (uint32_t i : IterateBitSet(extensionsBitSet)) {
properties->*(kExtensionNameAndInfoList[i].memberInWGPUDeviceProperties) = true;
}
}
const char* ExtensionEnumToName(Extension extension) {
ASSERT(extension != Extension::InvalidEnum);

View File

@ -39,6 +39,7 @@ namespace dawn_native {
void EnableExtension(Extension extension);
bool IsEnabled(Extension extension) const;
std::vector<const char*> GetEnabledExtensionNames() const;
void InitializeDeviceProperties(WGPUDeviceProperties* properties) const;
};
const char* ExtensionEnumToName(Extension extension);

View File

@ -90,6 +90,7 @@ namespace dawn_native {
DeviceType GetDeviceType() const;
const PCIInfo& GetPCIInfo() const;
std::vector<const char*> GetSupportedExtensions() const;
WGPUDeviceProperties GetAdapterProperties() const;
explicit operator bool() const;