Dawn: Refactor adapter features, part 1

This CL make adapter base holds it supported features set as private
instead of protected and provide a method to set features enabled. This
CL also rename SetSupportedFeatures in null adapter to
SetSupportedFeaturesForTesting.
This is a pre-CL for implementing UseDXC as instance toggle, which may
require further refactor and adapter features logic to handle the toggles.

Bug: dawn:1495
Change-Id: I0a07e5653b43f18278cb4a2fe90985cc90b66068
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124421
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Zhaoming Jiang 2023-03-16 19:06:33 +00:00 committed by Dawn LUCI CQ
parent 498e91826e
commit 981d5a6f08
12 changed files with 104 additions and 104 deletions

View File

@ -40,8 +40,8 @@ MaybeError AdapterBase::Initialize() {
DAWN_TRY_CONTEXT(InitializeImpl(), "initializing adapter (backend=%s)", mBackend); DAWN_TRY_CONTEXT(InitializeImpl(), "initializing adapter (backend=%s)", mBackend);
InitializeVendorArchitectureImpl(); InitializeVendorArchitectureImpl();
mSupportedFeatures.EnableFeature(Feature::DawnNative); EnableFeature(Feature::DawnNative);
mSupportedFeatures.EnableFeature(Feature::DawnInternalUsages); EnableFeature(Feature::DawnInternalUsages);
InitializeSupportedFeaturesImpl(); InitializeSupportedFeaturesImpl();
DAWN_TRY_CONTEXT( DAWN_TRY_CONTEXT(
@ -213,9 +213,12 @@ const TogglesState& AdapterBase::GetTogglesState() const {
return mTogglesState; return mTogglesState;
} }
MaybeError AdapterBase::ValidateFeatureSupportedWithDeviceToggles( void AdapterBase::EnableFeature(Feature feature) {
wgpu::FeatureName feature, mSupportedFeatures.EnableFeature(feature);
const TogglesState& deviceTogglesState) { }
MaybeError AdapterBase::ValidateFeatureSupportedWithToggles(wgpu::FeatureName feature,
const TogglesState& toggles) const {
DAWN_TRY(ValidateFeatureName(feature)); DAWN_TRY(ValidateFeatureName(feature));
DAWN_INVALID_IF(!mSupportedFeatures.IsEnabled(feature), DAWN_INVALID_IF(!mSupportedFeatures.IsEnabled(feature),
"Requested feature %s is not supported.", feature); "Requested feature %s is not supported.", feature);
@ -224,12 +227,20 @@ MaybeError AdapterBase::ValidateFeatureSupportedWithDeviceToggles(
// Experimental features are guarded by toggle DisallowUnsafeAPIs. // Experimental features are guarded by toggle DisallowUnsafeAPIs.
if (featureInfo->featureState == FeatureInfo::FeatureState::Experimental) { if (featureInfo->featureState == FeatureInfo::FeatureState::Experimental) {
// DisallowUnsafeAPIs toggle is by default enabled if not explicitly disabled. // DisallowUnsafeAPIs toggle is by default enabled if not explicitly disabled.
DAWN_INVALID_IF(deviceTogglesState.IsEnabled(Toggle::DisallowUnsafeAPIs), DAWN_INVALID_IF(toggles.IsEnabled(Toggle::DisallowUnsafeAPIs),
"Feature %s is guarded by toggle disallow_unsafe_apis.", featureInfo->name); "Feature %s is guarded by toggle disallow_unsafe_apis.", featureInfo->name);
} }
// Do backend-specific validation. // Do backend-specific validation.
return ValidateFeatureSupportedWithDeviceTogglesImpl(feature, deviceTogglesState); return ValidateFeatureSupportedWithTogglesImpl(feature, toggles);
}
void AdapterBase::SetSupportedFeaturesForTesting(
const std::vector<wgpu::FeatureName>& requiredFeatures) {
mSupportedFeatures = {};
for (wgpu::FeatureName f : requiredFeatures) {
mSupportedFeatures.EnableFeature(f);
}
} }
ResultOrError<Ref<DeviceBase>> AdapterBase::CreateDeviceInternal( ResultOrError<Ref<DeviceBase>> AdapterBase::CreateDeviceInternal(
@ -285,7 +296,7 @@ ResultOrError<Ref<DeviceBase>> AdapterBase::CreateDeviceInternal(
// supported features using adapter toggles or device toggles. // supported features using adapter toggles or device toggles.
for (uint32_t i = 0; i < descriptor->requiredFeaturesCount; ++i) { for (uint32_t i = 0; i < descriptor->requiredFeaturesCount; ++i) {
wgpu::FeatureName feature = descriptor->requiredFeatures[i]; wgpu::FeatureName feature = descriptor->requiredFeatures[i];
DAWN_TRY(ValidateFeatureSupportedWithDeviceToggles(feature, deviceToggles)); DAWN_TRY(ValidateFeatureSupportedWithToggles(feature, deviceToggles));
} }
if (descriptor->requiredLimits != nullptr) { if (descriptor->requiredLimits != nullptr) {

View File

@ -16,6 +16,7 @@
#define SRC_DAWN_NATIVE_ADAPTER_H_ #define SRC_DAWN_NATIVE_ADAPTER_H_
#include <string> #include <string>
#include <vector>
#include "dawn/native/DawnNative.h" #include "dawn/native/DawnNative.h"
@ -82,15 +83,15 @@ class AdapterBase : public RefCounted {
gpu_info::DriverVersion mDriverVersion; gpu_info::DriverVersion mDriverVersion;
std::string mDriverDescription; std::string mDriverDescription;
// Features set that CAN be supported by devices of this adapter. Some features in this set may // Mark a feature as enabled in mSupportedFeatures.
// be guarded by toggles, and creating a device with these features required may result in a void EnableFeature(Feature feature);
// validation error if proper toggles are not enabled/disabled.
FeaturesSet mSupportedFeatures;
// Check if a feature os supported by this adapter AND suitable with given toggles. // Check if a feature os supported by this adapter AND suitable with given toggles.
// TODO(dawn:1495): After implementing adapter toggles, remove this and use adapter toggles // TODO(dawn:1495): After implementing adapter toggles, remove this and use adapter toggles
// instead of device toggles to validate supported features. // instead of device toggles to validate supported features.
MaybeError ValidateFeatureSupportedWithDeviceToggles(wgpu::FeatureName feature, MaybeError ValidateFeatureSupportedWithToggles(wgpu::FeatureName feature,
const TogglesState& deviceTogglesState); const TogglesState& toggles) const;
// Used for the tests that intend to use an adapter without all features enabled.
void SetSupportedFeaturesForTesting(const std::vector<wgpu::FeatureName>& requiredFeatures);
private: private:
// Backend-specific force-setting and defaulting device toggles // Backend-specific force-setting and defaulting device toggles
@ -109,9 +110,9 @@ class AdapterBase : public RefCounted {
virtual void InitializeVendorArchitectureImpl(); virtual void InitializeVendorArchitectureImpl();
virtual MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl( virtual MaybeError ValidateFeatureSupportedWithTogglesImpl(
wgpu::FeatureName feature, wgpu::FeatureName feature,
const TogglesState& deviceTogglesState) = 0; const TogglesState& toggles) const = 0;
ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(const DeviceDescriptor* descriptor); ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(const DeviceDescriptor* descriptor);
@ -122,6 +123,11 @@ class AdapterBase : public RefCounted {
// Adapter toggles state, currently only inherited from instance toggles state. // Adapter toggles state, currently only inherited from instance toggles state.
TogglesState mTogglesState; TogglesState mTogglesState;
// Features set that CAN be supported by devices of this adapter. Some features in this set may
// be guarded by toggles, and creating a device with these features required may result in a
// validation error if proper toggles are not enabled/disabled.
FeaturesSet mSupportedFeatures;
CombinedLimits mLimits; CombinedLimits mLimits;
bool mUseTieredLimits = false; bool mUseTieredLimits = false;
}; };

View File

@ -135,26 +135,26 @@ bool Adapter::AreTimestampQueriesSupported() const {
} }
void Adapter::InitializeSupportedFeaturesImpl() { void Adapter::InitializeSupportedFeaturesImpl() {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats); EnableFeature(Feature::MultiPlanarFormats);
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8); EnableFeature(Feature::Depth32FloatStencil8);
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance); EnableFeature(Feature::IndirectFirstInstance);
mSupportedFeatures.EnableFeature(Feature::RG11B10UfloatRenderable); EnableFeature(Feature::RG11B10UfloatRenderable);
mSupportedFeatures.EnableFeature(Feature::DepthClipControl); EnableFeature(Feature::DepthClipControl);
if (AreTimestampQueriesSupported()) { if (AreTimestampQueriesSupported()) {
mSupportedFeatures.EnableFeature(Feature::TimestampQuery); EnableFeature(Feature::TimestampQuery);
mSupportedFeatures.EnableFeature(Feature::TimestampQueryInsidePasses); EnableFeature(Feature::TimestampQueryInsidePasses);
} }
mSupportedFeatures.EnableFeature(Feature::PipelineStatisticsQuery); EnableFeature(Feature::PipelineStatisticsQuery);
// Both Dp4a and ShaderF16 features require DXC version being 1.4 or higher // Both Dp4a and ShaderF16 features require DXC version being 1.4 or higher
if (GetBackend()->IsDXCAvailableAndVersionAtLeast(1, 4, 1, 4)) { if (GetBackend()->IsDXCAvailableAndVersionAtLeast(1, 4, 1, 4)) {
if (mDeviceInfo.supportsDP4a) { if (mDeviceInfo.supportsDP4a) {
mSupportedFeatures.EnableFeature(Feature::ChromiumExperimentalDp4a); EnableFeature(Feature::ChromiumExperimentalDp4a);
} }
if (mDeviceInfo.supportsShaderF16) { if (mDeviceInfo.supportsShaderF16) {
mSupportedFeatures.EnableFeature(Feature::ShaderF16); EnableFeature(Feature::ShaderF16);
} }
} }
@ -164,7 +164,7 @@ void Adapter::InitializeSupportedFeaturesImpl() {
D3D12_FEATURE_FORMAT_SUPPORT, &bgra8unormFormatInfo, sizeof(bgra8unormFormatInfo)); D3D12_FEATURE_FORMAT_SUPPORT, &bgra8unormFormatInfo, sizeof(bgra8unormFormatInfo));
if (SUCCEEDED(hr) && if (SUCCEEDED(hr) &&
(bgra8unormFormatInfo.Support1 & D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW)) { (bgra8unormFormatInfo.Support1 & D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW)) {
mSupportedFeatures.EnableFeature(Feature::BGRA8UnormStorage); EnableFeature(Feature::BGRA8UnormStorage);
} }
} }
@ -342,16 +342,13 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
return {}; return {};
} }
MaybeError Adapter::ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const {
const TogglesState& deviceTogglesState) {
// shader-f16 feature and chromium-experimental-dp4a feature require DXC 1.4 or higher for // shader-f16 feature and chromium-experimental-dp4a feature require DXC 1.4 or higher for
// D3D12. // D3D12. Note that DXC version is checked in InitializeSupportedFeaturesImpl.
if (feature == wgpu::FeatureName::ShaderF16 || if (feature == wgpu::FeatureName::ShaderF16 ||
feature == wgpu::FeatureName::ChromiumExperimentalDp4a) { feature == wgpu::FeatureName::ChromiumExperimentalDp4a) {
DAWN_INVALID_IF(!(deviceTogglesState.IsEnabled(Toggle::UseDXC) && DAWN_INVALID_IF(!toggles.IsEnabled(Toggle::UseDXC), "Feature %s requires DXC for D3D12.",
GetBackend()->IsDXCAvailableAndVersionAtLeast(1, 4, 1, 4)),
"Feature %s requires DXC for D3D12.",
GetInstance()->GetFeatureInfo(feature)->name); GetInstance()->GetFeatureInfo(feature)->name);
} }
return {}; return {};

View File

@ -55,9 +55,8 @@ class Adapter : public d3d::Adapter {
void InitializeSupportedFeaturesImpl() override; void InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override; MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const override;
const TogglesState& deviceTogglesState) override;
MaybeError InitializeDebugLayerFilters(); MaybeError InitializeDebugLayerFilters();
void CleanUpDebugLayerFilters(); void CleanUpDebugLayerFilters();

View File

@ -431,28 +431,28 @@ class Adapter : public AdapterBase {
// Check compressed texture format with deprecated MTLFeatureSet way. // Check compressed texture format with deprecated MTLFeatureSet way.
#if DAWN_PLATFORM_IS(MACOS) #if DAWN_PLATFORM_IS(MACOS)
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
} }
#endif #endif
#if DAWN_PLATFORM_IS(IOS) #if DAWN_PLATFORM_IS(IOS)
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2); EnableFeature(Feature::TextureCompressionETC2);
} }
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v1]) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionASTC); EnableFeature(Feature::TextureCompressionASTC);
} }
#endif #endif
// Check compressed texture format with MTLGPUFamily // Check compressed texture format with MTLGPUFamily
if (@available(macOS 10.15, iOS 13.0, *)) { if (@available(macOS 10.15, iOS 13.0, *)) {
if ([*mDevice supportsFamily:MTLGPUFamilyMac1]) { if ([*mDevice supportsFamily:MTLGPUFamilyMac1]) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
} }
if ([*mDevice supportsFamily:MTLGPUFamilyApple2]) { if ([*mDevice supportsFamily:MTLGPUFamilyApple2]) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2); EnableFeature(Feature::TextureCompressionETC2);
} }
if ([*mDevice supportsFamily:MTLGPUFamilyApple3]) { if ([*mDevice supportsFamily:MTLGPUFamilyApple3]) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionASTC); EnableFeature(Feature::TextureCompressionASTC);
} }
} }
@ -462,7 +462,7 @@ class Adapter : public AdapterBase {
{MTLCommonCounterVertexInvocations, MTLCommonCounterClipperInvocations, {MTLCommonCounterVertexInvocations, MTLCommonCounterClipperInvocations,
MTLCommonCounterClipperPrimitivesOut, MTLCommonCounterFragmentInvocations, MTLCommonCounterClipperPrimitivesOut, MTLCommonCounterFragmentInvocations,
MTLCommonCounterComputeKernelInvocations})) { MTLCommonCounterComputeKernelInvocations})) {
mSupportedFeatures.EnableFeature(Feature::PipelineStatisticsQuery); EnableFeature(Feature::PipelineStatisticsQuery);
} }
if (IsGPUCounterSupported(*mDevice, MTLCommonCounterSetTimestamp, if (IsGPUCounterSupported(*mDevice, MTLCommonCounterSetTimestamp,
@ -486,33 +486,33 @@ class Adapter : public AdapterBase {
#endif #endif
if (enableTimestampQuery) { if (enableTimestampQuery) {
mSupportedFeatures.EnableFeature(Feature::TimestampQuery); EnableFeature(Feature::TimestampQuery);
} }
if (enableTimestampQueryInsidePasses) { if (enableTimestampQueryInsidePasses) {
mSupportedFeatures.EnableFeature(Feature::TimestampQueryInsidePasses); EnableFeature(Feature::TimestampQueryInsidePasses);
} }
} }
} }
if (@available(macOS 10.11, iOS 11.0, *)) { if (@available(macOS 10.11, iOS 11.0, *)) {
mSupportedFeatures.EnableFeature(Feature::DepthClipControl); EnableFeature(Feature::DepthClipControl);
} }
if (@available(macOS 10.11, iOS 9.0, *)) { if (@available(macOS 10.11, iOS 9.0, *)) {
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8); EnableFeature(Feature::Depth32FloatStencil8);
} }
// Uses newTextureWithDescriptor::iosurface::plane which is available // Uses newTextureWithDescriptor::iosurface::plane which is available
// on ios 11.0+ and macOS 11.0+ // on ios 11.0+ and macOS 11.0+
if (@available(macOS 10.11, iOS 11.0, *)) { if (@available(macOS 10.11, iOS 11.0, *)) {
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats); EnableFeature(Feature::MultiPlanarFormats);
} }
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance); EnableFeature(Feature::IndirectFirstInstance);
mSupportedFeatures.EnableFeature(Feature::ShaderF16); EnableFeature(Feature::ShaderF16);
mSupportedFeatures.EnableFeature(Feature::RG11B10UfloatRenderable); EnableFeature(Feature::RG11B10UfloatRenderable);
mSupportedFeatures.EnableFeature(Feature::BGRA8UnormStorage); EnableFeature(Feature::BGRA8UnormStorage);
} }
void InitializeVendorArchitectureImpl() override { void InitializeVendorArchitectureImpl() override {
@ -759,9 +759,8 @@ class Adapter : public AdapterBase {
return {}; return {};
} }
MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const override {
const TogglesState& deviceToggles) override {
return {}; return {};
} }

