Remove unused unsafe blocks

This commit is contained in:
maik klein 2016-12-29 04:17:46 +01:00
parent b49b2b1deb
commit 519a0f0038
6 changed files with 188 additions and 231 deletions

View file

@ -1,6 +1,5 @@
#![allow(dead_code)] #![allow(dead_code)]
use prelude::*; use prelude::*;
use std::ptr;
use std::mem; use std::mem;
use vk; use vk;
use ::RawPtr; use ::RawPtr;
@ -148,7 +147,6 @@ impl Device {
create_info: &vk::SamplerCreateInfo, create_info: &vk::SamplerCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::Sampler> { -> VkResult<vk::Sampler> {
unsafe {
let mut sampler = mem::uninitialized(); let mut sampler = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_sampler(self.handle, .create_sampler(self.handle,
@ -160,7 +158,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn cmd_copy_buffer(&self, pub unsafe fn cmd_copy_buffer(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
@ -223,7 +220,6 @@ impl Device {
create_info: &vk::DescriptorSetLayoutCreateInfo, create_info: &vk::DescriptorSetLayoutCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::DescriptorSetLayout> { -> VkResult<vk::DescriptorSetLayout> {
unsafe {
let mut layout = mem::uninitialized(); let mut layout = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_descriptor_set_layout(self.handle, .create_descriptor_set_layout(self.handle,
@ -235,7 +231,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub fn device_wait_idle(&self) -> VkResult<()> { pub fn device_wait_idle(&self) -> VkResult<()> {
unsafe { unsafe {
@ -251,7 +246,6 @@ impl Device {
create_info: &vk::DescriptorPoolCreateInfo, create_info: &vk::DescriptorPoolCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::DescriptorPool> { -> VkResult<vk::DescriptorPool> {
unsafe {
let mut pool = mem::uninitialized(); let mut pool = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_descriptor_pool(self.handle, .create_descriptor_pool(self.handle,
@ -263,7 +257,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn reset_command_buffer(&self, pub unsafe fn reset_command_buffer(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
@ -392,7 +385,6 @@ impl Device {
create_info: &vk::SemaphoreCreateInfo, create_info: &vk::SemaphoreCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::Semaphore> { -> VkResult<vk::Semaphore> {
unsafe {
let mut semaphore = mem::uninitialized(); let mut semaphore = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_semaphore(self.handle, .create_semaphore(self.handle,
@ -404,14 +396,12 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn create_graphics_pipelines(&self, pub unsafe fn create_graphics_pipelines(&self,
pipeline_cache: vk::PipelineCache, pipeline_cache: vk::PipelineCache,
create_infos: &[vk::GraphicsPipelineCreateInfo], create_infos: &[vk::GraphicsPipelineCreateInfo],
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<Vec<vk::Pipeline>> { -> VkResult<Vec<vk::Pipeline>> {
unsafe {
let mut pipelines = Vec::with_capacity(create_infos.len()); let mut pipelines = Vec::with_capacity(create_infos.len());
let err_code = self.device_fn let err_code = self.device_fn
.create_graphics_pipelines(self.handle, .create_graphics_pipelines(self.handle,
@ -426,13 +416,11 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn create_buffer(&self, pub unsafe fn create_buffer(&self,
create_info: &vk::BufferCreateInfo, create_info: &vk::BufferCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::Buffer> { -> VkResult<vk::Buffer> {
unsafe {
let mut buffer = mem::uninitialized(); let mut buffer = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_buffer(self.handle, .create_buffer(self.handle,
@ -444,7 +432,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub fn create_pipeline_layout(&self, pub fn create_pipeline_layout(&self,
create_info: &vk::PipelineLayoutCreateInfo, create_info: &vk::PipelineLayoutCreateInfo,
@ -509,13 +496,11 @@ impl Device {
queue_family_index: vk::uint32_t, queue_family_index: vk::uint32_t,
queue_index: vk::uint32_t) queue_index: vk::uint32_t)
-> vk::Queue { -> vk::Queue {
unsafe {
let mut queue = mem::uninitialized(); let mut queue = mem::uninitialized();
self.device_fn self.device_fn
.get_device_queue(self.handle, queue_family_index, queue_index, &mut queue); .get_device_queue(self.handle, queue_family_index, queue_index, &mut queue);
queue queue
} }
}
pub unsafe fn cmd_pipeline_barrier(&self, pub unsafe fn cmd_pipeline_barrier(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
@ -541,7 +526,6 @@ impl Device {
create_info: &vk::RenderPassCreateInfo, create_info: &vk::RenderPassCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::RenderPass> { -> VkResult<vk::RenderPass> {
unsafe {
let mut renderpass = mem::uninitialized(); let mut renderpass = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_render_pass(self.handle, .create_render_pass(self.handle,
@ -553,7 +537,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn begin_command_buffer(&self, pub unsafe fn begin_command_buffer(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
@ -581,7 +564,6 @@ impl Device {
wait_all: bool, wait_all: bool,
timeout: vk::uint64_t) timeout: vk::uint64_t)
-> VkResult<()> { -> VkResult<()> {
unsafe {
let err_code = self.device_fn let err_code = self.device_fn
.wait_for_fences(self.handle, .wait_for_fences(self.handle,
fences.len() as vk::uint32_t, fences.len() as vk::uint32_t,
@ -593,17 +575,14 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> { pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
unsafe {
let err_code = self.device_fn.queue_wait_idle(queue); let err_code = self.device_fn.queue_wait_idle(queue);
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn queue_present_khr(&self, pub unsafe fn queue_present_khr(&self,
queue: vk::Queue, queue: vk::Queue,
@ -637,7 +616,6 @@ impl Device {
create_info: &vk::ImageViewCreateInfo, create_info: &vk::ImageViewCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::ImageView> { -> VkResult<vk::ImageView> {
unsafe {
let mut image_view = mem::uninitialized(); let mut image_view = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_image_view(self.handle, .create_image_view(self.handle,
@ -649,7 +627,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn allocate_command_buffers(&self, pub unsafe fn allocate_command_buffers(&self,
@ -669,7 +646,6 @@ impl Device {
create_info: &vk::CommandPoolCreateInfo, create_info: &vk::CommandPoolCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::CommandPool> { -> VkResult<vk::CommandPool> {
unsafe {
let mut pool = mem::uninitialized(); let mut pool = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_command_pool(self.handle, .create_command_pool(self.handle,
@ -681,13 +657,11 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn create_image(&self, pub unsafe fn create_image(&self,
create_info: &vk::ImageCreateInfo, create_info: &vk::ImageCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::Image> { -> VkResult<vk::Image> {
unsafe {
let mut image = mem::uninitialized(); let mut image = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_image(self.handle, .create_image(self.handle,
@ -699,7 +673,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements { pub fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
unsafe { unsafe {
@ -723,7 +696,6 @@ impl Device {
create_info: &vk::MemoryAllocateInfo, create_info: &vk::MemoryAllocateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::DeviceMemory> { -> VkResult<vk::DeviceMemory> {
unsafe {
let mut memory = mem::uninitialized(); let mut memory = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.allocate_memory(self.handle, .allocate_memory(self.handle,
@ -735,13 +707,11 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn create_shader_module(&self, pub unsafe fn create_shader_module(&self,
create_info: &vk::ShaderModuleCreateInfo, create_info: &vk::ShaderModuleCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::ShaderModule> { -> VkResult<vk::ShaderModule> {
unsafe {
let mut shader = mem::uninitialized(); let mut shader = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_shader_module(self.handle, .create_shader_module(self.handle,
@ -753,13 +723,11 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn create_fence(&self, pub unsafe fn create_fence(&self,
create_info: &vk::FenceCreateInfo, create_info: &vk::FenceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::Fence> { -> VkResult<vk::Fence> {
unsafe {
let mut fence = mem::uninitialized(); let mut fence = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_fence(self.handle, .create_fence(self.handle,
@ -771,7 +739,6 @@ impl Device {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub unsafe fn bind_buffer_memory(&self, pub unsafe fn bind_buffer_memory(&self,
buffer: vk::Buffer, buffer: vk::Buffer,

View file

@ -1,5 +1,4 @@
use prelude::*; use prelude::*;
use std::ptr;
use std::mem; use std::mem;
use instance::Instance; use instance::Instance;
use entry::Entry; use entry::Entry;
@ -38,7 +37,6 @@ impl DebugReport {
pub unsafe fn create_debug_report_callback_ext(&self, pub unsafe fn create_debug_report_callback_ext(&self,
create_info: &vk::DebugReportCallbackCreateInfoEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>) create_info: &vk::DebugReportCallbackCreateInfoEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::DebugReportCallbackEXT> { -> VkResult<vk::DebugReportCallbackEXT> {
unsafe {
let mut debug_cb = mem::uninitialized(); let mut debug_cb = mem::uninitialized();
let err_code = self.debug_report_fn let err_code = self.debug_report_fn
.create_debug_report_callback_ext(self.handle, .create_debug_report_callback_ext(self.handle,
@ -50,5 +48,4 @@ impl DebugReport {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
} }

View file

@ -58,7 +58,6 @@ impl Swapchain {
create_info: &vk::SwapchainCreateInfoKHR, create_info: &vk::SwapchainCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SwapchainKHR> { -> VkResult<vk::SwapchainKHR> {
unsafe {
let mut swapchain = mem::uninitialized(); let mut swapchain = mem::uninitialized();
let err_code = self.swapchain_fn let err_code = self.swapchain_fn
.create_swapchain_khr(self.handle, .create_swapchain_khr(self.handle,
@ -70,7 +69,6 @@ impl Swapchain {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
pub fn get_swapchain_images_khr(&self, pub fn get_swapchain_images_khr(&self,
swapchain: vk::SwapchainKHR) swapchain: vk::SwapchainKHR)

View file

@ -1,5 +1,4 @@
use prelude::*; use prelude::*;
use std::ptr;
use std::mem; use std::mem;
use instance::Instance; use instance::Instance;
use entry::Entry; use entry::Entry;
@ -33,7 +32,6 @@ impl Win32Surface {
create_info: &vk::Win32SurfaceCreateInfoKHR, create_info: &vk::Win32SurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SurfaceKHR> { -> VkResult<vk::SurfaceKHR> {
unsafe {
let mut surface = mem::uninitialized(); let mut surface = mem::uninitialized();
let err_code = self.win32_surface_fn let err_code = self.win32_surface_fn
.create_win32_surface_khr(self.handle, .create_win32_surface_khr(self.handle,
@ -45,5 +43,4 @@ impl Win32Surface {
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
} }

View file

@ -1,5 +1,4 @@
use prelude::*; use prelude::*;
use std::ptr;
use std::mem; use std::mem;
use instance::Instance; use instance::Instance;
use entry::Entry; use entry::Entry;
@ -33,14 +32,15 @@ impl XlibSurface {
create_info: &vk::XlibSurfaceCreateInfoKHR, create_info: &vk::XlibSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SurfaceKHR> { -> VkResult<vk::SurfaceKHR> {
unsafe {
let mut surface = mem::uninitialized(); let mut surface = mem::uninitialized();
let err_code = self.xlib_surface_fn let err_code = self.xlib_surface_fn
.create_xlib_surface_khr(self.handle, create_info, allocation_callbacks.as_raw_ptr(), &mut surface); .create_xlib_surface_khr(self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut surface);
match err_code { match err_code {
vk::Result::Success => Ok(surface), vk::Result::Success => Ok(surface),
_ => Err(err_code), _ => Err(err_code),
} }
} }
}
} }

View file

@ -35,7 +35,6 @@ impl Instance {
create_info: &vk::DeviceCreateInfo, create_info: &vk::DeviceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> Result<Device, DeviceError> { -> Result<Device, DeviceError> {
unsafe {
let mut device: vk::Device = mem::uninitialized(); let mut device: vk::Device = mem::uninitialized();
let err_code = self.instance_fn let err_code = self.instance_fn
.create_device(physical_device, .create_device(physical_device,
@ -50,7 +49,6 @@ impl Instance {
}).map_err(|err| DeviceError::LoadError(err))?; }).map_err(|err| DeviceError::LoadError(err))?;
Ok(Device::from_raw(device, device_fn)) Ok(Device::from_raw(device, device_fn))
} }
}
pub fn get_device_proc_addr(&self, pub fn get_device_proc_addr(&self,
device: vk::Device, device: vk::Device,