From cb84c798dd0f19a70adb1c366f89c588077092b3 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 6 Apr 2020 08:32:01 +0000 Subject: [PATCH] Change the TogglesSet API to look like a set<> Bug: dawn:373 Change-Id: Id1c7e4f03364a0975ea4965eaaf7d71c34db6b4c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18760 Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya Commit-Queue: Corentin Wallez --- src/dawn_native/Device.cpp | 14 +++++++------- src/dawn_native/Device.h | 2 +- src/dawn_native/Toggles.cpp | 6 +++--- src/dawn_native/Toggles.h | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index fa3cd9b7a5..3834d1d24b 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -661,13 +661,13 @@ namespace dawn_native { for (const char* toggleName : deviceDescriptor->forceEnabledToggles) { Toggle toggle = GetAdapter()->GetInstance()->ToggleNameToEnum(toggleName); if (toggle != Toggle::InvalidEnum) { - mTogglesSet.SetToggle(toggle, true); + mEnabledToggles.Set(toggle, true); } } for (const char* toggleName : deviceDescriptor->forceDisabledToggles) { Toggle toggle = GetAdapter()->GetInstance()->ToggleNameToEnum(toggleName); if (toggle != Toggle::InvalidEnum) { - mTogglesSet.SetToggle(toggle, false); + mEnabledToggles.Set(toggle, false); } } } @@ -685,7 +685,7 @@ namespace dawn_native { } std::vector DeviceBase::GetTogglesUsed() const { - return mTogglesSet.GetEnabledToggleNames(); + return mEnabledToggles.GetContainedToggleNames(); } bool DeviceBase::IsExtensionEnabled(Extension extension) const { @@ -693,7 +693,7 @@ namespace dawn_native { } bool DeviceBase::IsToggleEnabled(Toggle toggle) const { - return mTogglesSet.IsEnabled(toggle); + return mEnabledToggles.Has(toggle); } bool DeviceBase::IsValidationEnabled() const { @@ -710,8 +710,8 @@ namespace dawn_native { void DeviceBase::SetDefaultToggles() { // Sets the default-enabled toggles - mTogglesSet.SetToggle(Toggle::LazyClearResourceOnFirstUse, true); - mTogglesSet.SetToggle(Toggle::UseSpvc, false); + mEnabledToggles.Set(Toggle::LazyClearResourceOnFirstUse, true); + mEnabledToggles.Set(Toggle::UseSpvc, false); } // Implementation details of object creation @@ -913,7 +913,7 @@ namespace dawn_native { } void DeviceBase::SetToggle(Toggle toggle, bool isEnabled) { - mTogglesSet.SetToggle(toggle, isEnabled); + mEnabledToggles.Set(toggle, isEnabled); } } // namespace dawn_native diff --git a/src/dawn_native/Device.h b/src/dawn_native/Device.h index e967f3e076..93704b0fdc 100644 --- a/src/dawn_native/Device.h +++ b/src/dawn_native/Device.h @@ -308,7 +308,7 @@ namespace dawn_native { FormatTable mFormatTable; - TogglesSet mTogglesSet; + TogglesSet mEnabledToggles; size_t mLazyClearCountForTesting = 0; ExtensionsSet mEnabledExtensions; diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp index 225918c26f..8c3a130b07 100644 --- a/src/dawn_native/Toggles.cpp +++ b/src/dawn_native/Toggles.cpp @@ -127,19 +127,19 @@ namespace dawn_native { } // anonymous namespace - void TogglesSet::SetToggle(Toggle toggle, bool enabled) { + void TogglesSet::Set(Toggle toggle, bool enabled) { ASSERT(toggle != Toggle::InvalidEnum); const size_t toggleIndex = static_cast(toggle); toggleBitset.set(toggleIndex, enabled); } - bool TogglesSet::IsEnabled(Toggle toggle) const { + bool TogglesSet::Has(Toggle toggle) const { ASSERT(toggle != Toggle::InvalidEnum); const size_t toggleIndex = static_cast(toggle); return toggleBitset.test(toggleIndex); } - std::vector TogglesSet::GetEnabledToggleNames() const { + std::vector TogglesSet::GetContainedToggleNames() const { std::vector togglesNameInUse(toggleBitset.count()); uint32_t index = 0; diff --git a/src/dawn_native/Toggles.h b/src/dawn_native/Toggles.h index 3cc40ecb28..93a31d2e9d 100644 --- a/src/dawn_native/Toggles.h +++ b/src/dawn_native/Toggles.h @@ -46,14 +46,14 @@ namespace dawn_native { InvalidEnum = EnumCount, }; - // A wrapper of the bitset to store if a toggle is enabled or not. This wrapper provides the + // A wrapper of the bitset to store if a toggle is present or not. This wrapper provides the // convenience to convert the enums of enum class Toggle to the indices of a bitset. struct TogglesSet { std::bitset(Toggle::EnumCount)> toggleBitset; - void SetToggle(Toggle toggle, bool enabled); - bool IsEnabled(Toggle toggle) const; - std::vector GetEnabledToggleNames() const; + void Set(Toggle toggle, bool enabled); + bool Has(Toggle toggle) const; + std::vector GetContainedToggleNames() const; }; const char* ToggleEnumToName(Toggle toggle);