View File

@ -50,21 +50,15 @@ bool Adapter::SupportsExternalImages() const {
return false; return false;
} }
// Used for the tests that intend to use an adapter without all features enabled.
void Adapter::SetSupportedFeatures(const std::vector<wgpu::FeatureName>& requiredFeatures) {
mSupportedFeatures = {};
for (wgpu::FeatureName f : requiredFeatures) {
mSupportedFeatures.EnableFeature(f);
}
}
MaybeError Adapter::InitializeImpl() { MaybeError Adapter::InitializeImpl() {
return {}; return {};
} }
void Adapter::InitializeSupportedFeaturesImpl() { void Adapter::InitializeSupportedFeaturesImpl() {
// Enable all features by default for the convenience of tests. // Enable all features by default for the convenience of tests.
mSupportedFeatures.featuresBitSet.set(); for (uint32_t i = 0; i < static_cast<uint32_t>(Feature::EnumCount); i++) {
EnableFeature(static_cast<Feature>(i));
}
} }
MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
@ -79,9 +73,8 @@ ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor*
return Device::Create(this, descriptor, deviceToggles); return Device::Create(this, descriptor, deviceToggles);
} }
MaybeError Adapter::ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const {
const TogglesState& deviceToggles) {
return {}; return {};
} }

View File

