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 <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
c7f454c241
commit
cb84c798dd
|
@ -661,13 +661,13 @@ namespace dawn_native {
|
||||||
for (const char* toggleName : deviceDescriptor->forceEnabledToggles) {
|
for (const char* toggleName : deviceDescriptor->forceEnabledToggles) {
|
||||||
Toggle toggle = GetAdapter()->GetInstance()->ToggleNameToEnum(toggleName);
|
Toggle toggle = GetAdapter()->GetInstance()->ToggleNameToEnum(toggleName);
|
||||||
if (toggle != Toggle::InvalidEnum) {
|
if (toggle != Toggle::InvalidEnum) {
|
||||||
mTogglesSet.SetToggle(toggle, true);
|
mEnabledToggles.Set(toggle, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const char* toggleName : deviceDescriptor->forceDisabledToggles) {
|
for (const char* toggleName : deviceDescriptor->forceDisabledToggles) {
|
||||||
Toggle toggle = GetAdapter()->GetInstance()->ToggleNameToEnum(toggleName);
|
Toggle toggle = GetAdapter()->GetInstance()->ToggleNameToEnum(toggleName);
|
||||||
if (toggle != Toggle::InvalidEnum) {
|
if (toggle != Toggle::InvalidEnum) {
|
||||||
mTogglesSet.SetToggle(toggle, false);
|
mEnabledToggles.Set(toggle, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -685,7 +685,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char*> DeviceBase::GetTogglesUsed() const {
|
std::vector<const char*> DeviceBase::GetTogglesUsed() const {
|
||||||
return mTogglesSet.GetEnabledToggleNames();
|
return mEnabledToggles.GetContainedToggleNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceBase::IsExtensionEnabled(Extension extension) const {
|
bool DeviceBase::IsExtensionEnabled(Extension extension) const {
|
||||||
|
@ -693,7 +693,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceBase::IsToggleEnabled(Toggle toggle) const {
|
bool DeviceBase::IsToggleEnabled(Toggle toggle) const {
|
||||||
return mTogglesSet.IsEnabled(toggle);
|
return mEnabledToggles.Has(toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceBase::IsValidationEnabled() const {
|
bool DeviceBase::IsValidationEnabled() const {
|
||||||
|
@ -710,8 +710,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
void DeviceBase::SetDefaultToggles() {
|
void DeviceBase::SetDefaultToggles() {
|
||||||
// Sets the default-enabled toggles
|
// Sets the default-enabled toggles
|
||||||
mTogglesSet.SetToggle(Toggle::LazyClearResourceOnFirstUse, true);
|
mEnabledToggles.Set(Toggle::LazyClearResourceOnFirstUse, true);
|
||||||
mTogglesSet.SetToggle(Toggle::UseSpvc, false);
|
mEnabledToggles.Set(Toggle::UseSpvc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation details of object creation
|
// Implementation details of object creation
|
||||||
|
@ -913,7 +913,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::SetToggle(Toggle toggle, bool isEnabled) {
|
void DeviceBase::SetToggle(Toggle toggle, bool isEnabled) {
|
||||||
mTogglesSet.SetToggle(toggle, isEnabled);
|
mEnabledToggles.Set(toggle, isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -308,7 +308,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
FormatTable mFormatTable;
|
FormatTable mFormatTable;
|
||||||
|
|
||||||
TogglesSet mTogglesSet;
|
TogglesSet mEnabledToggles;
|
||||||
size_t mLazyClearCountForTesting = 0;
|
size_t mLazyClearCountForTesting = 0;
|
||||||
|
|
||||||
ExtensionsSet mEnabledExtensions;
|
ExtensionsSet mEnabledExtensions;
|
||||||
|
|
|
@ -127,19 +127,19 @@ namespace dawn_native {
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
void TogglesSet::SetToggle(Toggle toggle, bool enabled) {
|
void TogglesSet::Set(Toggle toggle, bool enabled) {
|
||||||
ASSERT(toggle != Toggle::InvalidEnum);
|
ASSERT(toggle != Toggle::InvalidEnum);
|
||||||
const size_t toggleIndex = static_cast<size_t>(toggle);
|
const size_t toggleIndex = static_cast<size_t>(toggle);
|
||||||
toggleBitset.set(toggleIndex, enabled);
|
toggleBitset.set(toggleIndex, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TogglesSet::IsEnabled(Toggle toggle) const {
|
bool TogglesSet::Has(Toggle toggle) const {
|
||||||
ASSERT(toggle != Toggle::InvalidEnum);
|
ASSERT(toggle != Toggle::InvalidEnum);
|
||||||
const size_t toggleIndex = static_cast<size_t>(toggle);
|
const size_t toggleIndex = static_cast<size_t>(toggle);
|
||||||
return toggleBitset.test(toggleIndex);
|
return toggleBitset.test(toggleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char*> TogglesSet::GetEnabledToggleNames() const {
|
std::vector<const char*> TogglesSet::GetContainedToggleNames() const {
|
||||||
std::vector<const char*> togglesNameInUse(toggleBitset.count());
|
std::vector<const char*> togglesNameInUse(toggleBitset.count());
|
||||||
|
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
|
|
|
@ -46,14 +46,14 @@ namespace dawn_native {
|
||||||
InvalidEnum = EnumCount,
|
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.
|
// convenience to convert the enums of enum class Toggle to the indices of a bitset.
|
||||||
struct TogglesSet {
|
struct TogglesSet {
|
||||||
std::bitset<static_cast<size_t>(Toggle::EnumCount)> toggleBitset;
|
std::bitset<static_cast<size_t>(Toggle::EnumCount)> toggleBitset;
|
||||||
|
|
||||||
void SetToggle(Toggle toggle, bool enabled);
|
void Set(Toggle toggle, bool enabled);
|
||||||
bool IsEnabled(Toggle toggle) const;
|
bool Has(Toggle toggle) const;
|
||||||
std::vector<const char*> GetEnabledToggleNames() const;
|
std::vector<const char*> GetContainedToggleNames() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* ToggleEnumToName(Toggle toggle);
|
const char* ToggleEnumToName(Toggle toggle);
|
||||||
|
|
Loading…
Reference in New Issue