diff --git a/dawn.json b/dawn.json index 885a74cffd..d6cbc6b37f 100644 --- a/dawn.json +++ b/dawn.json @@ -1203,32 +1203,6 @@ {"value": 1, "name": "destroyed"} ] }, - "device properties": { - "category": "structure", - "extensible": false, - "tags": ["dawn"], - "members": [ - {"name": "device ID", "type": "uint32_t"}, - {"name": "vendor ID", "type": "uint32_t"}, - {"name": "adapter type", "type": "adapter type"}, - {"name": "texture compression BC", "type": "bool", "default": "false"}, - {"name": "texture compression ETC2", "type": "bool", "default": "false"}, - {"name": "texture compression ASTC", "type": "bool", "default": "false"}, - {"name": "shader float16", "type": "bool", "default": "false"}, - {"name": "pipeline statistics query", "type": "bool", "default": "false"}, - {"name": "timestamp query", "type": "bool", "default": "false"}, - {"name": "multi planar formats", "type": "bool", "default": "false"}, - {"name": "depth clamping", "type": "bool", "default": "false"}, - {"name": "depth24 unorm stencil8", "type": "bool", "default": "false"}, - {"name": "depth32 float stencil8", "type": "bool", "default": "false"}, - {"name": "chromium experimental dp4a", "type": "bool", "default": "false"}, - {"name": "indirect first instance", "type": "bool", "default": "false"}, - {"name": "invalid feature", "type": "bool", "default": "false"}, - {"name": "dawn internal usages", "type": "bool", "default": "false"}, - {"name": "dawn native", "type": "bool", "default": "false"}, - {"name": "limits", "type": "supported limits"} - ] - }, "double": { "category": "native" }, diff --git a/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h index 5de6aea5f4..9dab39752d 100644 --- a/include/dawn/native/DawnNative.h +++ b/include/dawn/native/DawnNative.h @@ -86,7 +86,6 @@ class DAWN_NATIVE_EXPORT Adapter { std::vector GetSupportedExtensions() const; std::vector GetSupportedFeatures() const; - WGPUDeviceProperties GetAdapterProperties() const; bool GetLimits(WGPUSupportedLimits* limits) const; void SetUseTieredLimits(bool useTieredLimits); diff --git a/src/dawn/native/Adapter.cpp b/src/dawn/native/Adapter.cpp index 929d6864c3..68e0420346 100644 --- a/src/dawn/native/Adapter.cpp +++ b/src/dawn/native/Adapter.cpp @@ -174,22 +174,6 @@ bool AdapterBase::SupportsAllRequiredFeatures( return true; } -WGPUDeviceProperties AdapterBase::GetAdapterProperties() const { - WGPUDeviceProperties adapterProperties = {}; - adapterProperties.deviceID = mDeviceId; - adapterProperties.vendorID = mVendorId; - adapterProperties.adapterType = static_cast(mAdapterType); - - mSupportedFeatures.InitializeDeviceProperties(&adapterProperties); - // This is OK for now because there are no limit feature structs. - // If we add additional structs, the caller will need to provide memory - // to store them (ex. by calling GetLimits directly instead). Currently, - // we keep this function as it's only used internally in Chromium to - // send the adapter properties across the wire. - GetLimits(FromAPI(&adapterProperties.limits)); - return adapterProperties; -} - bool AdapterBase::GetLimits(SupportedLimits* limits) const { ASSERT(limits != nullptr); if (limits->nextInChain != nullptr) { diff --git a/src/dawn/native/Adapter.h b/src/dawn/native/Adapter.h index ba69b38b45..f979b35d8d 100644 --- a/src/dawn/native/Adapter.h +++ b/src/dawn/native/Adapter.h @@ -57,7 +57,6 @@ class AdapterBase : public RefCounted { FeaturesSet GetSupportedFeatures() const; bool SupportsAllRequiredFeatures( const ityp::span& features) const; - WGPUDeviceProperties GetAdapterProperties() const; bool GetLimits(SupportedLimits* limits) const; diff --git a/src/dawn/native/DawnNative.cpp b/src/dawn/native/DawnNative.cpp index 7eaf0c72cc..5cb93e2031 100644 --- a/src/dawn/native/DawnNative.cpp +++ b/src/dawn/native/DawnNative.cpp @@ -125,10 +125,6 @@ std::vector Adapter::GetSupportedFeatures() const { return supportedFeaturesSet.GetEnabledFeatureNames(); } -WGPUDeviceProperties Adapter::GetAdapterProperties() const { - return mImpl->GetAdapterProperties(); -} - bool Adapter::GetLimits(WGPUSupportedLimits* limits) const { return mImpl->GetLimits(FromAPI(limits)); } diff --git a/src/dawn/native/Features.cpp b/src/dawn/native/Features.cpp index a813c6871d..7929a92822 100644 --- a/src/dawn/native/Features.cpp +++ b/src/dawn/native/Features.cpp @@ -26,7 +26,6 @@ namespace { struct FeatureEnumAndInfo { Feature feature; FeatureInfo info; - bool WGPUDeviceProperties::*memberInWGPUDeviceProperties; }; using FeatureEnumAndInfoList = @@ -35,69 +34,55 @@ using FeatureEnumAndInfoList = static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {{ {Feature::TextureCompressionBC, {"texture-compression-bc", "Support Block Compressed (BC) texture formats", - "https://bugs.chromium.org/p/dawn/issues/detail?id=42"}, - &WGPUDeviceProperties::textureCompressionBC}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=42"}}, {Feature::TextureCompressionETC2, {"texture-compression-etc2", "Support Ericsson Texture Compressed (ETC2/EAC) texture " "formats", - "https://bugs.chromium.org/p/dawn/issues/detail?id=955"}, - &WGPUDeviceProperties::textureCompressionETC2}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=955"}}, {Feature::TextureCompressionASTC, {"texture-compression-astc", "Support Adaptable Scalable Texture Compressed (ASTC) " "texture formats", - "https://bugs.chromium.org/p/dawn/issues/detail?id=955"}, - &WGPUDeviceProperties::textureCompressionASTC}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=955"}}, {Feature::ShaderFloat16, {"shader-float16", "Support 16bit float arithmetic and declarations in uniform and storage buffers", - "https://bugs.chromium.org/p/dawn/issues/detail?id=426"}, - &WGPUDeviceProperties::shaderFloat16}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=426"}}, {Feature::PipelineStatisticsQuery, {"pipeline-statistics-query", "Support Pipeline Statistics Query", - "https://bugs.chromium.org/p/dawn/issues/detail?id=434"}, - &WGPUDeviceProperties::pipelineStatisticsQuery}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=434"}}, {Feature::TimestampQuery, {"timestamp-query", "Support Timestamp Query", - "https://bugs.chromium.org/p/dawn/issues/detail?id=434"}, - &WGPUDeviceProperties::timestampQuery}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=434"}}, {Feature::DepthClamping, {"depth-clamping", "Clamp depth to [0, 1] in NDC space instead of clipping", - "https://bugs.chromium.org/p/dawn/issues/detail?id=716"}, - &WGPUDeviceProperties::depthClamping}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=716"}}, {Feature::Depth24UnormStencil8, {"depth24unorm-stencil8", "Support depth24unorm-stencil8 texture format", - "https://bugs.chromium.org/p/dawn/issues/detail?id=690"}, - &WGPUDeviceProperties::depth24UnormStencil8}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=690"}}, {Feature::Depth32FloatStencil8, {"depth32float-stencil8", "Support depth32float-stencil8 texture format", - "https://bugs.chromium.org/p/dawn/issues/detail?id=690"}, - &WGPUDeviceProperties::depth32FloatStencil8}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=690"}}, {Feature::ChromiumExperimentalDp4a, {"chromium-experimental-dp4a", "Support experimental DP4a instructions in WGSL", - "https://bugs.chromium.org/p/tint/issues/detail?id=1497"}, - &WGPUDeviceProperties::chromiumExperimentalDp4a}, + "https://bugs.chromium.org/p/tint/issues/detail?id=1497"}}, {Feature::IndirectFirstInstance, {"indirect-first-instance", "Support non-zero first instance values on indirect draw calls", - "https://bugs.chromium.org/p/dawn/issues/detail?id=1197"}, - &WGPUDeviceProperties::indirectFirstInstance}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=1197"}}, {Feature::DawnInternalUsages, {"dawn-internal-usages", "Add internal usages to resources to affect how the texture is allocated, but not " "frontend validation. Other internal commands may access this usage.", "https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/" - "dawn_internal_usages.md"}, - &WGPUDeviceProperties::dawnInternalUsages}, + "dawn_internal_usages.md"}}, {Feature::MultiPlanarFormats, {"multiplanar-formats", "Import and use multi-planar texture formats with per plane views", - "https://bugs.chromium.org/p/dawn/issues/detail?id=551"}, - &WGPUDeviceProperties::multiPlanarFormats}, + "https://bugs.chromium.org/p/dawn/issues/detail?id=551"}}, {Feature::DawnNative, {"dawn-native", "WebGPU is running on top of dawn_native.", "https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/" - "dawn_native.md"}, - &WGPUDeviceProperties::dawnNative}, + "dawn_native.md"}}, }}; Feature FromAPIFeature(wgpu::FeatureName feature) { @@ -225,14 +210,6 @@ std::vector FeaturesSet::GetEnabledFeatureNames() const { return enabledFeatureNames; } -void FeaturesSet::InitializeDeviceProperties(WGPUDeviceProperties* properties) const { - ASSERT(properties != nullptr); - - for (uint32_t i : IterateBitSet(featuresBitSet)) { - properties->*(kFeatureNameAndInfoList[i].memberInWGPUDeviceProperties) = true; - } -} - wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature) { ASSERT(feature != Feature::InvalidEnum); return ToAPIFeature(feature); diff --git a/src/dawn/native/Features.h b/src/dawn/native/Features.h index ebf804e5ca..3f4318b981 100644 --- a/src/dawn/native/Features.h +++ b/src/dawn/native/Features.h @@ -62,7 +62,6 @@ struct FeaturesSet { // non-null. size_t EnumerateFeatures(wgpu::FeatureName* features) const; std::vector GetEnabledFeatureNames() const; - void InitializeDeviceProperties(WGPUDeviceProperties* properties) const; }; wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature); diff --git a/src/dawn/node/binding/GPUAdapter.cpp b/src/dawn/node/binding/GPUAdapter.cpp index 511225e297..58b89b65bc 100644 --- a/src/dawn/node/binding/GPUAdapter.cpp +++ b/src/dawn/node/binding/GPUAdapter.cpp @@ -15,6 +15,7 @@ #include "src/dawn/node/binding/GPUAdapter.h" #include +#include #include #include "src/dawn/node/binding/Errors.h" @@ -91,29 +92,33 @@ namespace { //////////////////////////////////////////////////////////////////////////////// class Features : public interop::GPUSupportedFeatures { public: - explicit Features(WGPUDeviceProperties properties) { - if (properties.depth32FloatStencil8) { - enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8); + explicit Features(std::vector features) { + for (wgpu::FeatureName feature : features) { + switch (feature) { + case wgpu::FeatureName::Depth32FloatStencil8: + enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8); + break; + case wgpu::FeatureName::TimestampQuery: + enabled_.emplace(interop::GPUFeatureName::kTimestampQuery); + break; + case wgpu::FeatureName::TextureCompressionBC: + enabled_.emplace(interop::GPUFeatureName::kTextureCompressionBc); + break; + case wgpu::FeatureName::TextureCompressionETC2: + enabled_.emplace(interop::GPUFeatureName::kTextureCompressionEtc2); + break; + case wgpu::FeatureName::TextureCompressionASTC: + enabled_.emplace(interop::GPUFeatureName::kTextureCompressionAstc); + break; + case wgpu::FeatureName::IndirectFirstInstance: + enabled_.emplace(interop::GPUFeatureName::kIndirectFirstInstance); + break; + default: + break; + } } - if (properties.timestampQuery) { - enabled_.emplace(interop::GPUFeatureName::kTimestampQuery); - } - if (properties.textureCompressionBC) { - enabled_.emplace(interop::GPUFeatureName::kTextureCompressionBc); - } - if (properties.textureCompressionETC2) { - enabled_.emplace(interop::GPUFeatureName::kTextureCompressionEtc2); - } - if (properties.textureCompressionASTC) { - enabled_.emplace(interop::GPUFeatureName::kTextureCompressionAstc); - } - if (properties.timestampQuery) { - enabled_.emplace(interop::GPUFeatureName::kTimestampQuery); - } - // TODO(dawn:1123) add support for these extensions when possible. // wgpu::interop::GPUFeatureName::kDepthClipControl - // wgpu::interop::GPUFeatureName::kIndirectFirstInstance // wgpu::interop::GPUFeatureName::kShaderF16 // wgpu::interop::GPUFeatureName::kBgra8UnormStorage } @@ -152,7 +157,11 @@ GPUAdapter::GPUAdapter(dawn::native::Adapter a, const Flags& flags) : adapter_(a // TODO(dawn:1133): Avoid the extra copy by making the generator make a virtual method with const // std::string& interop::Interface GPUAdapter::getFeatures(Napi::Env env) { - return interop::GPUSupportedFeatures::Create(env, adapter_.GetAdapterProperties()); + wgpu::Adapter adapter(adapter_.Get()); + size_t count = adapter.EnumerateFeatures(nullptr); + std::vector features(count); + adapter.EnumerateFeatures(&features[0]); + return interop::GPUSupportedFeatures::Create(env, std::move(features)); } interop::Interface GPUAdapter::getLimits(Napi::Env env) {