diff --git a/src/dawn_native/Adapter.cpp b/src/dawn_native/Adapter.cpp index 362b540c0b..02f0966399 100644 --- a/src/dawn_native/Adapter.cpp +++ b/src/dawn_native/Adapter.cpp @@ -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; diff --git a/src/dawn_native/Adapter.h b/src/dawn_native/Adapter.h index f4cb28ae6e..410a9a35a4 100644 --- a/src/dawn_native/Adapter.h +++ b/src/dawn_native/Adapter.h @@ -39,6 +39,7 @@ namespace dawn_native { ExtensionsSet GetSupportedExtensions() const; bool SupportsAllRequestedExtensions( const std::vector& requestedExtensions) const; + WGPUDeviceProperties GetAdapterProperties() const; protected: PCIInfo mPCIInfo = {}; diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp index c30c6906cc..45fbb55ad9 100644 --- a/src/dawn_native/DawnNative.cpp +++ b/src/dawn_native/DawnNative.cpp @@ -61,6 +61,10 @@ namespace dawn_native { return supportedExtensionsSet.GetEnabledExtensionNames(); } + WGPUDeviceProperties Adapter::GetAdapterProperties() const { + return mImpl->GetAdapterProperties(); + } + Adapter::operator bool() const { return mImpl != nullptr; } diff --git a/src/dawn_native/Extensions.cpp b/src/dawn_native/Extensions.cpp index 2de7a8511d..a2b5a9dff1 100644 --- a/src/dawn_native/Extensions.cpp +++ b/src/dawn_native/Extensions.cpp @@ -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); diff --git a/src/dawn_native/Extensions.h b/src/dawn_native/Extensions.h index 274096fe3e..6e6d82d9f4 100644 --- a/src/dawn_native/Extensions.h +++ b/src/dawn_native/Extensions.h @@ -39,6 +39,7 @@ namespace dawn_native { void EnableExtension(Extension extension); bool IsEnabled(Extension extension) const; std::vector GetEnabledExtensionNames() const; + void InitializeDeviceProperties(WGPUDeviceProperties* properties) const; }; const char* ExtensionEnumToName(Extension extension); diff --git a/src/include/dawn_native/DawnNative.h b/src/include/dawn_native/DawnNative.h index 6e1bd63a62..b9a1d0eaee 100644 --- a/src/include/dawn_native/DawnNative.h +++ b/src/include/dawn_native/DawnNative.h @@ -90,6 +90,7 @@ namespace dawn_native { DeviceType GetDeviceType() const; const PCIInfo& GetPCIInfo() const; std::vector GetSupportedExtensions() const; + WGPUDeviceProperties GetAdapterProperties() const; explicit operator bool() const;