Marks all functions that take an allocator as 'unsafe'

This commit is contained in:
maik klein 2016-12-28 10:20:12 +01:00
parent 3db84ba1eb
commit e6415a91df
7 changed files with 98 additions and 80 deletions

View file

@ -144,10 +144,10 @@ impl Device {
descriptor_copies.as_ptr()); descriptor_copies.as_ptr());
} }
pub fn create_sampler(&self, pub unsafe fn create_sampler(&self,
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 { unsafe {
let mut sampler = mem::uninitialized(); let mut sampler = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -219,7 +219,7 @@ impl Device {
} }
} }
pub fn create_descriptor_set_layout(&self, pub unsafe fn create_descriptor_set_layout(&self,
create_info: &vk::DescriptorSetLayoutCreateInfo, create_info: &vk::DescriptorSetLayoutCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::DescriptorSetLayout> { -> VkResult<vk::DescriptorSetLayout> {
@ -247,10 +247,10 @@ impl Device {
} }
} }
pub fn create_descriptor_pool(&self, pub unsafe fn create_descriptor_pool(&self,
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 { unsafe {
let mut pool = mem::uninitialized(); let mut pool = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -388,10 +388,10 @@ impl Device {
viewports.as_ptr()); viewports.as_ptr());
} }
pub fn create_semaphore(&self, pub unsafe fn create_semaphore(&self,
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 { unsafe {
let mut semaphore = mem::uninitialized(); let mut semaphore = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -406,7 +406,7 @@ impl Device {
} }
} }
pub 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>)
@ -428,10 +428,10 @@ impl Device {
} }
} }
pub 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 { unsafe {
let mut buffer = mem::uninitialized(); let mut buffer = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -505,10 +505,10 @@ impl Device {
} }
} }
pub fn get_device_queue(&self, pub unsafe fn get_device_queue(&self,
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 { unsafe {
let mut queue = mem::uninitialized(); let mut queue = mem::uninitialized();
self.device_fn self.device_fn
@ -537,10 +537,10 @@ impl Device {
image_memory_barriers.as_ptr()); image_memory_barriers.as_ptr());
} }
pub fn create_render_pass(&self, pub unsafe fn create_render_pass(&self,
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 { unsafe {
let mut renderpass = mem::uninitialized(); let mut renderpass = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -576,11 +576,11 @@ impl Device {
} }
} }
pub fn wait_for_fences(&self, pub unsafe fn wait_for_fences(&self,
fences: &[vk::Fence], fences: &[vk::Fence],
wait_all: bool, wait_all: bool,
timeout: vk::uint64_t) timeout: vk::uint64_t)
-> VkResult<()> { -> VkResult<()> {
unsafe { unsafe {
let err_code = self.device_fn let err_code = self.device_fn
.wait_for_fences(self.handle, .wait_for_fences(self.handle,
@ -595,7 +595,7 @@ impl Device {
} }
} }
pub fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> { pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
unsafe { 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 {
@ -633,10 +633,10 @@ impl Device {
} }
} }
pub fn create_image_view(&self, pub unsafe fn create_image_view(&self,
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 { 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
@ -665,10 +665,10 @@ impl Device {
} }
} }
pub fn create_command_pool(&self, pub unsafe fn create_command_pool(&self,
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 { unsafe {
let mut pool = mem::uninitialized(); let mut pool = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -683,10 +683,10 @@ impl Device {
} }
} }
pub 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 { unsafe {
let mut image = mem::uninitialized(); let mut image = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -719,10 +719,10 @@ impl Device {
} }
} }
pub fn allocate_memory(&self, pub unsafe fn allocate_memory(&self,
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 { unsafe {
let mut memory = mem::uninitialized(); let mut memory = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -737,10 +737,10 @@ impl Device {
} }
} }
pub 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 { unsafe {
let mut shader = mem::uninitialized(); let mut shader = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -755,10 +755,10 @@ impl Device {
} }
} }
pub 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 { unsafe {
let mut fence = mem::uninitialized(); let mut fence = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn

View file

@ -5,6 +5,7 @@ use vk;
use instance::Instance; use instance::Instance;
use shared_library::dynamic_library::DynamicLibrary; use shared_library::dynamic_library::DynamicLibrary;
use std::path::Path; use std::path::Path;
use ::RawPtr;
#[cfg(windows)] #[cfg(windows)]
fn get_path() -> &'static Path { fn get_path() -> &'static Path {
@ -73,7 +74,6 @@ impl Entry {
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> Result<Instance, InstanceError> { -> Result<Instance, InstanceError> {
unsafe { unsafe {
use ::RawPtr;
let mut instance: vk::Instance = mem::uninitialized(); let mut instance: vk::Instance = mem::uninitialized();
let err_code = self.entry_fn.create_instance(create_info, let err_code = self.entry_fn.create_instance(create_info,
allocation_callbacks.as_raw_ptr(), allocation_callbacks.as_raw_ptr(),

View file

@ -5,6 +5,7 @@ use instance::Instance;
use entry::Entry; use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr;
pub struct DebugReport { pub struct DebugReport {
handle: vk::Instance, handle: vk::Instance,
@ -24,23 +25,25 @@ impl DebugReport {
}) })
} }
pub fn name() -> &'static CStr{ pub fn name() -> &'static CStr {
CStr::from_bytes_with_nul(b"VK_EXT_debug_report\0").expect("Wrong extension string") CStr::from_bytes_with_nul(b"VK_EXT_debug_report\0").expect("Wrong extension string")
} }
pub unsafe fn destroy_debug_report_callback_ext(&self, debug: vk::DebugReportCallbackEXT) { pub unsafe fn destroy_debug_report_callback_ext(&self, debug: vk::DebugReportCallbackEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.debug_report_fn.destroy_debug_report_callback_ext(self.handle, debug, ptr::null()); self.debug_report_fn.destroy_debug_report_callback_ext(self.handle,
debug,
allocation_callbacks.as_raw_ptr());
} }
pub fn create_debug_report_callback_ext(&self, pub unsafe fn create_debug_report_callback_ext(&self,
create_info: &vk::DebugReportCallbackCreateInfoEXT) create_info: &vk::DebugReportCallbackCreateInfoEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::DebugReportCallbackEXT> { -> VkResult<vk::DebugReportCallbackEXT> {
unsafe { 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,
create_info, create_info,
ptr::null(), allocation_callbacks.as_raw_ptr(),
&mut debug_cb); &mut debug_cb);
match err_code { match err_code {
vk::Result::Success => Ok(debug_cb), vk::Result::Success => Ok(debug_cb),

View file

@ -5,6 +5,7 @@ use instance::Instance;
use device::Device; use device::Device;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr;
pub struct Swapchain { pub struct Swapchain {
handle: vk::Device, handle: vk::Device,
@ -22,12 +23,15 @@ impl Swapchain {
}) })
} }
pub fn name() -> &'static CStr{ pub fn name() -> &'static CStr {
CStr::from_bytes_with_nul(b"VK_KHR_swapchain\0").expect("Wrong extension string") CStr::from_bytes_with_nul(b"VK_KHR_swapchain\0").expect("Wrong extension string")
} }
pub unsafe fn destroy_swapchain_khr(&self, swapchain: vk::SwapchainKHR) { pub unsafe fn destroy_swapchain_khr(&self,
self.swapchain_fn.destroy_swapchain_khr(self.handle, swapchain, ptr::null()); swapchain: vk::SwapchainKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.swapchain_fn
.destroy_swapchain_khr(self.handle, swapchain, allocation_callbacks.as_raw_ptr());
} }
pub unsafe fn acquire_next_image_khr(&self, pub unsafe fn acquire_next_image_khr(&self,
@ -50,13 +54,17 @@ impl Swapchain {
} }
} }
pub fn create_swapchain_khr(&self, pub unsafe fn create_swapchain_khr(&self,
create_info: &vk::SwapchainCreateInfoKHR) create_info: &vk::SwapchainCreateInfoKHR,
-> VkResult<vk::SwapchainKHR> { allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SwapchainKHR> {
unsafe { 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_info, ptr::null(), &mut swapchain); .create_swapchain_khr(self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut swapchain);
match err_code { match err_code {
vk::Result::Success => Ok(swapchain), vk::Result::Success => Ok(swapchain),
_ => Err(err_code), _ => Err(err_code),

View file

@ -5,6 +5,7 @@ use instance::Instance;
use entry::Entry; use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr;
pub struct Win32Surface { pub struct Win32Surface {
pub handle: vk::Instance, pub handle: vk::Instance,
@ -24,17 +25,21 @@ impl Win32Surface {
}) })
} }
pub fn name() -> &'static CStr{ pub fn name() -> &'static CStr {
CStr::from_bytes_with_nul(b"VK_KHR_win32_surface\0").expect("Wrong extension string") CStr::from_bytes_with_nul(b"VK_KHR_win32_surface\0").expect("Wrong extension string")
} }
pub fn create_win32_surface_khr(&self, pub unsafe fn create_win32_surface_khr(&self,
create_info: &vk::Win32SurfaceCreateInfoKHR) create_info: &vk::Win32SurfaceCreateInfoKHR,
-> VkResult<vk::SurfaceKHR> { allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SurfaceKHR> {
unsafe { 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_info, ptr::null(), &mut surface); .create_win32_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

@ -5,6 +5,7 @@ use instance::Instance;
use entry::Entry; use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr;
pub struct XlibSurface { pub struct XlibSurface {
pub handle: vk::Instance, pub handle: vk::Instance,
@ -24,17 +25,18 @@ impl XlibSurface {
}) })
} }
pub fn name() -> &'static CStr{ pub fn name() -> &'static CStr {
CStr::from_bytes_with_nul(b"VK_KHR_xlib_surface\0").expect("Wrong extension string") CStr::from_bytes_with_nul(b"VK_KHR_xlib_surface\0").expect("Wrong extension string")
} }
pub fn create_xlib_surface_khr(&self, pub unsafe fn create_xlib_surface_khr(&self,
create_info: &vk::XlibSurfaceCreateInfoKHR) create_info: &vk::XlibSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SurfaceKHR> { -> VkResult<vk::SurfaceKHR> {
unsafe { 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, ptr::null(), &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

@ -30,7 +30,7 @@ impl Instance {
} }
} }
pub fn create_device(&self, pub unsafe fn create_device(&self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
create_info: &vk::DeviceCreateInfo, create_info: &vk::DeviceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)