Remove unused unsafe blocks
This commit is contained in:
parent
b49b2b1deb
commit
519a0f0038
307
src/device.rs
307
src/device.rs
|
@ -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,17 +147,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut sampler);
|
||||||
&mut sampler);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(sampler),
|
||||||
vk::Result::Success => Ok(sampler),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,17 +220,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut layout);
|
||||||
&mut layout);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(layout),
|
||||||
vk::Result::Success => Ok(layout),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,17 +246,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut pool);
|
||||||
&mut pool);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(pool),
|
||||||
vk::Result::Success => Ok(pool),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,17 +385,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut semaphore);
|
||||||
&mut semaphore);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(semaphore),
|
||||||
vk::Result::Success => Ok(semaphore),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,20 +402,18 @@ impl Device {
|
||||||
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,
|
pipeline_cache,
|
||||||
pipeline_cache,
|
create_infos.len() as vk::uint32_t,
|
||||||
create_infos.len() as vk::uint32_t,
|
create_infos.as_ptr(),
|
||||||
create_infos.as_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
pipelines.as_mut_ptr());
|
||||||
pipelines.as_mut_ptr());
|
pipelines.set_len(create_infos.len());
|
||||||
pipelines.set_len(create_infos.len());
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(pipelines),
|
||||||
vk::Result::Success => Ok(pipelines),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,17 +421,15 @@ impl Device {
|
||||||
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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut buffer);
|
||||||
&mut buffer);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(buffer),
|
||||||
vk::Result::Success => Ok(buffer),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,12 +496,10 @@ 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,
|
||||||
|
@ -541,17 +526,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut renderpass);
|
||||||
&mut renderpass);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(renderpass),
|
||||||
vk::Result::Success => Ok(renderpass),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,27 +564,23 @@ 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,
|
fences.as_ptr(),
|
||||||
fences.as_ptr(),
|
wait_all as vk::uint32_t,
|
||||||
wait_all as vk::uint32_t,
|
timeout);
|
||||||
timeout);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(()),
|
||||||
vk::Result::Success => Ok(()),
|
_ => 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),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,17 +616,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut image_view);
|
||||||
&mut image_view);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(image_view),
|
||||||
vk::Result::Success => Ok(image_view),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,17 +646,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut pool);
|
||||||
&mut pool);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(pool),
|
||||||
vk::Result::Success => Ok(pool),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,17 +662,15 @@ impl Device {
|
||||||
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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut image);
|
||||||
&mut image);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(image),
|
||||||
vk::Result::Success => Ok(image),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,17 +696,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut memory);
|
||||||
&mut memory);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(memory),
|
||||||
vk::Result::Success => Ok(memory),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,17 +712,15 @@ impl Device {
|
||||||
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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut shader);
|
||||||
&mut shader);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(shader),
|
||||||
vk::Result::Success => Ok(shader),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,17 +728,15 @@ impl Device {
|
||||||
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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut fence);
|
||||||
&mut fence);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(fence),
|
||||||
vk::Result::Success => Ok(fence),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,17 +37,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
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),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,17 +58,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut swapchain);
|
||||||
&mut swapchain);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(swapchain),
|
||||||
vk::Result::Success => Ok(swapchain),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,17 +32,15 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut surface);
|
||||||
&mut surface);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::Success => Ok(surface),
|
||||||
vk::Result::Success => Ok(surface),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -30,17 +29,18 @@ impl XlibSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe 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>)
|
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_xlib_surface_khr(self.handle, create_info, allocation_callbacks.as_raw_ptr(), &mut surface);
|
create_info,
|
||||||
match err_code {
|
allocation_callbacks.as_raw_ptr(),
|
||||||
vk::Result::Success => Ok(surface),
|
&mut surface);
|
||||||
_ => Err(err_code),
|
match err_code {
|
||||||
}
|
vk::Result::Success => Ok(surface),
|
||||||
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,21 +35,19 @@ 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,
|
create_info,
|
||||||
create_info,
|
allocation_callbacks.as_raw_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
&mut device);
|
||||||
&mut device);
|
if err_code != vk::Result::Success {
|
||||||
if err_code != vk::Result::Success {
|
return Err(DeviceError::VkError(err_code));
|
||||||
return Err(DeviceError::VkError(err_code));
|
|
||||||
}
|
|
||||||
let device_fn = vk::DeviceFn::load(|name| {
|
|
||||||
mem::transmute(self.instance_fn.get_device_proc_addr(device, name.as_ptr()))
|
|
||||||
}).map_err(|err| DeviceError::LoadError(err))?;
|
|
||||||
Ok(Device::from_raw(device, device_fn))
|
|
||||||
}
|
}
|
||||||
|
let device_fn = vk::DeviceFn::load(|name| {
|
||||||
|
mem::transmute(self.instance_fn.get_device_proc_addr(device, name.as_ptr()))
|
||||||
|
}).map_err(|err| DeviceError::LoadError(err))?;
|
||||||
|
Ok(Device::from_raw(device, device_fn))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_device_proc_addr(&self,
|
pub fn get_device_proc_addr(&self,
|
||||||
|
|
Loading…
Reference in a new issue