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,7 +144,7 @@ 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> {
@ -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,7 +247,7 @@ 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> {
@ -388,7 +388,7 @@ 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> {
@ -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,7 +428,7 @@ 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> {
@ -505,7 +505,7 @@ 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 {
@ -537,7 +537,7 @@ 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> {
@ -576,7 +576,7 @@ 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)
@ -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,7 +633,7 @@ 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> {
@ -665,7 +665,7 @@ 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> {
@ -683,7 +683,7 @@ 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> {
@ -719,7 +719,7 @@ 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> {
@ -737,7 +737,7 @@ 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> {
@ -755,7 +755,7 @@ 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> {

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,
allocation_callbacks: Option<&vk::AllocationCallbacks>)
-> VkResult<vk::SwapchainKHR> { -> 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,
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.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>)