mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-10 02:41:47 +00:00
Enable VK_KHR_portability_subset if available
Makes it easy to use vulkan on macOS since vk-bootstrap will auto-enable it if the extension is available. This can be disabled by calling `disable_portability_subset`.
This commit is contained in:
parent
d3170c0657
commit
65071da181
@ -1182,11 +1182,20 @@ detail::Result<std::vector<PhysicalDevice>> PhysicalDeviceSelector::select_impl(
|
|||||||
auto fill_out_phys_dev_with_criteria = [&](PhysicalDevice& phys_dev) {
|
auto fill_out_phys_dev_with_criteria = [&](PhysicalDevice& phys_dev) {
|
||||||
phys_dev.features = criteria.required_features;
|
phys_dev.features = criteria.required_features;
|
||||||
phys_dev.extended_features_chain = criteria.extended_features_chain;
|
phys_dev.extended_features_chain = criteria.extended_features_chain;
|
||||||
|
bool portability_ext_available = false;
|
||||||
|
for (const auto& ext : phys_dev.extensions)
|
||||||
|
if (criteria.enable_portability_subset && ext == "VK_KHR_portability_subset")
|
||||||
|
portability_ext_available = true;
|
||||||
|
|
||||||
|
phys_dev.extensions.clear();
|
||||||
phys_dev.extensions.insert(
|
phys_dev.extensions.insert(
|
||||||
phys_dev.extensions.end(), criteria.required_extensions.begin(), criteria.required_extensions.end());
|
phys_dev.extensions.end(), criteria.required_extensions.begin(), criteria.required_extensions.end());
|
||||||
auto desired_extensions_supported = detail::check_device_extension_support(phys_dev.extensions, criteria.desired_extensions);
|
auto desired_extensions_supported = detail::check_device_extension_support(phys_dev.extensions, criteria.desired_extensions);
|
||||||
phys_dev.extensions.insert(
|
phys_dev.extensions.insert(
|
||||||
phys_dev.extensions.end(), desired_extensions_supported.begin(), desired_extensions_supported.end());
|
phys_dev.extensions.end(), desired_extensions_supported.begin(), desired_extensions_supported.end());
|
||||||
|
if (portability_ext_available) {
|
||||||
|
phys_dev.extensions.push_back("VK_KHR_portability_subset");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// if this option is set, always return only the first physical device found
|
// if this option is set, always return only the first physical device found
|
||||||
@ -1216,6 +1225,11 @@ detail::Result<std::vector<PhysicalDevice>> PhysicalDeviceSelector::select_impl(
|
|||||||
physical_devices.erase(partition_index, physical_devices.end() - 1);
|
physical_devices.erase(partition_index, physical_devices.end() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make the physical device ready to be used to create a Device from it
|
||||||
|
for (auto& physical_device : physical_devices) {
|
||||||
|
fill_out_phys_dev_with_criteria(physical_device);
|
||||||
|
}
|
||||||
|
|
||||||
return physical_devices;
|
return physical_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1324,6 +1338,11 @@ PhysicalDeviceSelector& PhysicalDeviceSelector::set_desired_version(uint32_t maj
|
|||||||
criteria.desired_version = VKB_MAKE_VK_VERSION(0, major, minor, 0);
|
criteria.desired_version = VKB_MAKE_VK_VERSION(0, major, minor, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
PhysicalDeviceSelector& PhysicalDeviceSelector::disable_portability_subset() {
|
||||||
|
criteria.enable_portability_subset = false;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
PhysicalDeviceSelector& PhysicalDeviceSelector::set_required_features(VkPhysicalDeviceFeatures const& features) {
|
PhysicalDeviceSelector& PhysicalDeviceSelector::set_required_features(VkPhysicalDeviceFeatures const& features) {
|
||||||
criteria.required_features = features;
|
criteria.required_features = features;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -580,6 +580,10 @@ class PhysicalDeviceSelector {
|
|||||||
// Require a physical device that supports a (major, minor) version of vulkan.
|
// Require a physical device that supports a (major, minor) version of vulkan.
|
||||||
PhysicalDeviceSelector& set_minimum_version(uint32_t major, uint32_t minor);
|
PhysicalDeviceSelector& set_minimum_version(uint32_t major, uint32_t minor);
|
||||||
|
|
||||||
|
// By default PhysicalDeviceSelector enables the portability subset if available
|
||||||
|
// This function disables that behavior
|
||||||
|
PhysicalDeviceSelector& disable_portability_subset();
|
||||||
|
|
||||||
// Require a physical device which supports a specific set of general/extension features.
|
// Require a physical device which supports a specific set of general/extension features.
|
||||||
#if defined(VKB_VK_API_VERSION_1_1)
|
#if defined(VKB_VK_API_VERSION_1_1)
|
||||||
template <typename T> PhysicalDeviceSelector& add_required_extension_features(T const& features) {
|
template <typename T> PhysicalDeviceSelector& add_required_extension_features(T const& features) {
|
||||||
@ -648,6 +652,7 @@ class PhysicalDeviceSelector {
|
|||||||
#endif
|
#endif
|
||||||
bool defer_surface_initialization = false;
|
bool defer_surface_initialization = false;
|
||||||
bool use_first_gpu_unconditionally = false;
|
bool use_first_gpu_unconditionally = false;
|
||||||
|
bool enable_portability_subset = true;
|
||||||
} criteria;
|
} criteria;
|
||||||
|
|
||||||
PhysicalDevice populate_device_details(VkPhysicalDevice phys_device,
|
PhysicalDevice populate_device_details(VkPhysicalDevice phys_device,
|
||||||
|
Loading…
Reference in New Issue
Block a user