mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 06:45:23 +00:00
add some logic for known properties (#1654)
* add some logic for known properties * update examples * fix tests * fix indentation
This commit is contained in:
parent
00b6340715
commit
0bf8c86eea
@ -44,7 +44,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -55,8 +55,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
// Now initializing the device.
|
||||
|
@ -69,7 +69,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -80,8 +80,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -126,7 +126,7 @@ fn main() {
|
||||
.expect("couldn't find a queue family"),
|
||||
)
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
|
@ -70,7 +70,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -81,8 +81,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -46,7 +46,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -57,8 +57,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
@ -159,8 +159,7 @@ fn main() {
|
||||
let min_dynamic_align = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_uniform_buffer_offset_alignment
|
||||
.unwrap() as usize;
|
||||
.min_uniform_buffer_offset_alignment as usize;
|
||||
println!(
|
||||
"Minimum uniform buffer offset alignment: {}",
|
||||
min_dynamic_align
|
||||
|
@ -57,7 +57,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -68,8 +68,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -60,7 +60,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -71,8 +71,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap(),
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type,
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -39,7 +39,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -50,8 +50,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -85,7 +85,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -96,8 +96,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap(),
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type,
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -82,7 +82,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -93,8 +93,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap(),
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type,
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -104,7 +104,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -115,8 +115,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -81,7 +81,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -92,8 +92,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -84,7 +84,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -97,8 +97,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -55,7 +55,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -66,8 +66,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap(),
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type,
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -55,7 +55,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -66,8 +66,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
// Now initializing the device.
|
||||
|
@ -35,7 +35,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -46,8 +46,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -80,7 +80,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -91,8 +91,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -36,7 +36,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -47,8 +47,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -35,7 +35,7 @@ fn main() {
|
||||
.find(|&q| q.supports_compute())
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -46,8 +46,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -62,7 +62,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -73,8 +73,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap(),
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type,
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -162,7 +162,7 @@ fn main() {
|
||||
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))
|
||||
.map(|q| (p, q))
|
||||
})
|
||||
.min_by_key(|(p, _)| match p.properties().device_type.unwrap() {
|
||||
.min_by_key(|(p, _)| match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -173,8 +173,8 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap()
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type
|
||||
);
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
|
@ -119,7 +119,7 @@ fn main() {
|
||||
// "default" or "recommended" device, and let the user choose the device themselves.
|
||||
.min_by_key(|(p, _)| {
|
||||
// We assign a better score to device types that are likely to be faster/better.
|
||||
match p.properties().device_type.unwrap() {
|
||||
match p.properties().device_type {
|
||||
PhysicalDeviceType::DiscreteGpu => 0,
|
||||
PhysicalDeviceType::IntegratedGpu => 1,
|
||||
PhysicalDeviceType::VirtualGpu => 2,
|
||||
@ -132,8 +132,8 @@ fn main() {
|
||||
// Some little debug infos.
|
||||
println!(
|
||||
"Using device: {} (type: {:?})",
|
||||
physical_device.properties().device_name.as_ref().unwrap(),
|
||||
physical_device.properties().device_type.unwrap(),
|
||||
physical_device.properties().device_name,
|
||||
physical_device.properties().device_type,
|
||||
);
|
||||
|
||||
// Now initializing the device. This is probably the most important object of Vulkan.
|
||||
|
@ -34,6 +34,7 @@ pub fn write<W: Write>(
|
||||
feat.ffi_members.join(", ")
|
||||
)
|
||||
.unwrap();
|
||||
write!(writer, "\n\t\trequired: {},", feat.required).unwrap();
|
||||
write!(writer, "\n\t}},").unwrap();
|
||||
}
|
||||
|
||||
@ -66,6 +67,7 @@ struct VulkanoProperty {
|
||||
vulkan_doc: String,
|
||||
ffi_name: String,
|
||||
ffi_members: Vec<String>,
|
||||
required: bool,
|
||||
}
|
||||
|
||||
fn make_vulkano_properties(types: &HashMap<&str, (&Type, Vec<&str>)>) -> Vec<VulkanoProperty> {
|
||||
@ -85,6 +87,10 @@ fn make_vulkano_properties(types: &HashMap<&str, (&Type, Vec<&str>)>) -> Vec<Vul
|
||||
})
|
||||
.for_each(|(ty, _)| {
|
||||
let vulkan_ty_name = ty.name.as_ref().unwrap();
|
||||
let required = vulkan_ty_name == "VkPhysicalDeviceProperties"
|
||||
|| vulkan_ty_name == "VkPhysicalDeviceLimits"
|
||||
|| vulkan_ty_name == "VkPhysicalDeviceSparseProperties"
|
||||
;
|
||||
|
||||
let ty_name = if vulkan_ty_name == "VkPhysicalDeviceProperties" {
|
||||
"properties_vulkan10.properties".to_owned()
|
||||
@ -116,6 +122,7 @@ fn make_vulkano_properties(types: &HashMap<&str, (&Type, Vec<&str>)>) -> Vec<Vul
|
||||
vulkan_doc: format!("{}.html#limits-{}", vulkan_ty_name, name),
|
||||
ffi_name: vulkano_member,
|
||||
ffi_members: vec![ty_name.to_owned()],
|
||||
required: required,
|
||||
});
|
||||
}
|
||||
Entry::Occupied(entry) => {
|
||||
|
@ -468,8 +468,7 @@ where
|
||||
self.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_uniform_buffer_offset_alignment
|
||||
.unwrap() as usize
|
||||
.min_uniform_buffer_offset_alignment as usize
|
||||
} else {
|
||||
1
|
||||
},
|
||||
@ -477,8 +476,7 @@ where
|
||||
self.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_storage_buffer_offset_alignment
|
||||
.unwrap() as usize
|
||||
.min_storage_buffer_offset_alignment as usize
|
||||
} else {
|
||||
1
|
||||
},
|
||||
|
@ -220,21 +220,21 @@ impl UnsafeBuffer {
|
||||
if usage.uniform_texel_buffer || usage.storage_texel_buffer {
|
||||
output.alignment = align(
|
||||
output.alignment,
|
||||
properties.min_texel_buffer_offset_alignment.unwrap() as usize,
|
||||
properties.min_texel_buffer_offset_alignment as usize,
|
||||
);
|
||||
}
|
||||
|
||||
if usage.storage_buffer {
|
||||
output.alignment = align(
|
||||
output.alignment,
|
||||
properties.min_storage_buffer_offset_alignment.unwrap() as usize,
|
||||
properties.min_storage_buffer_offset_alignment as usize,
|
||||
);
|
||||
}
|
||||
|
||||
if usage.uniform_buffer {
|
||||
output.alignment = align(
|
||||
output.alignment,
|
||||
properties.min_uniform_buffer_offset_alignment.unwrap() as usize,
|
||||
properties.min_uniform_buffer_offset_alignment as usize,
|
||||
);
|
||||
}
|
||||
|
||||
@ -275,17 +275,17 @@ impl UnsafeBuffer {
|
||||
let properties = self.device().physical_device().properties();
|
||||
if self.usage().uniform_texel_buffer || self.usage().storage_texel_buffer {
|
||||
debug_assert!(
|
||||
offset % properties.min_texel_buffer_offset_alignment.unwrap() as usize == 0
|
||||
offset % properties.min_texel_buffer_offset_alignment as usize == 0
|
||||
);
|
||||
}
|
||||
if self.usage().storage_buffer {
|
||||
debug_assert!(
|
||||
offset % properties.min_storage_buffer_offset_alignment.unwrap() as usize == 0
|
||||
offset % properties.min_storage_buffer_offset_alignment as usize == 0
|
||||
);
|
||||
}
|
||||
if self.usage().uniform_buffer {
|
||||
debug_assert!(
|
||||
offset % properties.min_uniform_buffer_offset_alignment.unwrap() as usize == 0
|
||||
offset % properties.min_uniform_buffer_offset_alignment as usize == 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +97,7 @@ where
|
||||
% device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_texel_buffer_offset_alignment
|
||||
.unwrap() as usize)
|
||||
.min_texel_buffer_offset_alignment as usize)
|
||||
!= 0
|
||||
{
|
||||
return Err(BufferViewCreationError::WrongBufferAlignment);
|
||||
@ -116,8 +115,7 @@ where
|
||||
let l = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_texel_buffer_elements
|
||||
.unwrap();
|
||||
.max_texel_buffer_elements;
|
||||
if nb > l as usize {
|
||||
return Err(BufferViewCreationError::MaxTexelBufferElementsExceeded);
|
||||
}
|
||||
|
@ -1259,8 +1259,7 @@ impl<L, P> AutoCommandBufferBuilder<L, P> {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_draw_indirect_count
|
||||
.unwrap();
|
||||
.max_draw_indirect_count;
|
||||
|
||||
if requested > limit {
|
||||
return Err(
|
||||
@ -1440,8 +1439,7 @@ impl<L, P> AutoCommandBufferBuilder<L, P> {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_draw_indirect_count
|
||||
.unwrap();
|
||||
.max_draw_indirect_count;
|
||||
|
||||
if requested > limit {
|
||||
return Err(
|
||||
|
@ -425,8 +425,7 @@ impl UnsafeCommandBufferBuilder {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_bindings
|
||||
.unwrap();
|
||||
.max_vertex_input_bindings;
|
||||
first_binding + num_bindings <= max_bindings
|
||||
});
|
||||
|
||||
@ -1022,8 +1021,7 @@ impl UnsafeCommandBufferBuilder {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_compute_work_group_count
|
||||
.unwrap();
|
||||
.max_compute_work_group_count;
|
||||
group_counts[0] <= max_group_counts[0]
|
||||
&& group_counts[1] <= max_group_counts[1]
|
||||
&& group_counts[2] <= max_group_counts[2]
|
||||
@ -1421,8 +1419,7 @@ impl UnsafeCommandBufferBuilder {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_viewports
|
||||
.unwrap();
|
||||
.max_viewports;
|
||||
first_scissor + scissors.len() as u32 <= max
|
||||
});
|
||||
|
||||
@ -1457,8 +1454,7 @@ impl UnsafeCommandBufferBuilder {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_viewports
|
||||
.unwrap();
|
||||
.max_viewports;
|
||||
first_viewport + viewports.len() as u32 <= max
|
||||
});
|
||||
|
||||
|
@ -17,8 +17,7 @@ pub fn check_dispatch(device: &Device, dimensions: [u32; 3]) -> Result<(), Check
|
||||
let max = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_compute_work_group_count
|
||||
.unwrap();
|
||||
.max_compute_work_group_count;
|
||||
|
||||
if dimensions[0] > max[0] || dimensions[1] > max[1] || dimensions[2] > max[2] {
|
||||
return Err(CheckDispatchError::UnsupportedDimensions {
|
||||
@ -74,7 +73,6 @@ mod tests {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_compute_work_group_count
|
||||
.unwrap()
|
||||
== attempted
|
||||
{
|
||||
return;
|
||||
|
@ -205,8 +205,8 @@ impl DescriptorSetWithOffsets {
|
||||
let dynamic_offsets: SmallVec<_> = dynamic_offsets.into_iter().collect();
|
||||
let layout = descriptor_set.layout();
|
||||
let properties = layout.device().physical_device().properties();
|
||||
let min_uniform_off_align = properties.min_uniform_buffer_offset_alignment.unwrap() as u32;
|
||||
let min_storage_off_align = properties.min_storage_buffer_offset_alignment.unwrap() as u32;
|
||||
let min_uniform_off_align = properties.min_uniform_buffer_offset_alignment as u32;
|
||||
let min_storage_off_align = properties.min_storage_buffer_offset_alignment as u32;
|
||||
let mut dynamic_offset_index = 0;
|
||||
|
||||
// Ensure that the number of dynamic_offsets is correct and that each
|
||||
|
@ -405,8 +405,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_uniform_buffer_offset_alignment
|
||||
.unwrap() as usize,
|
||||
.min_uniform_buffer_offset_alignment as usize,
|
||||
0
|
||||
);
|
||||
debug_assert!(
|
||||
@ -414,8 +413,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_uniform_buffer_range
|
||||
.unwrap() as usize
|
||||
.max_uniform_buffer_range as usize
|
||||
);
|
||||
|
||||
DescriptorWrite {
|
||||
@ -441,8 +439,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_storage_buffer_offset_alignment
|
||||
.unwrap() as usize,
|
||||
.min_storage_buffer_offset_alignment as usize,
|
||||
0
|
||||
);
|
||||
debug_assert!(
|
||||
@ -450,8 +447,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_storage_buffer_range
|
||||
.unwrap() as usize
|
||||
.max_storage_buffer_range as usize
|
||||
);
|
||||
|
||||
DescriptorWrite {
|
||||
@ -481,8 +477,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_uniform_buffer_offset_alignment
|
||||
.unwrap() as usize,
|
||||
.min_uniform_buffer_offset_alignment as usize,
|
||||
0
|
||||
);
|
||||
debug_assert!(
|
||||
@ -490,8 +485,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_uniform_buffer_range
|
||||
.unwrap() as usize
|
||||
.max_uniform_buffer_range as usize
|
||||
);
|
||||
|
||||
DescriptorWrite {
|
||||
@ -523,8 +517,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.min_storage_buffer_offset_alignment
|
||||
.unwrap() as usize,
|
||||
.min_storage_buffer_offset_alignment as usize,
|
||||
0
|
||||
);
|
||||
debug_assert!(
|
||||
@ -532,8 +525,7 @@ impl DescriptorWrite {
|
||||
.device()
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_storage_buffer_range
|
||||
.unwrap() as usize
|
||||
.max_storage_buffer_range as usize
|
||||
);
|
||||
|
||||
DescriptorWrite {
|
||||
|
@ -295,7 +295,7 @@ fn init_physical_devices_inner2(instance: &Instance, infos: &mut [PhysicalDevice
|
||||
/// }
|
||||
///
|
||||
/// fn print_infos(dev: PhysicalDevice) {
|
||||
/// println!("Name: {}", dev.properties().device_name.as_ref().unwrap());
|
||||
/// println!("Name: {}", dev.properties().device_name);
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@ -318,7 +318,7 @@ impl<'a> PhysicalDevice<'a> {
|
||||
///
|
||||
/// # let instance = Instance::new(None, Version::V1_1, &InstanceExtensions::none(), None).unwrap();
|
||||
/// for physical_device in PhysicalDevice::enumerate(&instance) {
|
||||
/// println!("Available device: {}", physical_device.properties().device_name.as_ref().unwrap());
|
||||
/// println!("Available device: {}", physical_device.properties().device_name);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -536,6 +536,13 @@ pub enum PhysicalDeviceType {
|
||||
Other = ash::vk::PhysicalDeviceType::OTHER.as_raw(),
|
||||
}
|
||||
|
||||
/// VkPhysicalDeviceType::Other is represented as 0
|
||||
impl Default for PhysicalDeviceType {
|
||||
fn default() -> Self {
|
||||
PhysicalDeviceType::Other
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<ash::vk::PhysicalDeviceType> for PhysicalDeviceType {
|
||||
type Error = ();
|
||||
|
||||
|
@ -9,13 +9,42 @@ use crate::Version;
|
||||
use std::convert::TryInto;
|
||||
use std::ffi::CStr;
|
||||
|
||||
/// this is a macro that outputs either T or Option<T> depending on the 2nd argument
|
||||
macro_rules! property_type {
|
||||
($ty:ty, true) => {
|
||||
$ty
|
||||
};
|
||||
($ty:ty, false) => {
|
||||
Option<$ty>
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use property_type;
|
||||
|
||||
/// this is a macro that executes the correct from_vulkan call depending on whether or not the type is Option<T>
|
||||
macro_rules! property_from_vulkan {
|
||||
($ty:ty, [$($ffi_struct:ident $(.$ffi_struct_field:ident)*),+], $ffi_field:ident, true, $properties:ident) => {
|
||||
std::array::IntoIter::new([
|
||||
$($properties.$ffi_struct$(.$ffi_struct_field)*.$ffi_field),+
|
||||
]).next().and_then(|x| <$ty>::from_vulkan(x)).expect(concat!("expected good ", stringify!($ffi_field)))
|
||||
};
|
||||
($ty:ty, [$($ffi_struct:ident $(.$ffi_struct_field:ident)*),+], $ffi_field:ident, false, $properties:ident) => {
|
||||
std::array::IntoIter::new([
|
||||
$($properties.$ffi_struct.map(|s| s$(.$ffi_struct_field)*.$ffi_field)),+
|
||||
]).flatten().next().and_then(|x| <$ty>::from_vulkan(x))
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use property_from_vulkan;
|
||||
|
||||
macro_rules! properties {
|
||||
{
|
||||
$($member:ident => {
|
||||
doc: $doc:expr,
|
||||
ty: $ty:ty,
|
||||
ffi_name: $ffi_field:ident,
|
||||
ty: $ty:ty,
|
||||
ffi_name: $ffi_field:ident,
|
||||
ffi_members: [$($ffi_struct:ident $(.$ffi_struct_field:ident)*),+],
|
||||
required: $required:tt,
|
||||
},)*
|
||||
} => {
|
||||
/// Represents all the properties of a physical device.
|
||||
@ -28,7 +57,7 @@ macro_rules! properties {
|
||||
pub struct Properties {
|
||||
$(
|
||||
#[doc = $doc]
|
||||
pub $member: Option<$ty>,
|
||||
pub $member: $crate::device::properties::property_type!($ty, $required),
|
||||
)*
|
||||
}
|
||||
|
||||
@ -38,9 +67,7 @@ macro_rules! properties {
|
||||
|
||||
Properties {
|
||||
$(
|
||||
$member: std::array::IntoIter::new([
|
||||
$(properties_ffi.$ffi_struct.map(|s| s$(.$ffi_struct_field)*.$ffi_field)),+
|
||||
]).flatten().next().and_then(|x| <$ty>::from_vulkan(x)),
|
||||
$member: crate::device::properties::property_from_vulkan!($ty, [ $($ffi_struct$(.$ffi_struct_field)*),+ ], $ffi_field, $required, properties_ffi),
|
||||
)*
|
||||
}
|
||||
}
|
||||
@ -55,7 +82,7 @@ macro_rules! properties_ffi {
|
||||
{
|
||||
$api_version:ident,
|
||||
$device_extensions:ident,
|
||||
$instance_extensions:ident,
|
||||
$instance_extensions:ident,
|
||||
$($member:ident => {
|
||||
ty: $ty:ident,
|
||||
provided_by: [$($provided_by:expr),+],
|
||||
@ -64,7 +91,7 @@ macro_rules! properties_ffi {
|
||||
} => {
|
||||
#[derive(Default)]
|
||||
pub(crate) struct PropertiesFfi {
|
||||
properties_vulkan10: Option<ash::vk::PhysicalDeviceProperties2KHR>,
|
||||
properties_vulkan10: ash::vk::PhysicalDeviceProperties2KHR,
|
||||
|
||||
$(
|
||||
$member: Option<ash::vk::$ty>,
|
||||
@ -78,8 +105,8 @@ macro_rules! properties_ffi {
|
||||
$device_extensions: &crate::device::DeviceExtensions,
|
||||
$instance_extensions: &crate::instance::InstanceExtensions,
|
||||
) {
|
||||
self.properties_vulkan10 = Some(Default::default());
|
||||
let head = self.properties_vulkan10.as_mut().unwrap();
|
||||
self.properties_vulkan10 = Default::default();
|
||||
let head = &mut self.properties_vulkan10;
|
||||
|
||||
$(
|
||||
if std::array::IntoIter::new([$($provided_by),+]).any(|x| x) &&
|
||||
@ -93,11 +120,11 @@ macro_rules! properties_ffi {
|
||||
}
|
||||
|
||||
pub(crate) fn head_as_ref(&self) -> &ash::vk::PhysicalDeviceProperties2KHR {
|
||||
self.properties_vulkan10.as_ref().unwrap()
|
||||
&self.properties_vulkan10
|
||||
}
|
||||
|
||||
pub(crate) fn head_as_mut(&mut self) -> &mut ash::vk::PhysicalDeviceProperties2KHR {
|
||||
self.properties_vulkan10.as_mut().unwrap()
|
||||
&mut self.properties_vulkan10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -129,7 +129,7 @@ impl TryFrom<u32> for SampleCount {
|
||||
}
|
||||
|
||||
/// Specifies how many sample counts supported for an image used for storage operations.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone, Default)]
|
||||
pub struct SampleCounts {
|
||||
// specify an image with one sample per pixel
|
||||
pub sample1: bool,
|
||||
|
@ -251,7 +251,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.sampled_image_color_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Uint | FormatTy::Sint => {
|
||||
@ -259,7 +258,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.sampled_image_integer_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Depth => {
|
||||
@ -267,7 +265,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.sampled_image_depth_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Stencil => {
|
||||
@ -275,7 +272,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.sampled_image_stencil_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::DepthStencil => {
|
||||
@ -283,13 +279,11 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.sampled_image_depth_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
supported_samples &= device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.sampled_image_stencil_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Ycbcr => {
|
||||
@ -307,7 +301,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.storage_image_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
|
||||
@ -322,7 +315,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.framebuffer_color_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Depth => {
|
||||
@ -330,7 +322,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.framebuffer_depth_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Stencil => {
|
||||
@ -338,7 +329,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.framebuffer_stencil_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::DepthStencil => {
|
||||
@ -346,13 +336,11 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.framebuffer_depth_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
supported_samples &= device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.framebuffer_stencil_sample_counts
|
||||
.unwrap()
|
||||
.into();
|
||||
}
|
||||
FormatTy::Ycbcr => {
|
||||
@ -451,7 +439,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_image_array_layers
|
||||
.unwrap()
|
||||
{
|
||||
let err = ImageCreationError::UnsupportedDimensions { dimensions };
|
||||
capabilities_error = Some(err);
|
||||
@ -463,7 +450,6 @@ impl UnsafeImage {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_image_dimension1_d
|
||||
.unwrap()
|
||||
{
|
||||
let err = ImageCreationError::UnsupportedDimensions { dimensions };
|
||||
capabilities_error = Some(err);
|
||||
@ -473,8 +459,7 @@ impl UnsafeImage {
|
||||
let limit = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_image_dimension2_d
|
||||
.unwrap();
|
||||
.max_image_dimension2_d;
|
||||
if extent.width > limit || extent.height > limit {
|
||||
let err = ImageCreationError::UnsupportedDimensions { dimensions };
|
||||
capabilities_error = Some(err);
|
||||
@ -484,8 +469,7 @@ impl UnsafeImage {
|
||||
let limit = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_image_dimension_cube
|
||||
.unwrap();
|
||||
.max_image_dimension_cube;
|
||||
if extent.width > limit {
|
||||
let err = ImageCreationError::UnsupportedDimensions { dimensions };
|
||||
capabilities_error = Some(err);
|
||||
@ -496,8 +480,7 @@ impl UnsafeImage {
|
||||
let limit = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_image_dimension3_d
|
||||
.unwrap();
|
||||
.max_image_dimension3_d;
|
||||
if extent.width > limit || extent.height > limit || extent.depth > limit {
|
||||
let err = ImageCreationError::UnsupportedDimensions { dimensions };
|
||||
capabilities_error = Some(err);
|
||||
|
@ -35,7 +35,7 @@
|
||||
//!
|
||||
//! # let instance = Instance::new(None, Version::V1_1, &InstanceExtensions::none(), None).unwrap();
|
||||
//! for physical_device in PhysicalDevice::enumerate(&instance) {
|
||||
//! println!("Available device: {}", physical_device.properties().device_name.as_ref().unwrap());
|
||||
//! println!("Available device: {}", physical_device.properties().device_name);
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
@ -339,7 +339,6 @@ impl<'a> DeviceMemoryBuilder<'a> {
|
||||
>= physical_device
|
||||
.properties()
|
||||
.max_memory_allocation_count
|
||||
.unwrap()
|
||||
{
|
||||
return Err(DeviceMemoryAllocError::TooManyObjects);
|
||||
}
|
||||
|
@ -487,15 +487,13 @@ where
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_bindings
|
||||
.unwrap()
|
||||
{
|
||||
return Err(
|
||||
GraphicsPipelineCreationError::MaxVertexInputBindingsExceeded {
|
||||
max: device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_bindings
|
||||
.unwrap(),
|
||||
.max_vertex_input_bindings,
|
||||
obtained: binding,
|
||||
},
|
||||
);
|
||||
@ -506,7 +504,6 @@ where
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_binding_stride
|
||||
.unwrap()
|
||||
{
|
||||
return Err(
|
||||
GraphicsPipelineCreationError::MaxVertexInputBindingStrideExceeded {
|
||||
@ -514,8 +511,7 @@ where
|
||||
max: device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_binding_stride
|
||||
.unwrap(),
|
||||
.max_vertex_input_binding_stride,
|
||||
obtained: binding_desc.stride,
|
||||
},
|
||||
);
|
||||
@ -575,16 +571,14 @@ where
|
||||
> device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_bindings
|
||||
.unwrap() as usize
|
||||
.max_vertex_input_bindings as usize
|
||||
{
|
||||
return Err(
|
||||
GraphicsPipelineCreationError::MaxVertexInputBindingsExceeded {
|
||||
max: device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_bindings
|
||||
.unwrap(),
|
||||
.max_vertex_input_bindings,
|
||||
obtained: binding_descriptions.len() as u32,
|
||||
},
|
||||
);
|
||||
@ -604,15 +598,13 @@ where
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_attribute_offset
|
||||
.unwrap()
|
||||
{
|
||||
return Err(
|
||||
GraphicsPipelineCreationError::MaxVertexInputAttributeOffsetExceeded {
|
||||
max: device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_attribute_offset
|
||||
.unwrap(),
|
||||
.max_vertex_input_attribute_offset,
|
||||
obtained: attribute_desc.offset,
|
||||
},
|
||||
);
|
||||
@ -630,16 +622,14 @@ where
|
||||
> device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_attributes
|
||||
.unwrap() as usize
|
||||
.max_vertex_input_attributes as usize
|
||||
{
|
||||
return Err(
|
||||
GraphicsPipelineCreationError::MaxVertexInputAttributesExceeded {
|
||||
max: device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_vertex_input_attributes
|
||||
.unwrap(),
|
||||
.max_vertex_input_attributes,
|
||||
obtained: attribute_descriptions.len(),
|
||||
},
|
||||
);
|
||||
@ -706,7 +696,6 @@ where
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_tessellation_patch_size
|
||||
.unwrap()
|
||||
{
|
||||
return Err(GraphicsPipelineCreationError::MaxTessellationPatchSizeExceeded);
|
||||
}
|
||||
@ -765,10 +754,10 @@ where
|
||||
return Err(GraphicsPipelineCreationError::MultiViewportFeatureNotEnabled);
|
||||
}
|
||||
|
||||
if vp_num > device.physical_device().properties().max_viewports.unwrap() {
|
||||
if vp_num > device.physical_device().properties().max_viewports {
|
||||
return Err(GraphicsPipelineCreationError::MaxViewportsExceeded {
|
||||
obtained: vp_num,
|
||||
max: device.physical_device().properties().max_viewports.unwrap(),
|
||||
max: device.physical_device().properties().max_viewports,
|
||||
});
|
||||
}
|
||||
|
||||
@ -777,14 +766,12 @@ where
|
||||
> device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_viewport_dimensions
|
||||
.unwrap()[0] as f32
|
||||
.max_viewport_dimensions[0] as f32
|
||||
|| vp.height
|
||||
> device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_viewport_dimensions
|
||||
.unwrap()[1] as f32
|
||||
.max_viewport_dimensions[1] as f32
|
||||
{
|
||||
return Err(GraphicsPipelineCreationError::MaxViewportDimensionsExceeded);
|
||||
}
|
||||
@ -793,26 +780,22 @@ where
|
||||
< device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.viewport_bounds_range
|
||||
.unwrap()[0]
|
||||
.viewport_bounds_range[0]
|
||||
|| vp.x + vp.width
|
||||
> device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.viewport_bounds_range
|
||||
.unwrap()[1]
|
||||
.viewport_bounds_range[1]
|
||||
|| vp.y
|
||||
< device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.viewport_bounds_range
|
||||
.unwrap()[0]
|
||||
.viewport_bounds_range[0]
|
||||
|| vp.y + vp.height
|
||||
> device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.viewport_bounds_range
|
||||
.unwrap()[1]
|
||||
.viewport_bounds_range[1]
|
||||
{
|
||||
return Err(GraphicsPipelineCreationError::ViewportBoundsExceeded);
|
||||
}
|
||||
|
@ -74,66 +74,66 @@ pub fn check_desc_against_limits(
|
||||
}
|
||||
}
|
||||
|
||||
if descriptor_set_layouts.len() > properties.max_bound_descriptor_sets.unwrap() as usize {
|
||||
if descriptor_set_layouts.len() > properties.max_bound_descriptor_sets as usize {
|
||||
return Err(PipelineLayoutLimitsError::MaxDescriptorSetsLimitExceeded {
|
||||
limit: properties.max_bound_descriptor_sets.unwrap() as usize,
|
||||
limit: properties.max_bound_descriptor_sets as usize,
|
||||
requested: descriptor_set_layouts.len(),
|
||||
});
|
||||
}
|
||||
|
||||
if num_resources.max_per_stage() > properties.max_per_stage_resources.unwrap() {
|
||||
if num_resources.max_per_stage() > properties.max_per_stage_resources {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageResourcesLimitExceeded {
|
||||
limit: properties.max_per_stage_resources.unwrap(),
|
||||
limit: properties.max_per_stage_resources,
|
||||
requested: num_resources.max_per_stage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if num_samplers.max_per_stage() > properties.max_per_stage_descriptor_samplers.unwrap() {
|
||||
if num_samplers.max_per_stage() > properties.max_per_stage_descriptor_samplers {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageDescriptorSamplersLimitExceeded {
|
||||
limit: properties.max_per_stage_descriptor_samplers.unwrap(),
|
||||
limit: properties.max_per_stage_descriptor_samplers,
|
||||
requested: num_samplers.max_per_stage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_uniform_buffers.max_per_stage()
|
||||
> properties.max_per_stage_descriptor_uniform_buffers.unwrap()
|
||||
> properties.max_per_stage_descriptor_uniform_buffers
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageDescriptorUniformBuffersLimitExceeded {
|
||||
limit: properties.max_per_stage_descriptor_uniform_buffers.unwrap(),
|
||||
limit: properties.max_per_stage_descriptor_uniform_buffers,
|
||||
requested: num_uniform_buffers.max_per_stage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_storage_buffers.max_per_stage()
|
||||
> properties.max_per_stage_descriptor_storage_buffers.unwrap()
|
||||
> properties.max_per_stage_descriptor_storage_buffers
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageDescriptorStorageBuffersLimitExceeded {
|
||||
limit: properties.max_per_stage_descriptor_storage_buffers.unwrap(),
|
||||
limit: properties.max_per_stage_descriptor_storage_buffers,
|
||||
requested: num_storage_buffers.max_per_stage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_sampled_images.max_per_stage()
|
||||
> properties.max_per_stage_descriptor_sampled_images.unwrap()
|
||||
> properties.max_per_stage_descriptor_sampled_images
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageDescriptorSampledImagesLimitExceeded {
|
||||
limit: properties.max_per_stage_descriptor_sampled_images.unwrap(),
|
||||
limit: properties.max_per_stage_descriptor_sampled_images,
|
||||
requested: num_sampled_images.max_per_stage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_storage_images.max_per_stage()
|
||||
> properties.max_per_stage_descriptor_storage_images.unwrap()
|
||||
> properties.max_per_stage_descriptor_storage_images
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageDescriptorStorageImagesLimitExceeded {
|
||||
limit: properties.max_per_stage_descriptor_storage_images.unwrap(),
|
||||
limit: properties.max_per_stage_descriptor_storage_images,
|
||||
requested: num_storage_images.max_per_stage(),
|
||||
},
|
||||
);
|
||||
@ -141,30 +141,28 @@ pub fn check_desc_against_limits(
|
||||
if num_input_attachments.max_per_stage()
|
||||
> properties
|
||||
.max_per_stage_descriptor_input_attachments
|
||||
.unwrap()
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxPerStageDescriptorInputAttachmentsLimitExceeded {
|
||||
limit: properties
|
||||
.max_per_stage_descriptor_input_attachments
|
||||
.unwrap(),
|
||||
.max_per_stage_descriptor_input_attachments,
|
||||
requested: num_input_attachments.max_per_stage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if num_samplers.total > properties.max_descriptor_set_samplers.unwrap() {
|
||||
if num_samplers.total > properties.max_descriptor_set_samplers {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetSamplersLimitExceeded {
|
||||
limit: properties.max_descriptor_set_samplers.unwrap(),
|
||||
limit: properties.max_descriptor_set_samplers,
|
||||
requested: num_samplers.total,
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_uniform_buffers.total > properties.max_descriptor_set_uniform_buffers.unwrap() {
|
||||
if num_uniform_buffers.total > properties.max_descriptor_set_uniform_buffers {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetUniformBuffersLimitExceeded {
|
||||
limit: properties.max_descriptor_set_uniform_buffers.unwrap(),
|
||||
limit: properties.max_descriptor_set_uniform_buffers,
|
||||
requested: num_uniform_buffers.total,
|
||||
},
|
||||
);
|
||||
@ -172,21 +170,19 @@ pub fn check_desc_against_limits(
|
||||
if num_uniform_buffers_dynamic
|
||||
> properties
|
||||
.max_descriptor_set_uniform_buffers_dynamic
|
||||
.unwrap()
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetUniformBuffersDynamicLimitExceeded {
|
||||
limit: properties
|
||||
.max_descriptor_set_uniform_buffers_dynamic
|
||||
.unwrap(),
|
||||
.max_descriptor_set_uniform_buffers_dynamic,
|
||||
requested: num_uniform_buffers_dynamic,
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_storage_buffers.total > properties.max_descriptor_set_storage_buffers.unwrap() {
|
||||
if num_storage_buffers.total > properties.max_descriptor_set_storage_buffers {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetStorageBuffersLimitExceeded {
|
||||
limit: properties.max_descriptor_set_storage_buffers.unwrap(),
|
||||
limit: properties.max_descriptor_set_storage_buffers,
|
||||
requested: num_storage_buffers.total,
|
||||
},
|
||||
);
|
||||
@ -194,46 +190,44 @@ pub fn check_desc_against_limits(
|
||||
if num_storage_buffers_dynamic
|
||||
> properties
|
||||
.max_descriptor_set_storage_buffers_dynamic
|
||||
.unwrap()
|
||||
{
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetStorageBuffersDynamicLimitExceeded {
|
||||
limit: properties
|
||||
.max_descriptor_set_storage_buffers_dynamic
|
||||
.unwrap(),
|
||||
.max_descriptor_set_storage_buffers_dynamic,
|
||||
requested: num_storage_buffers_dynamic,
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_sampled_images.total > properties.max_descriptor_set_sampled_images.unwrap() {
|
||||
if num_sampled_images.total > properties.max_descriptor_set_sampled_images {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetSampledImagesLimitExceeded {
|
||||
limit: properties.max_descriptor_set_sampled_images.unwrap(),
|
||||
limit: properties.max_descriptor_set_sampled_images,
|
||||
requested: num_sampled_images.total,
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_storage_images.total > properties.max_descriptor_set_storage_images.unwrap() {
|
||||
if num_storage_images.total > properties.max_descriptor_set_storage_images {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetStorageImagesLimitExceeded {
|
||||
limit: properties.max_descriptor_set_storage_images.unwrap(),
|
||||
limit: properties.max_descriptor_set_storage_images,
|
||||
requested: num_storage_images.total,
|
||||
},
|
||||
);
|
||||
}
|
||||
if num_input_attachments.total > properties.max_descriptor_set_input_attachments.unwrap() {
|
||||
if num_input_attachments.total > properties.max_descriptor_set_input_attachments {
|
||||
return Err(
|
||||
PipelineLayoutLimitsError::MaxDescriptorSetInputAttachmentsLimitExceeded {
|
||||
limit: properties.max_descriptor_set_input_attachments.unwrap(),
|
||||
limit: properties.max_descriptor_set_input_attachments,
|
||||
requested: num_input_attachments.total,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
for &PipelineLayoutPcRange { offset, size, .. } in push_constants_ranges {
|
||||
if offset + size > properties.max_push_constants_size.unwrap() as usize {
|
||||
if offset + size > properties.max_push_constants_size as usize {
|
||||
return Err(PipelineLayoutLimitsError::MaxPushConstantsSizeExceeded {
|
||||
limit: properties.max_push_constants_size.unwrap() as usize,
|
||||
limit: properties.max_push_constants_size as usize,
|
||||
requested: offset + size,
|
||||
});
|
||||
}
|
||||
|
@ -282,9 +282,9 @@ where
|
||||
{
|
||||
let properties = device.physical_device().properties();
|
||||
let limits = [
|
||||
properties.max_framebuffer_width.unwrap(),
|
||||
properties.max_framebuffer_height.unwrap(),
|
||||
properties.max_framebuffer_layers.unwrap(),
|
||||
properties.max_framebuffer_width,
|
||||
properties.max_framebuffer_height,
|
||||
properties.max_framebuffer_layers,
|
||||
];
|
||||
if dimensions[0] > limits[0] || dimensions[1] > limits[1] || dimensions[2] > limits[2] {
|
||||
return Err(FramebufferCreationError::DimensionsTooLarge);
|
||||
|
@ -290,7 +290,6 @@ impl RenderPass {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_color_attachments
|
||||
.unwrap()
|
||||
{
|
||||
return Err(RenderPassCreationError::ColorAttachmentsLimitExceeded);
|
||||
}
|
||||
@ -858,7 +857,6 @@ mod tests {
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_color_attachments
|
||||
.unwrap()
|
||||
>= 10
|
||||
{
|
||||
return; // test ignored
|
||||
|
@ -269,8 +269,7 @@ impl Sampler {
|
||||
let limit = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_sampler_anisotropy
|
||||
.unwrap();
|
||||
.max_sampler_anisotropy;
|
||||
if max_anisotropy > limit {
|
||||
return Err(SamplerCreationError::AnisotropyLimitExceeded {
|
||||
requested: max_anisotropy,
|
||||
@ -284,8 +283,7 @@ impl Sampler {
|
||||
let limit = device
|
||||
.physical_device()
|
||||
.properties()
|
||||
.max_sampler_lod_bias
|
||||
.unwrap();
|
||||
.max_sampler_lod_bias;
|
||||
if mip_lod_bias > limit {
|
||||
return Err(SamplerCreationError::MipLodBiasLimitExceeded {
|
||||
requested: mip_lod_bias,
|
||||
|
@ -39,6 +39,12 @@ impl Version {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Version {
|
||||
fn default() -> Self {
|
||||
Self::V1_0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for Version {
|
||||
#[inline]
|
||||
fn from(val: u32) -> Self {
|
||||
|
Loading…
Reference in New Issue
Block a user