@ -181,16 +181,15 @@ class Adapter : public AdapterBase {
bool SupportsExternalImages() const override; bool SupportsExternalImages() const override;
// Used for the tests that intend to use an adapter without all features enabled. // Used for the tests that intend to use an adapter without all features enabled.
void SetSupportedFeatures(const std::vector<wgpu::FeatureName>& requiredFeatures); using AdapterBase::SetSupportedFeaturesForTesting;
private: private:
MaybeError InitializeImpl() override; MaybeError InitializeImpl() override;
void InitializeSupportedFeaturesImpl() override; void InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override; MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const override;
const TogglesState& deviceToggles) override;
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor, ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,

View File

@ -130,7 +130,7 @@ void Adapter::InitializeSupportedFeaturesImpl() {
if (supportsS3TC && (supportsTextureSRGB || supportsS3TCSRGB) && supportsRGTC && if (supportsS3TC && (supportsTextureSRGB || supportsS3TCSRGB) && supportsRGTC &&
supportsBPTC) { supportsBPTC) {
mSupportedFeatures.EnableFeature(dawn::native::Feature::TextureCompressionBC); EnableFeature(dawn::native::Feature::TextureCompressionBC);
} }
} }
@ -140,12 +140,12 @@ void Adapter::InitializeSupportedFeaturesImpl() {
// OpenGL ES: // OpenGL ES:
// https://www.khronos.org/registry/OpenGL-Refpages/es3/html/glDrawElementsIndirect.xhtml // https://www.khronos.org/registry/OpenGL-Refpages/es3/html/glDrawElementsIndirect.xhtml
if (mFunctions.IsAtLeastGL(4, 2)) { if (mFunctions.IsAtLeastGL(4, 2)) {
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance); EnableFeature(Feature::IndirectFirstInstance);
} }
// ShaderF16 // ShaderF16
if (mFunctions.IsGLExtensionSupported("GL_AMD_gpu_shader_half_float")) { if (mFunctions.IsGLExtensionSupported("GL_AMD_gpu_shader_half_float")) {
mSupportedFeatures.EnableFeature(Feature::ShaderF16); EnableFeature(Feature::ShaderF16);
} }
} }
@ -226,9 +226,8 @@ ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor*
return Device::Create(this, descriptor, mFunctions, std::move(context), deviceToggles); return Device::Create(this, descriptor, mFunctions, std::move(context), deviceToggles);
} }
MaybeError Adapter::ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const {
const TogglesState& deviceToggles) {
return {}; return {};
} }
} // namespace dawn::native::opengl } // namespace dawn::native::opengl

