From 5ad765d2e14a34f3fd95d8901583ed40f32fd634 Mon Sep 17 00:00:00 2001 From: maik klein Date: Sat, 24 Dec 2016 05:57:44 +0100 Subject: [PATCH] Expose public api for handle --- src/device.rs | 8 ++++++-- src/entry.rs | 4 ++-- src/extensions/debug_report.rs | 9 ++++----- src/extensions/surface.rs | 4 ++-- src/extensions/swapchain.rs | 4 ++-- src/extensions/xlibsurface.rs | 5 ++--- src/instance.rs | 7 +++++-- src/vk.rs | 2 +- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/device.rs b/src/device.rs index 624c6c7..64c61b0 100644 --- a/src/device.rs +++ b/src/device.rs @@ -9,11 +9,15 @@ unsafe impl Sync for Device {} unsafe impl Send for Device {} pub struct Device { - pub handle: vk::Device, - pub device_fn: vk::DeviceFn, + handle: vk::Device, + device_fn: vk::DeviceFn, } impl Device { + pub fn handle(&self) -> vk::Device{ + self.handle + } + pub unsafe fn from_raw(handle: vk::Device, device_fn: vk::DeviceFn) -> Self { Device { handle: handle, diff --git a/src/entry.rs b/src/entry.rs index 0ff9cdf..fc63d05 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -26,8 +26,8 @@ lazy_static!{ } pub struct Entry { - pub static_fn: vk::StaticFn, - pub entry_fn: vk::EntryFn, + static_fn: vk::StaticFn, + entry_fn: vk::EntryFn, } #[derive(Debug)] diff --git a/src/extensions/debug_report.rs b/src/extensions/debug_report.rs index 56a9929..c662d9f 100644 --- a/src/extensions/debug_report.rs +++ b/src/extensions/debug_report.rs @@ -7,20 +7,19 @@ use vk; pub struct DebugReport { - pub handle: vk::Instance, - pub debug_report_fn: vk::DebugReportFn, + handle: vk::Instance, + debug_report_fn: vk::DebugReportFn, } impl DebugReport { pub fn new(entry: &Entry, instance: &Instance) -> Result { let debug_report_fn = vk::DebugReportFn::load(|name| { unsafe { - mem::transmute(entry.static_fn - .get_instance_proc_addr(instance.handle, name.as_ptr())) + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) } })?; Ok(DebugReport { - handle: instance.handle, + handle: instance.handle(), debug_report_fn: debug_report_fn, }) } diff --git a/src/extensions/surface.rs b/src/extensions/surface.rs index 7d94062..e2fbd9b 100644 --- a/src/extensions/surface.rs +++ b/src/extensions/surface.rs @@ -13,10 +13,10 @@ pub struct Surface { impl Surface { pub fn new(entry: &Entry, instance: &Instance) -> Result { let surface_fn = vk::SurfaceFn::load(|name| { - unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle, name.as_ptr())) } + unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) } })?; Ok(Surface { - handle: instance.handle, + handle: instance.handle(), surface_fn: surface_fn, }) } diff --git a/src/extensions/swapchain.rs b/src/extensions/swapchain.rs index 93a2ea7..c3a7c35 100644 --- a/src/extensions/swapchain.rs +++ b/src/extensions/swapchain.rs @@ -14,11 +14,11 @@ impl Swapchain { pub fn new(instance: &Instance, device: &Device) -> Result { let swapchain_fn = vk::SwapchainFn::load(|name| { unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle, name.as_ptr())) + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) } })?; Ok(Swapchain { - handle: device.handle, + handle: device.handle(), swapchain_fn: swapchain_fn, }) } diff --git a/src/extensions/xlibsurface.rs b/src/extensions/xlibsurface.rs index dadca44..400125d 100644 --- a/src/extensions/xlibsurface.rs +++ b/src/extensions/xlibsurface.rs @@ -14,12 +14,11 @@ impl XlibSurface { pub fn new(entry: &Entry, instance: &Instance) -> Result { let surface_fn = vk::XlibSurfaceFn::load(|name| { unsafe { - mem::transmute(entry.static_fn - .get_instance_proc_addr(instance.handle, name.as_ptr())) + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) } })?; Ok(XlibSurface { - handle: instance.handle, + handle: instance.handle(), xlib_surface_fn: surface_fn, }) } diff --git a/src/instance.rs b/src/instance.rs index 9faacf6..9c954cf 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -15,11 +15,14 @@ pub enum DeviceError { #[derive(Debug)] pub struct Instance { - pub handle: vk::Instance, - pub instance_fn: vk::InstanceFn, + handle: vk::Instance, + instance_fn: vk::InstanceFn, } impl Instance { + pub fn handle(&self) -> vk::Instance{ + self.handle + } pub unsafe fn from_raw(handle: vk::Instance, instance_fn: vk::InstanceFn) -> Self { Instance { handle: handle, diff --git a/src/vk.rs b/src/vk.rs index d92173a..a825dcc 100644 --- a/src/vk.rs +++ b/src/vk.rs @@ -3234,13 +3234,13 @@ pub mod types { pub type Queue = *mut Queue_T; - handle_nondispatchable!(Semaphore); #[repr(C)] #[doc(hidden)] pub struct CommandBuffer_T(u8); pub type CommandBuffer = *mut CommandBuffer_T; + handle_nondispatchable!(Semaphore); handle_nondispatchable!(Fence); handle_nondispatchable!(DeviceMemory); handle_nondispatchable!(Buffer);