mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 23:24:34 +00:00
Renamed allow_fallback_gpu_type to allow_any_type and refactored implementation to be simpler
This commit is contained in:
parent
8a18c5a7ba
commit
6043129631
@ -674,13 +674,8 @@ PhysicalDeviceSelector::Suitable PhysicalDeviceSelector::is_device_suitable (Phy
|
|||||||
}
|
}
|
||||||
if (criteria.require_present && !swapChainAdequate) suitable = Suitable::no;
|
if (criteria.require_present && !swapChainAdequate) suitable = Suitable::no;
|
||||||
|
|
||||||
if ((criteria.preferred_type == PreferredDeviceType::discrete &&
|
if (pd.device_properties.deviceType != static_cast<VkPhysicalDeviceType> (criteria.preferred_type)) {
|
||||||
pd.device_properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) ||
|
if (criteria.allow_any_type)
|
||||||
(criteria.preferred_type == PreferredDeviceType::integrated &&
|
|
||||||
pd.device_properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) ||
|
|
||||||
(criteria.preferred_type == PreferredDeviceType::virtual_gpu &&
|
|
||||||
pd.device_properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU)) {
|
|
||||||
if (criteria.allow_fallback)
|
|
||||||
suitable = Suitable::partial;
|
suitable = Suitable::partial;
|
||||||
else
|
else
|
||||||
suitable = Suitable::no;
|
suitable = Suitable::no;
|
||||||
@ -778,8 +773,8 @@ PhysicalDeviceSelector& PhysicalDeviceSelector::prefer_gpu_device_type (Preferre
|
|||||||
criteria.preferred_type = type;
|
criteria.preferred_type = type;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PhysicalDeviceSelector& PhysicalDeviceSelector::allow_fallback_gpu_type (bool fallback) {
|
PhysicalDeviceSelector& PhysicalDeviceSelector::allow_any_gpu_device_type (bool allow_any_type) {
|
||||||
criteria.allow_fallback = fallback;
|
criteria.allow_any_type = allow_any_type;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PhysicalDeviceSelector& PhysicalDeviceSelector::require_present (bool require) {
|
PhysicalDeviceSelector& PhysicalDeviceSelector::require_present (bool require) {
|
||||||
|
@ -280,7 +280,14 @@ struct PhysicalDevice {
|
|||||||
friend class DeviceBuilder;
|
friend class DeviceBuilder;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PreferredDeviceType { discrete, integrated, virtual_gpu, cpu, dont_care };
|
enum class PreferredDeviceType {
|
||||||
|
other = 0,
|
||||||
|
integrated = 1,
|
||||||
|
discrete = 2,
|
||||||
|
virtual_gpu = 3,
|
||||||
|
cpu = 4
|
||||||
|
};
|
||||||
|
|
||||||
class PhysicalDeviceSelector {
|
class PhysicalDeviceSelector {
|
||||||
public:
|
public:
|
||||||
// Requires a vkb::Instance to construct, needed to pass instance creation info.
|
// Requires a vkb::Instance to construct, needed to pass instance creation info.
|
||||||
@ -292,8 +299,8 @@ class PhysicalDeviceSelector {
|
|||||||
PhysicalDeviceSelector& set_surface (VkSurfaceKHR instance);
|
PhysicalDeviceSelector& set_surface (VkSurfaceKHR instance);
|
||||||
// Set the desired physical device type to select. Defaults to PreferredDeviceType::discrete.
|
// Set the desired physical device type to select. Defaults to PreferredDeviceType::discrete.
|
||||||
PhysicalDeviceSelector& prefer_gpu_device_type (PreferredDeviceType type = PreferredDeviceType::discrete);
|
PhysicalDeviceSelector& prefer_gpu_device_type (PreferredDeviceType type = PreferredDeviceType::discrete);
|
||||||
// Allow fallback to a device type that isn't the preferred physical device type. Defaults to true.
|
// Allow selection of a gpu device type that isn't the preferred physical device type. Defaults to true.
|
||||||
PhysicalDeviceSelector& allow_fallback_gpu_type (bool fallback = true);
|
PhysicalDeviceSelector& allow_any_gpu_device_type (bool allow_any_type = true);
|
||||||
|
|
||||||
// Require that a physical device supports presentation. Defaults to true.
|
// Require that a physical device supports presentation. Defaults to true.
|
||||||
PhysicalDeviceSelector& require_present (bool require = true);
|
PhysicalDeviceSelector& require_present (bool require = true);
|
||||||
@ -352,7 +359,7 @@ class PhysicalDeviceSelector {
|
|||||||
|
|
||||||
struct SelectionCriteria {
|
struct SelectionCriteria {
|
||||||
PreferredDeviceType preferred_type = PreferredDeviceType::discrete;
|
PreferredDeviceType preferred_type = PreferredDeviceType::discrete;
|
||||||
bool allow_fallback = true;
|
bool allow_any_type = true;
|
||||||
bool require_present = true;
|
bool require_present = true;
|
||||||
bool require_dedicated_transfer_queue = false;
|
bool require_dedicated_transfer_queue = false;
|
||||||
bool require_dedicated_compute_queue = false;
|
bool require_dedicated_compute_queue = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user