map_memory returns a void ptr

This commit is contained in:
Maik Klein 2017-06-03 23:35:36 +02:00
parent c7fde01b2c
commit a9bb2e2b99

View file

@ -301,8 +301,7 @@ pub trait DeviceV1_0 {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
flags: vk::CommandBufferResetFlags) flags: vk::CommandBufferResetFlags)
-> VkResult<()> { -> VkResult<()> {
let err_code = self.fp_v1_0() let err_code = self.fp_v1_0().reset_command_buffer(command_buffer, flags);
.reset_command_buffer(command_buffer, flags);
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
_ => Err(err_code), _ => Err(err_code),
@ -560,7 +559,8 @@ pub trait DeviceV1_0 {
let mut pipeline_cache = mem::uninitialized(); let mut pipeline_cache = mem::uninitialized();
let err_code = self.fp_v1_0() let err_code = self.fp_v1_0()
.create_pipeline_cache(self.handle(), .create_pipeline_cache(self.handle(),
create_info, allocation_callbacks.as_raw_ptr(), create_info,
allocation_callbacks.as_raw_ptr(),
&mut pipeline_cache); &mut pipeline_cache);
match err_code { match err_code {
@ -569,21 +569,18 @@ pub trait DeviceV1_0 {
} }
} }
unsafe fn map_memory<T>(&self, unsafe fn map_memory(&self,
memory: vk::DeviceMemory, memory: vk::DeviceMemory,
offset: vk::DeviceSize, offset: vk::DeviceSize,
size: vk::DeviceSize, size: vk::DeviceSize,
flags: vk::MemoryMapFlags) flags: vk::MemoryMapFlags)
-> VkResult<&mut [T]> { -> VkResult<*mut ()> {
let mut data: *mut () = mem::uninitialized(); let mut data: *mut () = mem::uninitialized();
let err_code = self.fp_v1_0() let err_code = self.fp_v1_0()
.map_memory(self.handle(), memory, offset, size, flags, &mut data); .map_memory(self.handle(), memory, offset, size, flags, &mut data);
let x: *mut T = data as *mut T;
match err_code { match err_code {
vk::Result::Success => { vk::Result::Success => Ok(data),
Ok(::std::slice::from_raw_parts_mut(x, size as vk::size_t / mem::size_of::<T>()))
}
_ => Err(err_code), _ => Err(err_code),
} }
} }