View File

@ -39,9 +39,8 @@ class Adapter : public AdapterBase {
void InitializeSupportedFeaturesImpl() override; void InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override; MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const override;
const TogglesState& deviceTogglesState) override;
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor, ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,

View File

@ -186,35 +186,35 @@ MaybeError Adapter::InitializeImpl() {
void Adapter::InitializeSupportedFeaturesImpl() { void Adapter::InitializeSupportedFeaturesImpl() {
// Initialize supported extensions // Initialize supported extensions
if (mDeviceInfo.features.textureCompressionBC == VK_TRUE) { if (mDeviceInfo.features.textureCompressionBC == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
} }
if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE) { if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2); EnableFeature(Feature::TextureCompressionETC2);
} }
if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE) { if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::TextureCompressionASTC); EnableFeature(Feature::TextureCompressionASTC);
} }
if (mDeviceInfo.features.pipelineStatisticsQuery == VK_TRUE) { if (mDeviceInfo.features.pipelineStatisticsQuery == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::PipelineStatisticsQuery); EnableFeature(Feature::PipelineStatisticsQuery);
} }
// TODO(dawn:1559) Resolving timestamp queries after a render pass is failing on Qualcomm-based // TODO(dawn:1559) Resolving timestamp queries after a render pass is failing on Qualcomm-based
// Android devices. // Android devices.
if (mDeviceInfo.properties.limits.timestampComputeAndGraphics == VK_TRUE && if (mDeviceInfo.properties.limits.timestampComputeAndGraphics == VK_TRUE &&
!IsAndroidQualcomm()) { !IsAndroidQualcomm()) {
mSupportedFeatures.EnableFeature(Feature::TimestampQuery); EnableFeature(Feature::TimestampQuery);
mSupportedFeatures.EnableFeature(Feature::TimestampQueryInsidePasses); EnableFeature(Feature::TimestampQueryInsidePasses);
} }
if (IsDepthStencilFormatSupported(VK_FORMAT_D32_SFLOAT_S8_UINT)) { if (IsDepthStencilFormatSupported(VK_FORMAT_D32_SFLOAT_S8_UINT)) {
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8); EnableFeature(Feature::Depth32FloatStencil8);
} }
if (mDeviceInfo.features.drawIndirectFirstInstance == VK_TRUE) { if (mDeviceInfo.features.drawIndirectFirstInstance == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance); EnableFeature(Feature::IndirectFirstInstance);
} }
if (mDeviceInfo.HasExt(DeviceExt::ShaderFloat16Int8) && if (mDeviceInfo.HasExt(DeviceExt::ShaderFloat16Int8) &&
@ -223,7 +223,7 @@ void Adapter::InitializeSupportedFeaturesImpl() {
mDeviceInfo._16BitStorageFeatures.storageBuffer16BitAccess == VK_TRUE && mDeviceInfo._16BitStorageFeatures.storageBuffer16BitAccess == VK_TRUE &&
mDeviceInfo._16BitStorageFeatures.storageInputOutput16 == VK_TRUE && mDeviceInfo._16BitStorageFeatures.storageInputOutput16 == VK_TRUE &&
mDeviceInfo._16BitStorageFeatures.uniformAndStorageBuffer16BitAccess == VK_TRUE) { mDeviceInfo._16BitStorageFeatures.uniformAndStorageBuffer16BitAccess == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::ShaderF16); EnableFeature(Feature::ShaderF16);
} }
if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct) && if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct) &&
@ -231,14 +231,14 @@ void Adapter::InitializeSupportedFeaturesImpl() {
.integerDotProduct4x8BitPackedSignedAccelerated == VK_TRUE && .integerDotProduct4x8BitPackedSignedAccelerated == VK_TRUE &&
mDeviceInfo.shaderIntegerDotProductProperties mDeviceInfo.shaderIntegerDotProductProperties
.integerDotProduct4x8BitPackedUnsignedAccelerated == VK_TRUE) { .integerDotProduct4x8BitPackedUnsignedAccelerated == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::ChromiumExperimentalDp4a); EnableFeature(Feature::ChromiumExperimentalDp4a);
} }
// unclippedDepth=true translates to depthClipEnable=false, depthClamp=true // unclippedDepth=true translates to depthClipEnable=false, depthClamp=true
if (mDeviceInfo.features.depthClamp == VK_TRUE && if (mDeviceInfo.features.depthClamp == VK_TRUE &&
mDeviceInfo.HasExt(DeviceExt::DepthClipEnable) && mDeviceInfo.HasExt(DeviceExt::DepthClipEnable) &&
mDeviceInfo.depthClipEnableFeatures.depthClipEnable == VK_TRUE) { mDeviceInfo.depthClipEnableFeatures.depthClipEnable == VK_TRUE) {
mSupportedFeatures.EnableFeature(Feature::DepthClipControl); EnableFeature(Feature::DepthClipControl);
} }
VkFormatProperties rg11b10Properties; VkFormatProperties rg11b10Properties;
@ -248,20 +248,20 @@ void Adapter::InitializeSupportedFeaturesImpl() {
if (IsSubset(static_cast<VkFormatFeatureFlags>(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | if (IsSubset(static_cast<VkFormatFeatureFlags>(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT), VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT),
rg11b10Properties.optimalTilingFeatures)) { rg11b10Properties.optimalTilingFeatures)) {
mSupportedFeatures.EnableFeature(Feature::RG11B10UfloatRenderable); EnableFeature(Feature::RG11B10UfloatRenderable);
} }
VkFormatProperties bgra8unormProperties; VkFormatProperties bgra8unormProperties;
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties( mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(
mPhysicalDevice, VK_FORMAT_B8G8R8A8_UNORM, &bgra8unormProperties); mPhysicalDevice, VK_FORMAT_B8G8R8A8_UNORM, &bgra8unormProperties);
if (bgra8unormProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { if (bgra8unormProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) {
mSupportedFeatures.EnableFeature(Feature::BGRA8UnormStorage); EnableFeature(Feature::BGRA8UnormStorage);
} }
#if DAWN_PLATFORM_IS(ANDROID) || DAWN_PLATFORM_IS(CHROMEOS) #if DAWN_PLATFORM_IS(ANDROID) || DAWN_PLATFORM_IS(CHROMEOS)
// TODO(chromium:1258986): Precisely enable the feature by querying the device's format // TODO(chromium:1258986): Precisely enable the feature by querying the device's format
// features. // features.
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats); EnableFeature(Feature::MultiPlanarFormats);
#endif // DAWN_PLATFORM_IS(ANDROID) || DAWN_PLATFORM_IS(CHROMEOS) #endif // DAWN_PLATFORM_IS(ANDROID) || DAWN_PLATFORM_IS(CHROMEOS)
} }
@ -460,9 +460,8 @@ ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor*
return Device::Create(this, descriptor, deviceToggles); return Device::Create(this, descriptor, deviceToggles);
} }
MaybeError Adapter::ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const {
const TogglesState& deviceToggles) {
return {}; return {};
} }

