diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index 1885933..56d6e18 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -2,8 +2,10 @@ pub use self::debug_marker::DebugMarker; pub use self::debug_report::DebugReport; pub use self::debug_utils::DebugUtils; pub use self::metal_surface::MetalSurface; +pub use self::tooling_info::ToolingInfo; mod debug_marker; mod debug_report; mod debug_utils; mod metal_surface; +mod tooling_info; diff --git a/ash/src/extensions/ext/tooling_info.rs b/ash/src/extensions/ext/tooling_info.rs new file mode 100644 index 0000000..4212c88 --- /dev/null +++ b/ash/src/extensions/ext/tooling_info.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct ToolingInfo { + handle: vk::Instance, + tooling_info_fn: vk::ExtToolingInfoFn, +} + +impl ToolingInfo { + pub fn new(entry: &E, instance: &I) -> ToolingInfo { + let tooling_info_fn = vk::ExtToolingInfoFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + ToolingInfo { + handle: instance.handle(), + tooling_info_fn, + } + } + + pub fn name() -> &'static CStr { + vk::ExtToolingInfoFn::name() + } + + #[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceToolPropertiesEXT.html"] + pub unsafe fn get_physical_device_tool_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult> { + let mut count = 0; + self.tooling_info_fn + .get_physical_device_tool_properties_ext(physical_device, &mut count, ptr::null_mut()); + let mut v = Vec::with_capacity(count as usize); + let err_code = self + .tooling_info_fn + .get_physical_device_tool_properties_ext(physical_device, &mut count, v.as_mut_ptr()); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::ExtToolingInfoFn { + &self.tooling_info_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 48c7bc0..ba8e9f1 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -158,6 +158,7 @@ unsafe fn create_surface( instance: &I, window: &winit::Window, ) -> Result { + use std::ffi::c_void; use std::ptr; use winapi::shared::windef::HWND; use winapi::um::libloaderapi::GetModuleHandleW; diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 0f682ca..00cd261 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1753,7 +1753,7 @@ pub fn derive_setters( .map(|extends| name_to_tokens(&format!("Extends{}", name_to_tokens(&extends)))) .collect() }) - .unwrap_or_else(|| vec![]); + .unwrap_or_else(Vec::new); // We only implement a next methods for root structs with a `pnext` field. let next_function = if has_next && root_structs.is_empty() {