Added allocators to the examples

This commit is contained in:
maik klein 2016-12-28 09:24:24 +01:00
parent ce4945a61c
commit 0eaf851afa
3 changed files with 80 additions and 79 deletions

View file

@ -87,7 +87,7 @@ fn main() {
dependency_count: 1, dependency_count: 1,
p_dependencies: &dependency, p_dependencies: &dependency,
}; };
let renderpass = base.device.create_render_pass(&renderpass_create_info).unwrap(); let renderpass = base.device.create_render_pass(&renderpass_create_info, None).unwrap();
let framebuffers: Vec<vk::Framebuffer> = base.present_image_views let framebuffers: Vec<vk::Framebuffer> = base.present_image_views
.iter() .iter()
.map(|&present_image_view| { .map(|&present_image_view| {
@ -103,7 +103,7 @@ fn main() {
height: base.surface_resolution.height, height: base.surface_resolution.height,
layers: 1, layers: 1,
}; };
base.device.create_framebuffer(&frame_buffer_create_info).unwrap() base.device.create_framebuffer(&frame_buffer_create_info, None).unwrap()
}) })
.collect(); .collect();
let index_buffer_data = [0u32, 1, 2, 2, 3, 0]; let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
@ -117,7 +117,7 @@ fn main() {
queue_family_index_count: 0, queue_family_index_count: 0,
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
}; };
let index_buffer = base.device.create_buffer(&index_buffer_info).unwrap(); let index_buffer = base.device.create_buffer(&index_buffer_info, None).unwrap();
let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer); let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer);
let index_buffer_memory_index = find_memorytype_index(&index_buffer_memory_req, let index_buffer_memory_index = find_memorytype_index(&index_buffer_memory_req,
&base.device_memory_properties, &base.device_memory_properties,
@ -129,7 +129,7 @@ fn main() {
allocation_size: index_buffer_memory_req.size, allocation_size: index_buffer_memory_req.size,
memory_type_index: index_buffer_memory_index, memory_type_index: index_buffer_memory_index,
}; };
let index_buffer_memory = base.device.allocate_memory(&index_allocate_info).unwrap(); let index_buffer_memory = base.device.allocate_memory(&index_allocate_info, None).unwrap();
let index_slice = base.device let index_slice = base.device
.map_memory::<u32>(index_buffer_memory, .map_memory::<u32>(index_buffer_memory,
0, 0,
@ -166,7 +166,8 @@ fn main() {
queue_family_index_count: 0, queue_family_index_count: 0,
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
}; };
let vertex_input_buffer = base.device.create_buffer(&vertex_input_buffer_info).unwrap(); let vertex_input_buffer =
base.device.create_buffer(&vertex_input_buffer_info, None).unwrap();
let vertex_input_buffer_memory_req = base.device let vertex_input_buffer_memory_req = base.device
.get_buffer_memory_requirements(vertex_input_buffer); .get_buffer_memory_requirements(vertex_input_buffer);
let vertex_input_buffer_memory_index = let vertex_input_buffer_memory_index =
@ -182,7 +183,7 @@ fn main() {
memory_type_index: vertex_input_buffer_memory_index, memory_type_index: vertex_input_buffer_memory_index,
}; };
let vertex_input_buffer_memory = base.device let vertex_input_buffer_memory = base.device
.allocate_memory(&vertex_buffer_allocate_info) .allocate_memory(&vertex_buffer_allocate_info, None)
.unwrap(); .unwrap();
let slice = base.device let slice = base.device
.map_memory::<Vertex>(vertex_input_buffer_memory, .map_memory::<Vertex>(vertex_input_buffer_memory,
@ -205,7 +206,8 @@ fn main() {
queue_family_index_count: 0, queue_family_index_count: 0,
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
}; };
let uniform_color_buffer = base.device.create_buffer(&uniform_color_buffer_info).unwrap(); let uniform_color_buffer =
base.device.create_buffer(&uniform_color_buffer_info, None).unwrap();
let uniform_color_buffer_memory_req = base.device let uniform_color_buffer_memory_req = base.device
.get_buffer_memory_requirements(uniform_color_buffer); .get_buffer_memory_requirements(uniform_color_buffer);
let uniform_color_buffer_memory_index = let uniform_color_buffer_memory_index =
@ -221,7 +223,7 @@ fn main() {
memory_type_index: uniform_color_buffer_memory_index, memory_type_index: uniform_color_buffer_memory_index,
}; };
let uniform_color_buffer_memory = base.device let uniform_color_buffer_memory = base.device
.allocate_memory(&uniform_color_buffer_allocate_info) .allocate_memory(&uniform_color_buffer_allocate_info, None)
.unwrap(); .unwrap();
let uniform_slice = base.device let uniform_slice = base.device
.map_memory::<f32>(uniform_color_buffer_memory, .map_memory::<f32>(uniform_color_buffer_memory,
@ -248,7 +250,7 @@ fn main() {
queue_family_index_count: 0, queue_family_index_count: 0,
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
}; };
let image_buffer = base.device.create_buffer(&image_buffer_info).unwrap(); let image_buffer = base.device.create_buffer(&image_buffer_info, None).unwrap();
let image_buffer_memory_req = base.device.get_buffer_memory_requirements(image_buffer); let image_buffer_memory_req = base.device.get_buffer_memory_requirements(image_buffer);
let image_buffer_memory_index = find_memorytype_index(&image_buffer_memory_req, let image_buffer_memory_index = find_memorytype_index(&image_buffer_memory_req,
&base.device_memory_properties, &base.device_memory_properties,
@ -261,7 +263,8 @@ fn main() {
allocation_size: image_buffer_memory_req.size, allocation_size: image_buffer_memory_req.size,
memory_type_index: image_buffer_memory_index, memory_type_index: image_buffer_memory_index,
}; };
let image_buffer_memory = base.device.allocate_memory(&image_buffer_allocate_info).unwrap(); let image_buffer_memory =
base.device.allocate_memory(&image_buffer_allocate_info, None).unwrap();
let image_buffer_slice = base.device let image_buffer_slice = base.device
.map_memory::<u8>(image_buffer_memory, .map_memory::<u8>(image_buffer_memory,
0, 0,
@ -293,7 +296,7 @@ fn main() {
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
initial_layout: vk::ImageLayout::Undefined, initial_layout: vk::ImageLayout::Undefined,
}; };
let texture_image = base.device.create_image(&texture_create_info).unwrap(); let texture_image = base.device.create_image(&texture_create_info, None).unwrap();
let texture_memory_req = base.device.get_image_memory_requirements(texture_image); let texture_memory_req = base.device.get_image_memory_requirements(texture_image);
let texture_memory_index = find_memorytype_index(&texture_memory_req, let texture_memory_index = find_memorytype_index(&texture_memory_req,
&base.device_memory_properties, &base.device_memory_properties,
@ -306,7 +309,7 @@ fn main() {
allocation_size: texture_memory_req.size, allocation_size: texture_memory_req.size,
memory_type_index: texture_memory_index, memory_type_index: texture_memory_index,
}; };
let texture_memory = base.device.allocate_memory(&texture_allocate_info).unwrap(); let texture_memory = base.device.allocate_memory(&texture_allocate_info, None).unwrap();
base.device base.device
.bind_image_memory(texture_image, texture_memory, 0) .bind_image_memory(texture_image, texture_memory, 0)
.expect("Unable to bind depth image memory"); .expect("Unable to bind depth image memory");
@ -416,7 +419,7 @@ fn main() {
unnormalized_coordinates: 0, unnormalized_coordinates: 0,
}; };
let sampler = base.device.create_sampler(&sampler_info).unwrap(); let sampler = base.device.create_sampler(&sampler_info, None).unwrap();
let tex_image_view_info = vk::ImageViewCreateInfo { let tex_image_view_info = vk::ImageViewCreateInfo {
s_type: vk::StructureType::ImageViewCreateInfo, s_type: vk::StructureType::ImageViewCreateInfo,
@ -439,7 +442,7 @@ fn main() {
}, },
image: texture_image, image: texture_image,
}; };
let tex_image_view = base.device.create_image_view(&tex_image_view_info).unwrap(); let tex_image_view = base.device.create_image_view(&tex_image_view_info, None).unwrap();
let descriptor_sizes = [vk::DescriptorPoolSize { let descriptor_sizes = [vk::DescriptorPoolSize {
typ: vk::DescriptorType::UniformBuffer, typ: vk::DescriptorType::UniformBuffer,
descriptor_count: 1, descriptor_count: 1,
@ -456,7 +459,8 @@ fn main() {
p_pool_sizes: descriptor_sizes.as_ptr(), p_pool_sizes: descriptor_sizes.as_ptr(),
max_sets: 1, max_sets: 1,
}; };
let descriptor_pool = base.device.create_descriptor_pool(&descriptor_pool_info).unwrap(); let descriptor_pool =
base.device.create_descriptor_pool(&descriptor_pool_info, None).unwrap();
let desc_layout_bindings = [vk::DescriptorSetLayoutBinding { let desc_layout_bindings = [vk::DescriptorSetLayoutBinding {
binding: 0, binding: 0,
descriptor_type: vk::DescriptorType::UniformBuffer, descriptor_type: vk::DescriptorType::UniformBuffer,
@ -481,7 +485,7 @@ fn main() {
let desc_set_layouts = let desc_set_layouts =
[base.device.create_descriptor_set_layout(&descriptor_info).unwrap()]; [base.device.create_descriptor_set_layout(&descriptor_info, None).unwrap()];
let desc_alloc_info = vk::DescriptorSetAllocateInfo { let desc_alloc_info = vk::DescriptorSetAllocateInfo {
s_type: vk::StructureType::DescriptorSetAllocateInfo, s_type: vk::StructureType::DescriptorSetAllocateInfo,
p_next: ptr::null(), p_next: ptr::null(),
@ -551,11 +555,11 @@ fn main() {
p_code: frag_bytes.as_ptr() as *const u32, p_code: frag_bytes.as_ptr() as *const u32,
}; };
let vertex_shader_module = base.device let vertex_shader_module = base.device
.create_shader_module(&vertex_shader_info) .create_shader_module(&vertex_shader_info, None)
.expect("Vertex shader module error"); .expect("Vertex shader module error");
let fragment_shader_module = base.device let fragment_shader_module = base.device
.create_shader_module(&frag_shader_info) .create_shader_module(&frag_shader_info, None)
.expect("Fragment shader module error"); .expect("Fragment shader module error");
let layout_create_info = vk::PipelineLayoutCreateInfo { let layout_create_info = vk::PipelineLayoutCreateInfo {
@ -568,7 +572,8 @@ fn main() {
p_push_constant_ranges: ptr::null(), p_push_constant_ranges: ptr::null(),
}; };
let pipeline_layout = base.device.create_pipeline_layout(&layout_create_info).unwrap(); let pipeline_layout =
base.device.create_pipeline_layout(&layout_create_info, None).unwrap();
let shader_entry_name = CString::new("main").unwrap(); let shader_entry_name = CString::new("main").unwrap();
let shader_stage_create_infos = let shader_stage_create_infos =
@ -744,7 +749,7 @@ fn main() {
base_pipeline_index: 0, base_pipeline_index: 0,
}; };
let graphics_pipelines = base.device let graphics_pipelines = base.device
.create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info]) .create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info], None)
.unwrap(); .unwrap();
let graphic_pipeline = graphics_pipelines[0]; let graphic_pipeline = graphics_pipelines[0];
@ -827,18 +832,18 @@ fn main() {
}); });
for pipeline in graphics_pipelines { for pipeline in graphics_pipelines {
base.device.destroy_pipeline(pipeline); base.device.destroy_pipeline(pipeline, None);
} }
base.device.destroy_pipeline_layout(pipeline_layout); base.device.destroy_pipeline_layout(pipeline_layout, None);
base.device.destroy_shader_module(vertex_shader_module); base.device.destroy_shader_module(vertex_shader_module, None);
base.device.destroy_shader_module(fragment_shader_module); base.device.destroy_shader_module(fragment_shader_module, None);
base.device.free_memory(index_buffer_memory); base.device.free_memory(index_buffer_memory, None);
base.device.destroy_buffer(index_buffer); base.device.destroy_buffer(index_buffer, None);
base.device.free_memory(vertex_input_buffer_memory); base.device.free_memory(vertex_input_buffer_memory, None);
base.device.destroy_buffer(vertex_input_buffer); base.device.destroy_buffer(vertex_input_buffer, None);
for framebuffer in framebuffers { for framebuffer in framebuffers {
base.device.destroy_framebuffer(framebuffer); base.device.destroy_framebuffer(framebuffer, None);
} }
base.device.destroy_render_pass(renderpass); base.device.destroy_render_pass(renderpass, None);
} }
} }

View file

@ -86,7 +86,7 @@ fn main() {
dependency_count: 1, dependency_count: 1,
p_dependencies: &dependency, p_dependencies: &dependency,
}; };
let renderpass = base.device.create_render_pass(&renderpass_create_info).unwrap(); let renderpass = base.device.create_render_pass(&renderpass_create_info, None).unwrap();
let framebuffers: Vec<vk::Framebuffer> = base.present_image_views let framebuffers: Vec<vk::Framebuffer> = base.present_image_views
.iter() .iter()
.map(|&present_image_view| { .map(|&present_image_view| {
@ -102,7 +102,7 @@ fn main() {
height: base.surface_resolution.height, height: base.surface_resolution.height,
layers: 1, layers: 1,
}; };
base.device.create_framebuffer(&frame_buffer_create_info).unwrap() base.device.create_framebuffer(&frame_buffer_create_info, None).unwrap()
}) })
.collect(); .collect();
let index_buffer_data = [0u32, 1, 2]; let index_buffer_data = [0u32, 1, 2];
@ -116,7 +116,7 @@ fn main() {
queue_family_index_count: 0, queue_family_index_count: 0,
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
}; };
let index_buffer = base.device.create_buffer(&index_buffer_info).unwrap(); let index_buffer = base.device.create_buffer(&index_buffer_info, None).unwrap();
let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer); let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer);
let index_buffer_memory_index = find_memorytype_index(&index_buffer_memory_req, let index_buffer_memory_index = find_memorytype_index(&index_buffer_memory_req,
&base.device_memory_properties, &base.device_memory_properties,
@ -128,7 +128,7 @@ fn main() {
allocation_size: index_buffer_memory_req.size, allocation_size: index_buffer_memory_req.size,
memory_type_index: index_buffer_memory_index, memory_type_index: index_buffer_memory_index,
}; };
let index_buffer_memory = base.device.allocate_memory(&index_allocate_info).unwrap(); let index_buffer_memory = base.device.allocate_memory(&index_allocate_info, None).unwrap();
let index_slice = base.device let index_slice = base.device
.map_memory::<u32>(index_buffer_memory, .map_memory::<u32>(index_buffer_memory,
0, 0,
@ -149,7 +149,8 @@ fn main() {
queue_family_index_count: 0, queue_family_index_count: 0,
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
}; };
let vertex_input_buffer = base.device.create_buffer(&vertex_input_buffer_info).unwrap(); let vertex_input_buffer =
base.device.create_buffer(&vertex_input_buffer_info, None).unwrap();
let vertex_input_buffer_memory_req = base.device let vertex_input_buffer_memory_req = base.device
.get_buffer_memory_requirements(vertex_input_buffer); .get_buffer_memory_requirements(vertex_input_buffer);
let vertex_input_buffer_memory_index = let vertex_input_buffer_memory_index =
@ -165,7 +166,7 @@ fn main() {
memory_type_index: vertex_input_buffer_memory_index, memory_type_index: vertex_input_buffer_memory_index,
}; };
let vertex_input_buffer_memory = base.device let vertex_input_buffer_memory = base.device
.allocate_memory(&vertex_buffer_allocate_info) .allocate_memory(&vertex_buffer_allocate_info, None)
.unwrap(); .unwrap();
let vertices = [Vertex { let vertices = [Vertex {
pos: [-1.0, 1.0, 0.0, 1.0], pos: [-1.0, 1.0, 0.0, 1.0],
@ -210,11 +211,11 @@ fn main() {
p_code: frag_bytes.as_ptr() as *const u32, p_code: frag_bytes.as_ptr() as *const u32,
}; };
let vertex_shader_module = base.device let vertex_shader_module = base.device
.create_shader_module(&vertex_shader_info) .create_shader_module(&vertex_shader_info, None)
.expect("Vertex shader module error"); .expect("Vertex shader module error");
let fragment_shader_module = base.device let fragment_shader_module = base.device
.create_shader_module(&frag_shader_info) .create_shader_module(&frag_shader_info, None)
.expect("Fragment shader module error"); .expect("Fragment shader module error");
let layout_create_info = vk::PipelineLayoutCreateInfo { let layout_create_info = vk::PipelineLayoutCreateInfo {
@ -227,7 +228,8 @@ fn main() {
p_push_constant_ranges: ptr::null(), p_push_constant_ranges: ptr::null(),
}; };
let pipeline_layout = base.device.create_pipeline_layout(&layout_create_info).unwrap(); let pipeline_layout =
base.device.create_pipeline_layout(&layout_create_info, None).unwrap();
let shader_entry_name = CString::new("main").unwrap(); let shader_entry_name = CString::new("main").unwrap();
let shader_stage_create_infos = let shader_stage_create_infos =
@ -403,7 +405,7 @@ fn main() {
base_pipeline_index: 0, base_pipeline_index: 0,
}; };
let graphics_pipelines = base.device let graphics_pipelines = base.device
.create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info]) .create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info], None)
.unwrap(); .unwrap();
let graphic_pipeline = graphics_pipelines[0]; let graphic_pipeline = graphics_pipelines[0];
@ -480,18 +482,18 @@ fn main() {
}); });
for pipeline in graphics_pipelines { for pipeline in graphics_pipelines {
base.device.destroy_pipeline(pipeline); base.device.destroy_pipeline(pipeline, None);
} }
base.device.destroy_pipeline_layout(pipeline_layout); base.device.destroy_pipeline_layout(pipeline_layout, None);
base.device.destroy_shader_module(vertex_shader_module); base.device.destroy_shader_module(vertex_shader_module, None);
base.device.destroy_shader_module(fragment_shader_module); base.device.destroy_shader_module(fragment_shader_module, None);
base.device.free_memory(index_buffer_memory); base.device.free_memory(index_buffer_memory, None);
base.device.destroy_buffer(index_buffer); base.device.destroy_buffer(index_buffer, None);
base.device.free_memory(vertex_input_buffer_memory); base.device.free_memory(vertex_input_buffer_memory, None);
base.device.destroy_buffer(vertex_input_buffer); base.device.destroy_buffer(vertex_input_buffer, None);
for framebuffer in framebuffers { for framebuffer in framebuffers {
base.device.destroy_framebuffer(framebuffer); base.device.destroy_framebuffer(framebuffer, None);
} }
base.device.destroy_render_pass(renderpass); base.device.destroy_render_pass(renderpass, None);
} }
} }

