diff --git a/ash/Cargo.toml b/ash/Cargo.toml index 46f37b7..167abd8 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -12,6 +12,7 @@ documentation = "https://docs.rs/ash" [dependencies] shared_library = "0.1.5" lazy_static = "0.2.1" +libc = "0.2.26" [package.metadata.release] no-dev-version = true diff --git a/ash/src/device.rs b/ash/src/device.rs index 40500b8..bfe64b7 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -753,9 +753,9 @@ pub trait DeviceV1_0 { offset: vk::DeviceSize, size: vk::DeviceSize, flags: vk::MemoryMapFlags, - ) -> VkResult<*mut ()> { + ) -> VkResult<*mut vk::c_void> { - let mut data: *mut () = mem::uninitialized(); + let mut data: *mut vk::c_void = mem::uninitialized(); let err_code = self.fp_v1_0().map_memory( self.handle(), memory, diff --git a/ash/src/lib.rs b/ash/src/lib.rs index f75d3e8..ba433cb 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -1,3 +1,4 @@ +extern crate libc; extern crate shared_library; #[macro_use] extern crate lazy_static; @@ -10,7 +11,7 @@ mod device; mod entry; pub mod prelude; pub mod vk; -mod allocator; +//mod allocator; pub mod extensions; pub mod version; pub mod util; diff --git a/ash/src/util.rs b/ash/src/util.rs index 44bb901..2d39682 100644 --- a/ash/src/util.rs +++ b/ash/src/util.rs @@ -52,7 +52,7 @@ impl AlignByteSlice { /// that is allocated on 4 bytes boundries, and insert the correct amount of paddings. #[derive(Debug, Clone)] pub struct Align { - ptr: *mut (), + ptr: *mut vk::c_void, elem_size: vk::DeviceSize, size: vk::DeviceSize, _m: PhantomData, @@ -85,7 +85,11 @@ fn calc_padding(adr: vk::DeviceSize, align: vk::DeviceSize) -> vk::DeviceSize { } impl Align { - pub unsafe fn new(ptr: *mut (), alignment: vk::DeviceSize, size: vk::DeviceSize) -> Self { + pub unsafe fn new( + ptr: *mut vk::c_void, + alignment: vk::DeviceSize, + size: vk::DeviceSize, + ) -> Self { let padding = calc_padding(size_of::() as vk::DeviceSize, alignment); let elem_size = size_of::() as vk::DeviceSize + padding; assert!(calc_padding(size, alignment) == 0, "size must be aligned"); diff --git a/ash/src/vk.rs b/ash/src/vk.rs index 9634c26..4daf1fb 100644 --- a/ash/src/vk.rs +++ b/ash/src/vk.rs @@ -199,23 +199,22 @@ macro_rules! vk_version_patch { ($minor: expr) => (($minor as uint32_t) & 0xfff) } -mod libc_reexports {} pub mod types { #![allow(non_camel_case_types, dead_code)] use std::ops::*; use std::fmt; use std::ffi::CStr; use super::*; - #[allow(unused_imports)] - use super::libc_reexports::*; - pub type c_void = (); - pub type c_char = i8; - pub type uint32_t = u32; - pub type size_t = usize; - pub type uint64_t = u64; - pub type uint8_t = u8; - pub type c_float = f32; - pub type int32_t = i32; + use libc; + + pub type c_void = libc::c_void; + pub type c_char = libc::c_char; + pub type uint32_t = libc::uint32_t; + pub type size_t = libc::size_t; + pub type uint64_t = libc::uint64_t; + pub type uint8_t = libc::uint8_t; + pub type c_float = libc::c_float; + pub type int32_t = libc::int32_t; pub type Display = *const (); pub type Window = *const (); pub type VisualID = *const (); @@ -3913,8 +3912,6 @@ macro_rules! vk_functions { pub mod cmds { #![allow(dead_code)] use super::*; - #[allow(unused_imports)] - use super::libc_reexports::*; vk_functions!{ StaticFn, diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index 5ef4add..956cb7f 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -147,7 +147,7 @@ fn main() { let index_buffer_memory = base.device .allocate_memory(&index_allocate_info, None) .unwrap(); - let index_ptr = base.device + let index_ptr: *mut vk::c_void = base.device .map_memory( index_buffer_memory, 0, @@ -330,12 +330,12 @@ fn main() { vk::MemoryMapFlags::empty(), ) .unwrap(); - let mut image_slice = AlignByteSlice::new( + let mut image_slice = Align::new( image_ptr, - image_buffer_memory_req.alignment, + std::mem::align_of::() as u64, image_buffer_memory_req.size, ); - image_slice.copy_from_slices(&[&image_data]); + image_slice.copy_from_slice(&image_data); base.device.unmap_memory(image_buffer_memory); base.device .bind_buffer_memory(image_buffer, image_buffer_memory, 0) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index d673a7d..5bbeecd 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -131,12 +131,12 @@ fn extension_names() -> Vec<*const i8> { unsafe extern "system" fn vulkan_debug_callback(_: vk::DebugReportFlagsEXT, _: vk::DebugReportObjectTypeEXT, - _: u64, - _: usize, - _: i32, - _: *const i8, - p_message: *const i8, - _: *mut ()) + _: vk::uint64_t, + _: vk::size_t, + _: vk::int32_t, + _: *const vk::c_char, + p_message: *const vk::c_char, + _: *mut vk::c_void) -> u32 { println!("{:?}", CStr::from_ptr(p_message)); 1