Added VK_EXT_tooling_info extension support (#310)

* Added `VK_EXT_tooling_info` extension support.

* Formatting applied.

* cargo-clippy suggestions satisfied.

* cargo-clippy suggestions satisfied.
This commit is contained in:
zedrian 2020-07-02 12:10:05 +02:00 committed by GitHub
parent 8d7dfee763
commit ac4d046d4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 1 deletions

View file

@ -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;

View file

@ -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<E: EntryV1_0, I: InstanceV1_0>(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<Vec<vk::PhysicalDeviceToolPropertiesEXT>> {
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
}
}

View file

@ -158,6 +158,7 @@ unsafe fn create_surface<E: EntryV1_0, I: InstanceV1_0>(
instance: &I,
window: &winit::Window,
) -> Result<vk::SurfaceKHR, vk::Result> {
use std::ffi::c_void;
use std::ptr;
use winapi::shared::windef::HWND;
use winapi::um::libloaderapi::GetModuleHandleW;

View file

@ -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() {