Delete WGPUDeviceProperties

This struct is no longer needed now that the adapter exposes
a way to query its features that works both in native and the
wire.

Change-Id: Ib0d865330f65473bb0363858a9284e630da52eb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93340
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2022-06-13 16:58:27 +00:00 committed by Dawn LUCI CQ
parent cda3d7bfa8
commit 1faf5921c6
8 changed files with 44 additions and 107 deletions

View File

@ -1203,32 +1203,6 @@
{"value": 1, "name": "destroyed"} {"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": { "double": {
"category": "native" "category": "native"
}, },

View File

@ -86,7 +86,6 @@ class DAWN_NATIVE_EXPORT Adapter {
std::vector<const char*> GetSupportedExtensions() const; std::vector<const char*> GetSupportedExtensions() const;
std::vector<const char*> GetSupportedFeatures() const; std::vector<const char*> GetSupportedFeatures() const;
WGPUDeviceProperties GetAdapterProperties() const;
bool GetLimits(WGPUSupportedLimits* limits) const; bool GetLimits(WGPUSupportedLimits* limits) const;
void SetUseTieredLimits(bool useTieredLimits); void SetUseTieredLimits(bool useTieredLimits);

View File

@ -174,22 +174,6 @@ bool AdapterBase::SupportsAllRequiredFeatures(
return true; return true;
} }
WGPUDeviceProperties AdapterBase::GetAdapterProperties() const {
WGPUDeviceProperties adapterProperties = {};
adapterProperties.deviceID = mDeviceId;
adapterProperties.vendorID = mVendorId;
adapterProperties.adapterType = static_cast<WGPUAdapterType>(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 { bool AdapterBase::GetLimits(SupportedLimits* limits) const {
ASSERT(limits != nullptr); ASSERT(limits != nullptr);
if (limits->nextInChain != nullptr) { if (limits->nextInChain != nullptr) {

View File

@ -57,7 +57,6 @@ class AdapterBase : public RefCounted {
FeaturesSet GetSupportedFeatures() const; FeaturesSet GetSupportedFeatures() const;
bool SupportsAllRequiredFeatures( bool SupportsAllRequiredFeatures(
const ityp::span<size_t, const wgpu::FeatureName>& features) const; const ityp::span<size_t, const wgpu::FeatureName>& features) const;
WGPUDeviceProperties GetAdapterProperties() const;
bool GetLimits(SupportedLimits* limits) const; bool GetLimits(SupportedLimits* limits) const;

View File

@ -125,10 +125,6 @@ std::vector<const char*> Adapter::GetSupportedFeatures() const {
return supportedFeaturesSet.GetEnabledFeatureNames(); return supportedFeaturesSet.GetEnabledFeatureNames();
} }
WGPUDeviceProperties Adapter::GetAdapterProperties() const {
return mImpl->GetAdapterProperties();
}
bool Adapter::GetLimits(WGPUSupportedLimits* limits) const { bool Adapter::GetLimits(WGPUSupportedLimits* limits) const {
return mImpl->GetLimits(FromAPI(limits)); return mImpl->GetLimits(FromAPI(limits));
} }

View File

@ -26,7 +26,6 @@ namespace {
struct FeatureEnumAndInfo { struct FeatureEnumAndInfo {
Feature feature; Feature feature;
FeatureInfo info; FeatureInfo info;
bool WGPUDeviceProperties::*memberInWGPUDeviceProperties;
}; };
using FeatureEnumAndInfoList = using FeatureEnumAndInfoList =
@ -35,69 +34,55 @@ using FeatureEnumAndInfoList =
static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {{ static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {{
{Feature::TextureCompressionBC, {Feature::TextureCompressionBC,
{"texture-compression-bc", "Support Block Compressed (BC) texture formats", {"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},
{Feature::TextureCompressionETC2, {Feature::TextureCompressionETC2,
{"texture-compression-etc2", {"texture-compression-etc2",
"Support Ericsson Texture Compressed (ETC2/EAC) texture " "Support Ericsson Texture Compressed (ETC2/EAC) texture "
"formats", "formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=955"}},
&WGPUDeviceProperties::textureCompressionETC2},
{Feature::TextureCompressionASTC, {Feature::TextureCompressionASTC,
{"texture-compression-astc", {"texture-compression-astc",
"Support Adaptable Scalable Texture Compressed (ASTC) " "Support Adaptable Scalable Texture Compressed (ASTC) "
"texture formats", "texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=955"}},
&WGPUDeviceProperties::textureCompressionASTC},
{Feature::ShaderFloat16, {Feature::ShaderFloat16,
{"shader-float16", {"shader-float16",
"Support 16bit float arithmetic and declarations in uniform and storage buffers", "Support 16bit float arithmetic and declarations in uniform and storage buffers",
"https://bugs.chromium.org/p/dawn/issues/detail?id=426"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=426"}},
&WGPUDeviceProperties::shaderFloat16},
{Feature::PipelineStatisticsQuery, {Feature::PipelineStatisticsQuery,
{"pipeline-statistics-query", "Support Pipeline Statistics Query", {"pipeline-statistics-query", "Support Pipeline Statistics Query",
"https://bugs.chromium.org/p/dawn/issues/detail?id=434"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=434"}},
&WGPUDeviceProperties::pipelineStatisticsQuery},
{Feature::TimestampQuery, {Feature::TimestampQuery,
{"timestamp-query", "Support Timestamp Query", {"timestamp-query", "Support Timestamp Query",
"https://bugs.chromium.org/p/dawn/issues/detail?id=434"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=434"}},
&WGPUDeviceProperties::timestampQuery},
{Feature::DepthClamping, {Feature::DepthClamping,
{"depth-clamping", "Clamp depth to [0, 1] in NDC space instead of clipping", {"depth-clamping", "Clamp depth to [0, 1] in NDC space instead of clipping",
"https://bugs.chromium.org/p/dawn/issues/detail?id=716"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=716"}},
&WGPUDeviceProperties::depthClamping},
{Feature::Depth24UnormStencil8, {Feature::Depth24UnormStencil8,
{"depth24unorm-stencil8", "Support depth24unorm-stencil8 texture format", {"depth24unorm-stencil8", "Support depth24unorm-stencil8 texture format",
"https://bugs.chromium.org/p/dawn/issues/detail?id=690"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=690"}},
&WGPUDeviceProperties::depth24UnormStencil8},
{Feature::Depth32FloatStencil8, {Feature::Depth32FloatStencil8,
{"depth32float-stencil8", "Support depth32float-stencil8 texture format", {"depth32float-stencil8", "Support depth32float-stencil8 texture format",
"https://bugs.chromium.org/p/dawn/issues/detail?id=690"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=690"}},
&WGPUDeviceProperties::depth32FloatStencil8},
{Feature::ChromiumExperimentalDp4a, {Feature::ChromiumExperimentalDp4a,
{"chromium-experimental-dp4a", "Support experimental DP4a instructions in WGSL", {"chromium-experimental-dp4a", "Support experimental DP4a instructions in WGSL",
"https://bugs.chromium.org/p/tint/issues/detail?id=1497"}, "https://bugs.chromium.org/p/tint/issues/detail?id=1497"}},
&WGPUDeviceProperties::chromiumExperimentalDp4a},
{Feature::IndirectFirstInstance, {Feature::IndirectFirstInstance,
{"indirect-first-instance", "Support non-zero first instance values on indirect draw calls", {"indirect-first-instance", "Support non-zero first instance values on indirect draw calls",
"https://bugs.chromium.org/p/dawn/issues/detail?id=1197"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=1197"}},
&WGPUDeviceProperties::indirectFirstInstance},
{Feature::DawnInternalUsages, {Feature::DawnInternalUsages,
{"dawn-internal-usages", {"dawn-internal-usages",
"Add internal usages to resources to affect how the texture is allocated, but not " "Add internal usages to resources to affect how the texture is allocated, but not "
"frontend validation. Other internal commands may access this usage.", "frontend validation. Other internal commands may access this usage.",
"https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/" "https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/"
"dawn_internal_usages.md"}, "dawn_internal_usages.md"}},
&WGPUDeviceProperties::dawnInternalUsages},
{Feature::MultiPlanarFormats, {Feature::MultiPlanarFormats,
{"multiplanar-formats", "Import and use multi-planar texture formats with per plane views", {"multiplanar-formats", "Import and use multi-planar texture formats with per plane views",
"https://bugs.chromium.org/p/dawn/issues/detail?id=551"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=551"}},
&WGPUDeviceProperties::multiPlanarFormats},
{Feature::DawnNative, {Feature::DawnNative,
{"dawn-native", "WebGPU is running on top of dawn_native.", {"dawn-native", "WebGPU is running on top of dawn_native.",
"https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/" "https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/"
"dawn_native.md"}, "dawn_native.md"}},
&WGPUDeviceProperties::dawnNative},
}}; }};
Feature FromAPIFeature(wgpu::FeatureName feature) { Feature FromAPIFeature(wgpu::FeatureName feature) {
@ -225,14 +210,6 @@ std::vector<const char*> FeaturesSet::GetEnabledFeatureNames() const {
return enabledFeatureNames; 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) { wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature) {
ASSERT(feature != Feature::InvalidEnum); ASSERT(feature != Feature::InvalidEnum);
return ToAPIFeature(feature); return ToAPIFeature(feature);

View File

@ -62,7 +62,6 @@ struct FeaturesSet {
// non-null. // non-null.
size_t EnumerateFeatures(wgpu::FeatureName* features) const; size_t EnumerateFeatures(wgpu::FeatureName* features) const;
std::vector<const char*> GetEnabledFeatureNames() const; std::vector<const char*> GetEnabledFeatureNames() const;
void InitializeDeviceProperties(WGPUDeviceProperties* properties) const;
}; };
wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature); wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature);

View File

@ -15,6 +15,7 @@
#include "src/dawn/node/binding/GPUAdapter.h" #include "src/dawn/node/binding/GPUAdapter.h"
#include <unordered_set> #include <unordered_set>
#include <utility>
#include <vector> #include <vector>
#include "src/dawn/node/binding/Errors.h" #include "src/dawn/node/binding/Errors.h"
@ -91,29 +92,33 @@ namespace {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class Features : public interop::GPUSupportedFeatures { class Features : public interop::GPUSupportedFeatures {
public: public:
explicit Features(WGPUDeviceProperties properties) { explicit Features(std::vector<wgpu::FeatureName> features) {
if (properties.depth32FloatStencil8) { for (wgpu::FeatureName feature : features) {
enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8); 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. // TODO(dawn:1123) add support for these extensions when possible.
// wgpu::interop::GPUFeatureName::kDepthClipControl // wgpu::interop::GPUFeatureName::kDepthClipControl
// wgpu::interop::GPUFeatureName::kIndirectFirstInstance
// wgpu::interop::GPUFeatureName::kShaderF16 // wgpu::interop::GPUFeatureName::kShaderF16
// wgpu::interop::GPUFeatureName::kBgra8UnormStorage // 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 // TODO(dawn:1133): Avoid the extra copy by making the generator make a virtual method with const
// std::string& // std::string&
interop::Interface<interop::GPUSupportedFeatures> GPUAdapter::getFeatures(Napi::Env env) { interop::Interface<interop::GPUSupportedFeatures> GPUAdapter::getFeatures(Napi::Env env) {
return interop::GPUSupportedFeatures::Create<Features>(env, adapter_.GetAdapterProperties()); wgpu::Adapter adapter(adapter_.Get());
size_t count = adapter.EnumerateFeatures(nullptr);
std::vector<wgpu::FeatureName> features(count);
adapter.EnumerateFeatures(&features[0]);
return interop::GPUSupportedFeatures::Create<Features>(env, std::move(features));
} }
interop::Interface<interop::GPUSupportedLimits> GPUAdapter::getLimits(Napi::Env env) { interop::Interface<interop::GPUSupportedLimits> GPUAdapter::getLimits(Napi::Env env) {