Added noexcept and NDEBUG guard.

This commit is contained in:
Cody Goodson 2021-06-15 13:38:21 -05:00 committed by Charles Giessen
parent c66158e87c
commit c05a277572
2 changed files with 5 additions and 3 deletions

View File

@ -40,7 +40,7 @@ GenericFeaturesPNextNode::GenericFeaturesPNextNode()
: fields() {} // zero initializes the array of fields : fields() {} // zero initializes the array of fields
bool GenericFeaturesPNextNode::match( bool GenericFeaturesPNextNode::match(
GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) { GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) noexcept {
assert(requested.sType == supported.sType && "Non-matching sTypes in features nodes!"); assert(requested.sType == supported.sType && "Non-matching sTypes in features nodes!");
for (uint32_t i = 0; i < field_capacity; i++) { for (uint32_t i = 0; i < field_capacity; i++) {
if (requested.fields[i] && !supported.fields[i]) return false; if (requested.fields[i] && !supported.fields[i]) return false;
@ -1138,6 +1138,7 @@ PhysicalDeviceSelector::PhysicalDeviceSelector(Instance const& instance) {
detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const { detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
#if !defined(NDEBUG)
// Validation // Validation
for(const auto& node : criteria.extended_features_chain) { for(const auto& node : criteria.extended_features_chain) {
assert(node.sType != 0 && "Features struct sType must be filled with the struct's " assert(node.sType != 0 && "Features struct sType must be filled with the struct's "
@ -1147,6 +1148,7 @@ detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
"Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An " "Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An "
"instance of this is managed internally for selection criteria and device creation."); "instance of this is managed internally for selection criteria and device creation.");
} }
#endif
if (!instance_info.headless && !criteria.defer_surface_initialization) { if (!instance_info.headless && !criteria.defer_surface_initialization) {
if (instance_info.surface == VK_NULL_HANDLE) if (instance_info.surface == VK_NULL_HANDLE)

View File

@ -122,11 +122,11 @@ struct GenericFeaturesPNextNode {
GenericFeaturesPNextNode(); GenericFeaturesPNextNode();
template <typename T> template <typename T>
GenericFeaturesPNextNode(T const& features) { GenericFeaturesPNextNode(T const& features) noexcept {
*reinterpret_cast<T*>(this) = features; *reinterpret_cast<T*>(this) = features;
} }
static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported); static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) noexcept;
VkStructureType sType = static_cast<VkStructureType>(0); VkStructureType sType = static_cast<VkStructureType>(0);
void* pNext = nullptr; void* pNext = nullptr;