mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 15:24:34 +00:00
Remove memset, fix mismatched size comparison
This commit is contained in:
parent
7271cac30c
commit
c607a65755
@ -907,7 +907,7 @@ bool supports_features(VkPhysicalDeviceFeatures supported,
|
|||||||
if (requested.variableMultisampleRate && !supported.variableMultisampleRate) return false;
|
if (requested.variableMultisampleRate && !supported.variableMultisampleRate) return false;
|
||||||
if (requested.inheritedQueries && !supported.inheritedQueries) return false;
|
if (requested.inheritedQueries && !supported.inheritedQueries) return false;
|
||||||
|
|
||||||
for(auto i = 0; i < extension_requested.size(); ++i) {
|
for(size_t i = 0; i < extension_requested.size(); ++i) {
|
||||||
auto res = GenericFeaturesPNextNode::match(extension_requested[i], extension_supported[i]);
|
auto res = GenericFeaturesPNextNode::match(extension_requested[i], extension_supported[i]);
|
||||||
if(!res) return false;
|
if(!res) return false;
|
||||||
}
|
}
|
||||||
@ -993,8 +993,8 @@ uint32_t get_present_queue_index(VkPhysicalDevice const phys_device,
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|
||||||
PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_device_details(
|
PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_device_details(uint32_t instance_version,
|
||||||
uint32_t instance_version, VkPhysicalDevice phys_device,
|
VkPhysicalDevice phys_device,
|
||||||
std::vector<detail::GenericFeaturesPNextNode> const& src_extended_features_chain) const {
|
std::vector<detail::GenericFeaturesPNextNode> const& src_extended_features_chain) const {
|
||||||
PhysicalDeviceSelector::PhysicalDeviceDesc desc{};
|
PhysicalDeviceSelector::PhysicalDeviceDesc desc{};
|
||||||
desc.phys_device = phys_device;
|
desc.phys_device = phys_device;
|
||||||
@ -1026,7 +1026,6 @@ PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_devi
|
|||||||
local_features.pNext = &fill_chain.front();
|
local_features.pNext = &fill_chain.front();
|
||||||
|
|
||||||
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2(phys_device, &local_features);
|
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2(phys_device, &local_features);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.extended_features_chain = fill_chain;
|
desc.extended_features_chain = fill_chain;
|
||||||
@ -1099,8 +1098,8 @@ PhysicalDeviceSelector::Suitable PhysicalDeviceSelector::is_device_suitable(Phys
|
|||||||
return Suitable::no;
|
return Suitable::no;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool required_features_supported = detail::supports_features(pd.device_features, criteria.required_features,
|
bool required_features_supported = detail::supports_features(
|
||||||
pd.extended_features_chain, criteria.extended_features_chain);
|
pd.device_features, criteria.required_features, pd.extended_features_chain, criteria.extended_features_chain);
|
||||||
if (!required_features_supported) return Suitable::no;
|
if (!required_features_supported) return Suitable::no;
|
||||||
|
|
||||||
bool has_required_memory = false;
|
bool has_required_memory = false;
|
||||||
@ -1151,9 +1150,8 @@ detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
|
|||||||
|
|
||||||
std::vector<PhysicalDeviceDesc> phys_device_descriptions;
|
std::vector<PhysicalDeviceDesc> phys_device_descriptions;
|
||||||
for (auto& phys_device : physical_devices) {
|
for (auto& phys_device : physical_devices) {
|
||||||
phys_device_descriptions.push_back(populate_device_details(instance_info.version,
|
phys_device_descriptions.push_back(populate_device_details(
|
||||||
phys_device,
|
instance_info.version, phys_device, criteria.extended_features_chain));
|
||||||
criteria.extended_features_chain));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalDeviceDesc selected_device{};
|
PhysicalDeviceDesc selected_device{};
|
||||||
@ -1440,7 +1438,8 @@ detail::Result<Device> DeviceBuilder::build() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("User provided VkPhysicalDeviceFeatures2 instance found in pNext chain. All requirements added via 'add_required_extension_features' will be ignored.");
|
printf("User provided VkPhysicalDeviceFeatures2 instance found in pNext chain. All "
|
||||||
|
"requirements added via 'add_required_extension_features' will be ignored.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user_defined_phys_dev_features_2 && !has_phys_dev_features_2) {
|
if (!user_defined_phys_dev_features_2 && !has_phys_dev_features_2) {
|
||||||
|
@ -117,9 +117,10 @@ template <typename T> class Result {
|
|||||||
|
|
||||||
struct GenericFeaturesPNextNode {
|
struct GenericFeaturesPNextNode {
|
||||||
|
|
||||||
GenericFeaturesPNextNode() : sType(static_cast<VkStructureType>(0)),
|
GenericFeaturesPNextNode() : sType(static_cast<VkStructureType>(0)), pNext(nullptr) {
|
||||||
pNext(nullptr) {
|
for (auto& field : fields) {
|
||||||
memset(fields, 0, sizeof(fields));
|
field = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkStructureType sType = static_cast<VkStructureType>(0);
|
VkStructureType sType = static_cast<VkStructureType>(0);
|
||||||
@ -127,20 +128,15 @@ struct GenericFeaturesPNextNode {
|
|||||||
static const uint32_t field_capacity = 256;
|
static const uint32_t field_capacity = 256;
|
||||||
VkBool32 fields[field_capacity];
|
VkBool32 fields[field_capacity];
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void set(T const& features) { *reinterpret_cast<T*>(this) = features; }
|
||||||
void set(T const& features) {
|
|
||||||
*reinterpret_cast<T*>(this) = features;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) {
|
static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) {
|
||||||
assert(requested.sType == supported.sType &&
|
assert(requested.sType == supported.sType && "Non-matching sTypes in features nodes!");
|
||||||
"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;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@ -449,10 +445,12 @@ class PhysicalDeviceSelector {
|
|||||||
#if defined(VK_API_VERSION_1_1)
|
#if defined(VK_API_VERSION_1_1)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PhysicalDeviceSelector& add_required_extension_features(T const& features) {
|
PhysicalDeviceSelector& add_required_extension_features(T const& features) {
|
||||||
assert(features.sType != 0 &&
|
assert(features.sType != 0 && "Features struct sType must be filled with the struct's "
|
||||||
"Features struct sType must be filled with the struct's corresponding VkStructureType enum");
|
"corresponding VkStructureType enum");
|
||||||
assert(features.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
|
assert(
|
||||||
"Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An instance of this is managed internally for selection criteria and device creation.");
|
features.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
|
||||||
|
"Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An "
|
||||||
|
"instance of this is managed internally for selection criteria and device creation.");
|
||||||
detail::GenericFeaturesPNextNode node;
|
detail::GenericFeaturesPNextNode node;
|
||||||
node.set(features);
|
node.set(features);
|
||||||
criteria.extended_features_chain.push_back(node);
|
criteria.extended_features_chain.push_back(node);
|
||||||
@ -499,8 +497,8 @@ class PhysicalDeviceSelector {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// We copy the extension features stored in the selector criteria under the prose of a "template" to
|
// We copy the extension features stored in the selector criteria under the prose of a
|
||||||
// ensure that after fetching everything is compared 1:1 during a match.
|
// "template" to ensure that after fetching everything is compared 1:1 during a match.
|
||||||
|
|
||||||
PhysicalDeviceDesc populate_device_details(uint32_t instance_version,
|
PhysicalDeviceDesc populate_device_details(uint32_t instance_version,
|
||||||
VkPhysicalDevice phys_device,
|
VkPhysicalDevice phys_device,
|
||||||
|
Loading…
Reference in New Issue
Block a user