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

View file

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

View file

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

View file

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

View file

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

View file

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