mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 07: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.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]);
|
||||
if(!res) return false;
|
||||
}
|
||||
@ -993,8 +993,8 @@ uint32_t get_present_queue_index(VkPhysicalDevice const phys_device,
|
||||
} // namespace detail
|
||||
|
||||
|
||||
PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_device_details(
|
||||
uint32_t instance_version, VkPhysicalDevice phys_device,
|
||||
PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_device_details(uint32_t instance_version,
|
||||
VkPhysicalDevice phys_device,
|
||||
std::vector<detail::GenericFeaturesPNextNode> const& src_extended_features_chain) const {
|
||||
PhysicalDeviceSelector::PhysicalDeviceDesc desc{};
|
||||
desc.phys_device = phys_device;
|
||||
@ -1026,7 +1026,6 @@ PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_devi
|
||||
local_features.pNext = &fill_chain.front();
|
||||
|
||||
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2(phys_device, &local_features);
|
||||
|
||||
}
|
||||
|
||||
desc.extended_features_chain = fill_chain;
|
||||
@ -1099,8 +1098,8 @@ PhysicalDeviceSelector::Suitable PhysicalDeviceSelector::is_device_suitable(Phys
|
||||
return Suitable::no;
|
||||
}
|
||||
|
||||
bool required_features_supported = detail::supports_features(pd.device_features, criteria.required_features,
|
||||
pd.extended_features_chain, criteria.extended_features_chain);
|
||||
bool required_features_supported = detail::supports_features(
|
||||
pd.device_features, criteria.required_features, pd.extended_features_chain, criteria.extended_features_chain);
|
||||
if (!required_features_supported) return Suitable::no;
|
||||
|
||||
bool has_required_memory = false;
|
||||
@ -1151,9 +1150,8 @@ detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
|
||||
|
||||
std::vector<PhysicalDeviceDesc> phys_device_descriptions;
|
||||
for (auto& phys_device : physical_devices) {
|
||||
phys_device_descriptions.push_back(populate_device_details(instance_info.version,
|
||||
phys_device,
|
||||
criteria.extended_features_chain));
|
||||
phys_device_descriptions.push_back(populate_device_details(
|
||||
instance_info.version, phys_device, criteria.extended_features_chain));
|
||||
}
|
||||
|
||||
PhysicalDeviceDesc selected_device{};
|
||||
@ -1440,7 +1438,8 @@ detail::Result<Device> DeviceBuilder::build() const {
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
|
@ -117,9 +117,10 @@ template <typename T> class Result {
|
||||
|
||||
struct GenericFeaturesPNextNode {
|
||||
|
||||
GenericFeaturesPNextNode() : sType(static_cast<VkStructureType>(0)),
|
||||
pNext(nullptr) {
|
||||
memset(fields, 0, sizeof(fields));
|
||||
GenericFeaturesPNextNode() : sType(static_cast<VkStructureType>(0)), pNext(nullptr) {
|
||||
for (auto& field : fields) {
|
||||
field = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VkStructureType sType = static_cast<VkStructureType>(0);
|
||||
@ -127,20 +128,15 @@ struct GenericFeaturesPNextNode {
|
||||
static const uint32_t field_capacity = 256;
|
||||
VkBool32 fields[field_capacity];
|
||||
|
||||
template <typename T>
|
||||
void set(T const& features) {
|
||||
*reinterpret_cast<T*>(this) = features;
|
||||
}
|
||||
template <typename T> void set(T const& features) { *reinterpret_cast<T*>(this) = features; }
|
||||
|
||||
static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) {
|
||||
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++) {
|
||||
if (requested.fields[i] && !supported.fields[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@ -449,10 +445,12 @@ class PhysicalDeviceSelector {
|
||||
#if defined(VK_API_VERSION_1_1)
|
||||
template <typename T>
|
||||
PhysicalDeviceSelector& add_required_extension_features(T const& features) {
|
||||
assert(features.sType != 0 &&
|
||||
"Features struct sType must be filled with the struct's corresponding VkStructureType enum");
|
||||
assert(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.");
|
||||
assert(features.sType != 0 && "Features struct sType must be filled with the struct's "
|
||||
"corresponding VkStructureType enum");
|
||||
assert(
|
||||
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;
|
||||
node.set(features);
|
||||
criteria.extended_features_chain.push_back(node);
|
||||
@ -499,8 +497,8 @@ class PhysicalDeviceSelector {
|
||||
#endif
|
||||
};
|
||||
|
||||
// We copy the extension features stored in the selector criteria under the prose of a "template" to
|
||||
// ensure that after fetching everything is compared 1:1 during a match.
|
||||
// We copy the extension features stored in the selector criteria under the prose of a
|
||||
// "template" to ensure that after fetching everything is compared 1:1 during a match.
|
||||
|
||||
PhysicalDeviceDesc populate_device_details(uint32_t instance_version,
|
||||
VkPhysicalDevice phys_device,
|
||||
|
Loading…
Reference in New Issue
Block a user