/// Tells us if this device is compatible with Sarekt.
/// This means it has what is needed by this configuration in terms of:
/// * Supported Queue Families (Graphics, Presentation if drawing to a window)
/// * Required Extensions (swapchain creation when drawing to a window)
/// * Swapchain support for the physical device (when drawing to a window).
///
/// This will become more complex as more features are added.
///
/// Certain features can be behind cargo feature flags that also affect this
/// function.
Tells us if this device is compatible with Sarekt.
This means it has what is needed by this configuration in terms of:
Supported Queue Families (Graphics, Presentation if drawing to a window)
Required Extensions (swapchain creation when drawing to a window)
Swapchain support for the physical device (when drawing to a window).

This will become more complex as more features are added.

Certain features can be behind cargo feature flags that also affect this
function.
Tells us if this device is compatible with Sarekt . This means it has what is needed by this configuration in terms of : Supported Queue Families ( Graphics Presentation if drawing to a window ) Required Extensions ( swapchain creation when drawing to a window ) Swapchain support for the physical device ( when drawing to a window ) . This will become more complex as more features are added . Certain features can be behind cargo feature flags that also affect this function .
fn is_device_suitable(
    instance: &Instance, physical_device: vk::PhysicalDevice,
    surface_and_extension: &SurfaceAndExtension,
  ) -> SarektResult<bool> {
    let has_needed_features = unsafe {
      instance
        .get_physical_device_features(physical_device)
        .sampler_anisotropy
        == vk::TRUE
    };
    let has_queues = Self::find_queue_families(instance, physical_device, surface_and_extension)
      .map(|qf| qf.is_complete())
      .unwrap_or(false);
    let supports_required_extensions =
      Self::device_supports_required_extensions(instance, physical_device);
    if supports_required_extensions.is_err() {
      warn!(
        "Could not enumerate physical device properties on device {:?}",
        physical_device
      );
      return Ok(false);
    }
    let sc_support_details =
      Self::query_swap_chain_support(surface_and_extension, physical_device)?;
    // TODO(issue#9) OFFSCREEN only if drawing to a window.
    let swap_chain_adequate =
      !sc_support_details.formats.is_empty() && !sc_support_details.present_modes.is_empty();
    // TODO(issue#9) OFFSCREEN only if drawing window need swap chain adequete.
    Ok(
      has_needed_features
        && has_queues
        && supports_required_extensions.unwrap()
        && swap_chain_adequate,
    )
  }
fn is_device_suitable ( instance : & Instance , physical_device : vk :: PhysicalDevice , surface_and_extension : & SurfaceAndExtension , ) -> SarektResult < bool > { let has_needed_features = unsafe { instance . get_physical_device_features ( physical_device ) . sampler_anisotropy == vk :: TRUE } ; let has_queues = Self :: find_queue_families ( instance , physical_device , surface_and_extension ) . map ( | qf | qf . is_complete ( ) ) . unwrap_or ( false ) ; let supports_required_extensions = Self :: device_supports_required_extensions ( instance , physical_device ) ; if supports_required_extensions . is_err ( ) { warn ! ( " " physical_device ) ; return Ok ( false ) ; } let sc_support_details = Self :: query_swap_chain_support ( surface_and_extension , physical_device ) ? ; // TODO(issue#9) OFFSCREEN only if drawing to a window. let swap_chain_adequate = ! sc_support_details . formats . is_empty ( ) && ! sc_support_details . present_modes . is_empty ( ) ; // TODO(issue#9) OFFSCREEN only if drawing window need swap chain adequete. Ok ( has_needed_features && has_queues && supports_required_extensions . unwrap ( ) && swap_chain_adequate , ) }
Tells us if this device is compatible with Sarekt.
Tells us if this device is compatible with Sarekt .
instance
&Instance
physical_device
vk::PhysicalDevice
surface_and_extension
&SurfaceAndExtension