View File

@ -49,9 +49,8 @@ class Adapter : public AdapterBase {
void InitializeSupportedFeaturesImpl() override; void InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override; MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl( MaybeError ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
wgpu::FeatureName feature, const TogglesState& toggles) const override;
const TogglesState& deviceToggles) override;
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor, ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,

View File

@ -64,7 +64,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
// Test that the adapter with unsafe apis disallowed validate features as expected. // Test that the adapter with unsafe apis disallowed validate features as expected.
{ {
mAdapterBase.SetSupportedFeatures(featureNamesWithoutOne); mAdapterBase.SetSupportedFeaturesForTesting(featureNamesWithoutOne);
dawn::native::Adapter adapterWithoutFeature(&mAdapterBase); dawn::native::Adapter adapterWithoutFeature(&mAdapterBase);
wgpu::DeviceDescriptor deviceDescriptor; wgpu::DeviceDescriptor deviceDescriptor;
@ -79,7 +79,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
// Test that the adapter with unsafe apis allowed validate features as expected. // Test that the adapter with unsafe apis allowed validate features as expected.
{ {
mUnsafeAdapterBase.SetSupportedFeatures(featureNamesWithoutOne); mUnsafeAdapterBase.SetSupportedFeaturesForTesting(featureNamesWithoutOne);
dawn::native::Adapter adapterWithoutFeature(&mUnsafeAdapterBase); dawn::native::Adapter adapterWithoutFeature(&mUnsafeAdapterBase);
wgpu::DeviceDescriptor deviceDescriptor; wgpu::DeviceDescriptor deviceDescriptor;