Expose public api for handle

This commit is contained in:
maik klein 2016-12-24 05:57:44 +01:00
parent 7bfe4d9531
commit 5ad765d2e1
8 changed files with 24 additions and 19 deletions

View file

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

View file

@ -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)]

View file

@ -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<DebugReport, String> {
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,
})
}

View file

@ -13,10 +13,10 @@ pub struct Surface {
impl Surface {
pub fn new(entry: &Entry, instance: &Instance) -> Result<Surface, String> {
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,
})
}

View file

@ -14,11 +14,11 @@ impl Swapchain {
pub fn new(instance: &Instance, device: &Device) -> Result<Swapchain, String> {
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,
})
}

View file

@ -14,12 +14,11 @@ impl XlibSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Result<XlibSurface, String> {
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,
})
}

View file

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

View file

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