use std::{any::Any, fmt};
use crate::{
device,
format,
image,
memory,
queue::{QueueGroup, QueuePriority},
Backend,
Features,
Hints,
Limits,
};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MemoryType {
pub properties: memory::Properties,
pub heap_index: usize,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MemoryProperties {
pub memory_types: Vec<MemoryType>,
pub memory_heaps: Vec<u64>,
}
#[derive(Debug)]
pub struct Gpu<B: Backend> {
pub device: B::Device,
pub queue_groups: Vec<QueueGroup<B>>,
}
pub trait PhysicalDevice<B: Backend>: fmt::Debug + Any + Send + Sync {
unsafe fn open(
&self,
families: &[(&B::QueueFamily, &[QueuePriority])],
requested_features: Features,
) -> Result<Gpu<B>, device::CreationError>;
fn format_properties(&self, format: Option<format::Format>) -> format::Properties;
fn image_format_properties(
&self,
format: format::Format,
dimensions: u8,
tiling: image::Tiling,
usage: image::Usage,
view_caps: image::ViewCapabilities,
) -> Option<image::FormatProperties>;
fn memory_properties(&self) -> MemoryProperties;
fn features(&self) -> Features;
fn hints(&self) -> Hints;
fn limits(&self) -> Limits;
fn is_valid_cache(&self, _cache: &[u8]) -> bool {
false
}
}
#[derive(Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum DeviceType {
Other = 0,
IntegratedGpu = 1,
DiscreteGpu = 2,
VirtualGpu = 3,
Cpu = 4,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AdapterInfo {
pub name: String,
pub vendor: usize,
pub device: usize,
pub device_type: DeviceType,
}
#[derive(Debug)]
pub struct Adapter<B: Backend> {
pub info: AdapterInfo,
pub physical_device: B::PhysicalDevice,
pub queue_families: Vec<B::QueueFamily>,
}