View file

@ -57,7 +57,8 @@ pub fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(device
p_next: ptr::null(), p_next: ptr::null(),
flags: vk::FenceCreateFlags::empty(), flags: vk::FenceCreateFlags::empty(),
}; };
let submit_fence = device.create_fence(&fence_create_info).expect("Create fence failed."); let submit_fence = device.create_fence(&fence_create_info, None)
.expect("Create fence failed.");
let submit_info = vk::SubmitInfo { let submit_info = vk::SubmitInfo {
s_type: vk::StructureType::SubmitInfo, s_type: vk::StructureType::SubmitInfo,
p_next: ptr::null(), p_next: ptr::null(),
@ -73,7 +74,7 @@ pub fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(device
.expect("queue submit failed."); .expect("queue submit failed.");
device.wait_for_fences(&[submit_fence], true, std::u64::MAX) device.wait_for_fences(&[submit_fence], true, std::u64::MAX)
.expect("Wait for fence failed."); .expect("Wait for fence failed.");
device.destroy_fence(submit_fence); device.destroy_fence(submit_fence, None);
} }
} }
@ -119,20 +120,12 @@ fn create_surface(instance: &Instance,
#[cfg(all(unix, not(target_os = "android")))] #[cfg(all(unix, not(target_os = "android")))]
fn extension_names() -> Vec<*const i8> { fn extension_names() -> Vec<*const i8> {
vec![ vec![Surface::name().as_ptr(), XlibSurface::name().as_ptr(), DebugReport::name().as_ptr()]
Surface::name().as_ptr(),
XlibSurface::name().as_ptr(),
DebugReport::name().as_ptr()
]
} }
#[cfg(all(windows))] #[cfg(all(windows))]
fn extension_names() -> Vec<*const i8> { fn extension_names() -> Vec<*const i8> {
vec![ vec![Surface::name().as_ptr(), Win32Surface::name().as_ptr(), DebugReport::name().as_ptr()]
Surface::name().as_ptr(),
Win32Surface::name().as_ptr(),
DebugReport::name().as_ptr()
]
} }
unsafe extern "system" fn vulkan_debug_callback(_: vk::DebugReportFlagsEXT, unsafe extern "system" fn vulkan_debug_callback(_: vk::DebugReportFlagsEXT,
@ -313,7 +306,7 @@ impl ExampleBase {
pp_enabled_extension_names: device_extension_names_raw.as_ptr(), pp_enabled_extension_names: device_extension_names_raw.as_ptr(),
p_enabled_features: &features, p_enabled_features: &features,
}; };
let device: Device = instance.create_device(pdevice, &device_create_info) let device: Device = instance.create_device(pdevice, &device_create_info, None)
.unwrap(); .unwrap();
let present_queue = device.get_device_queue(queue_family_index as u32, 0); let present_queue = device.get_device_queue(queue_family_index as u32, 0);
@ -393,7 +386,7 @@ impl ExampleBase {
flags: vk::COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, flags: vk::COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
queue_family_index: queue_family_index, queue_family_index: queue_family_index,
}; };
let pool = device.create_command_pool(&pool_create_info).unwrap(); let pool = device.create_command_pool(&pool_create_info, None).unwrap();
let command_buffer_allocate_info = vk::CommandBufferAllocateInfo { let command_buffer_allocate_info = vk::CommandBufferAllocateInfo {
s_type: vk::StructureType::CommandBufferAllocateInfo, s_type: vk::StructureType::CommandBufferAllocateInfo,
p_next: ptr::null(), p_next: ptr::null(),
@ -430,7 +423,7 @@ impl ExampleBase {
}, },
image: image, image: image,
}; };
device.create_image_view(&create_view_info).unwrap() device.create_image_view(&create_view_info, None).unwrap()
}) })
.collect(); .collect();
let device_memory_properties = instance.get_physical_device_memory_properties(pdevice); let device_memory_properties = instance.get_physical_device_memory_properties(pdevice);
@ -455,7 +448,7 @@ impl ExampleBase {
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
initial_layout: vk::ImageLayout::Undefined, initial_layout: vk::ImageLayout::Undefined,
}; };
let depth_image = device.create_image(&depth_image_create_info).unwrap(); let depth_image = device.create_image(&depth_image_create_info, None).unwrap();
let depth_image_memory_req = device.get_image_memory_requirements(depth_image); let depth_image_memory_req = device.get_image_memory_requirements(depth_image);
let depth_image_memory_index = let depth_image_memory_index =
find_memorytype_index(&depth_image_memory_req, find_memorytype_index(&depth_image_memory_req,
@ -469,7 +462,8 @@ impl ExampleBase {
allocation_size: depth_image_memory_req.size, allocation_size: depth_image_memory_req.size,
memory_type_index: depth_image_memory_index, memory_type_index: depth_image_memory_index,
}; };
let depth_image_memory = device.allocate_memory(&depth_image_allocate_info).unwrap(); let depth_image_memory = device.allocate_memory(&depth_image_allocate_info, None)
.unwrap();
device.bind_image_memory(depth_image, depth_image_memory, 0) device.bind_image_memory(depth_image, depth_image_memory, 0)
.expect("Unable to bind depth image memory"); .expect("Unable to bind depth image memory");
@ -512,7 +506,7 @@ impl ExampleBase {
p_next: ptr::null(), p_next: ptr::null(),
flags: vk::FenceCreateFlags::empty(), flags: vk::FenceCreateFlags::empty(),
}; };
let submit_fence = device.create_fence(&fence_create_info).unwrap(); let submit_fence = device.create_fence(&fence_create_info, None).unwrap();
let submit_info = vk::SubmitInfo { let submit_info = vk::SubmitInfo {
s_type: vk::StructureType::SubmitInfo, s_type: vk::StructureType::SubmitInfo,
p_next: ptr::null(), p_next: ptr::null(),
@ -548,15 +542,15 @@ impl ExampleBase {
}, },
image: depth_image, image: depth_image,
}; };
let depth_image_view = device.create_image_view(&depth_image_view_info).unwrap(); let depth_image_view = device.create_image_view(&depth_image_view_info, None).unwrap();
let semaphore_create_info = vk::SemaphoreCreateInfo { let semaphore_create_info = vk::SemaphoreCreateInfo {
s_type: vk::StructureType::SemaphoreCreateInfo, s_type: vk::StructureType::SemaphoreCreateInfo,
p_next: ptr::null(), p_next: ptr::null(),
flags: Default::default(), flags: Default::default(),
}; };
let present_complete_semaphore = device.create_semaphore(&semaphore_create_info) let present_complete_semaphore = device.create_semaphore(&semaphore_create_info, None)
.unwrap(); .unwrap();
let rendering_complete_semaphore = device.create_semaphore(&semaphore_create_info) let rendering_complete_semaphore = device.create_semaphore(&semaphore_create_info, None)
.unwrap(); .unwrap();
ExampleBase { ExampleBase {
entry: entry, entry: entry,
@ -593,17 +587,17 @@ impl Drop for ExampleBase {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
self.device.device_wait_idle().unwrap(); self.device.device_wait_idle().unwrap();
self.device.destroy_semaphore(self.present_complete_semaphore); self.device.destroy_semaphore(self.present_complete_semaphore, None);
self.device.destroy_semaphore(self.rendering_complete_semaphore); self.device.destroy_semaphore(self.rendering_complete_semaphore, None);
self.device.destroy_image_view(self.depth_image_view); self.device.destroy_image_view(self.depth_image_view, None);
self.device.destroy_image(self.depth_image); self.device.destroy_image(self.depth_image, None);
self.device.free_memory(self.depth_image_memory); self.device.free_memory(self.depth_image_memory, None);
for &image_view in self.present_image_views.iter() { for &image_view in self.present_image_views.iter() {
self.device.destroy_image_view(image_view); self.device.destroy_image_view(image_view, None);
} }
self.device.destroy_command_pool(self.pool); self.device.destroy_command_pool(self.pool, None);
self.swapchain_loader.destroy_swapchain_khr(self.swapchain); self.swapchain_loader.destroy_swapchain_khr(self.swapchain);
self.device.destroy_device(); self.device.destroy_device(None);
self.surface_loader.destroy_surface_khr(self.surface); self.surface_loader.destroy_surface_khr(self.surface);
self.debug_report_loader.destroy_debug_report_callback_ext(self.debug_call_back); self.debug_report_loader.destroy_debug_report_callback_ext(self.debug_call_back);
self.instance.destroy_instance(); self.instance.destroy_instance();