hal/vk: use more ergonomic GetPhysicalDeviceProperties2

This commit is contained in:
Dzmitry Malyshau committed 2021-12-01 21:50:14 -05:00
1 parent c16f794aa4
commit c0895f6fac
3 files changed
+13 -15

No files matched your search

+2 -3
View File
@@ -681,8 +681,7 @@ impl super::InstanceShared {
}
unsafe {
get_device_properties
.get_physical_device_properties2_khr(phd, &mut properites2);
get_device_properties.get_physical_device_properties2(phd, &mut properites2);
}
properites2.properties
} else {
@@ -749,7 +748,7 @@ impl super::InstanceShared {
}
unsafe {
get_device_properties.get_physical_device_features2_khr(phd, &mut features2);
get_device_properties.get_physical_device_features2(phd, &mut features2);
}
features2.features
} else {
+10 -11
View File
@@ -1,7 +1,7 @@
use std::{
cmp,
ffi::{c_void, CStr, CString},
mem, slice,
slice,
sync::Arc,
thread,
};
@@ -207,16 +207,15 @@ impl super::Instance {
None
};
let get_physical_device_properties = extensions
.iter()
.find(|&&ext| ext == vk::KhrGetPhysicalDeviceProperties2Fn::name())
.map(|_| {
vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| {
mem::transmute(
entry.get_instance_proc_addr(raw_instance.handle(), name.as_ptr()),
)
})
});
let get_physical_device_properties =
if extensions.contains(&khr::GetPhysicalDeviceProperties2::name()) {
Some(khr::GetPhysicalDeviceProperties2::new(
&entry,
&raw_instance,
))
} else {
None
};
Ok(Self {
shared: Arc::new(super::InstanceShared {
+1 -1
View File
@@ -84,7 +84,7 @@ struct InstanceShared {
drop_guard: Option<DropGuard>,
flags: crate::InstanceFlags,
debug_utils: Option<DebugUtils>,
get_physical_device_properties: Option<vk::KhrGetPhysicalDeviceProperties2Fn>,
get_physical_device_properties: Option<khr::GetPhysicalDeviceProperties2>,
entry: ash::Entry,
has_nv_optimus: bool,
}