Adjust lib.rs for examples

This commit is contained in:
Tim 2018-07-31 12:45:29 +02:00
parent f04df1e1df
commit 7c8ab2a876

View file

@ -43,14 +43,14 @@ pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffe
device
.reset_command_buffer(
command_buffer,
vk::COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT,
vk::CommandBufferResetFlags::RELEASE_RESOURCES,
)
.expect("Reset command buffer failed.");
let command_buffer_begin_info = vk::CommandBufferBeginInfo {
s_type: vk::StructureType::CommandBufferBeginInfo,
s_type: vk::StructureType::COMMAND_BUFFER_BEGIN_INFO,
p_next: ptr::null(),
p_inheritance_info: ptr::null(),
flags: vk::COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
flags: vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT,
};
device
.begin_command_buffer(command_buffer, &command_buffer_begin_info)
@ -60,7 +60,7 @@ pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffe
.end_command_buffer(command_buffer)
.expect("End commandbuffer");
let fence_create_info = vk::FenceCreateInfo {
s_type: vk::StructureType::FenceCreateInfo,
s_type: vk::StructureType::FENCE_CREATE_INFO,
p_next: ptr::null(),
flags: vk::FenceCreateFlags::empty(),
};
@ -68,7 +68,7 @@ pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffe
.create_fence(&fence_create_info, None)
.expect("Create fence failed.");
let submit_info = vk::SubmitInfo {
s_type: vk::StructureType::SubmitInfo,
s_type: vk::StructureType::SUBMIT_INFO,
p_next: ptr::null(),
wait_semaphore_count: wait_semaphores.len() as u32,
p_wait_semaphores: wait_semaphores.as_ptr(),
@ -98,7 +98,7 @@ unsafe fn create_surface<E: EntryV1_0, I: InstanceV1_0>(
let x11_display = window.get_xlib_display().unwrap();
let x11_window = window.get_xlib_window().unwrap();
let x11_create_info = vk::XlibSurfaceCreateInfoKHR {
s_type: vk::StructureType::XlibSurfaceCreateInfoKhr,
s_type: vk::StructureType::XLIB_SURFACE_CREATE_INFO_KHR,
p_next: ptr::null(),
flags: Default::default(),
window: x11_window as vk::Window,
@ -280,7 +280,7 @@ impl ExampleBase {
let extension_names_raw = extension_names();
let appinfo = vk::ApplicationInfo {
p_application_name: raw_name,
s_type: vk::StructureType::ApplicationInfo,
s_type: vk::StructureType::APPLICATION_INFO,
p_next: ptr::null(),
application_version: 0,
p_engine_name: raw_name,
@ -288,7 +288,7 @@ impl ExampleBase {
api_version: vk_make_version!(1, 0, 36),
};
let create_info = vk::InstanceCreateInfo {
s_type: vk::StructureType::InstanceCreateInfo,
s_type: vk::StructureType::INSTANCE_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
p_application_info: &appinfo,
@ -301,10 +301,10 @@ impl ExampleBase {
.create_instance(&create_info, None)
.expect("Instance creation error");
let debug_info = vk::DebugReportCallbackCreateInfoEXT {
s_type: vk::StructureType::DebugReportCallbackCreateInfoExt,
s_type: vk::StructureType::DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
p_next: ptr::null(),
flags: vk::DEBUG_REPORT_ERROR_BIT_EXT | vk::DEBUG_REPORT_WARNING_BIT_EXT
| vk::DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
flags: vk::DebugReportFlagsEXT::ERROR | vk::DebugReportFlagsEXT::WARNING
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING,
pfn_callback: vulkan_debug_callback,
p_user_data: ptr::null_mut(),
};
@ -328,7 +328,7 @@ impl ExampleBase {
.enumerate()
.filter_map(|(index, ref info)| {
let supports_graphic_and_surface = info.queue_flags
.subset(vk::QUEUE_GRAPHICS_BIT)
.subset(vk::QueueFlags::GRAPHICS)
&& surface_loader.get_physical_device_surface_support_khr(
*pdevice,
index as u32,
@ -352,7 +352,7 @@ impl ExampleBase {
};
let priorities = [1.0];
let queue_info = vk::DeviceQueueCreateInfo {
s_type: vk::StructureType::DeviceQueueCreateInfo,
s_type: vk::StructureType::DEVICE_QUEUE_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
queue_family_index: queue_family_index as u32,
@ -360,7 +360,7 @@ impl ExampleBase {
queue_count: priorities.len() as u32,
};
let device_create_info = vk::DeviceCreateInfo {
s_type: vk::StructureType::DeviceCreateInfo,
s_type: vk::StructureType::DEVICE_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
queue_create_info_count: 1,
@ -382,8 +382,8 @@ impl ExampleBase {
let surface_format = surface_formats
.iter()
.map(|sfmt| match sfmt.format {
vk::Format:: => vk::SurfaceFormatKHR {
format: vk::Format::B8g8r8Unorm,
vk::Format::UNDEFINED => vk::SurfaceFormatKHR {
format: vk::Format::B8G8R8_UNORM,
color_space: sfmt.color_space,
},
_ => sfmt.clone(),
@ -408,9 +408,9 @@ impl ExampleBase {
};
let pre_transform = if surface_capabilities
.supported_transforms
.subset(vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
.subset(vk::SurfaceTransformFlagsKHR::IDENTITY)
{
vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR
vk::SurfaceTransformFlagsKHR::IDENTITY
} else {
surface_capabilities.current_transform
};
@ -420,12 +420,12 @@ impl ExampleBase {
let present_mode = present_modes
.iter()
.cloned()
.find(|&mode| mode == vk::PresentModeKHR::Mailbox)
.unwrap_or(vk::PresentModeKHR::Fifo);
.find(|&mode| mode == vk::PresentModeKHR::MAILBOX)
.unwrap_or(vk::PresentModeKHR::FIFO);
let swapchain_loader =
Swapchain::new(&instance, &device).expect("Unable to load swapchain");
let swapchain_create_info = vk::SwapchainCreateInfoKHR {
s_type: vk::StructureType::SwapchainCreateInfoKhr,
s_type: vk::StructureType::SWAPCHAIN_CREATE_INFO_KHR,
p_next: ptr::null(),
flags: Default::default(),
surface: surface,
@ -433,10 +433,10 @@ impl ExampleBase {
image_color_space: surface_format.color_space,
image_format: surface_format.format,
image_extent: surface_resolution.clone(),
image_usage: vk::IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
image_sharing_mode: vk::SharingMode::Exclusive,
image_usage: vk::ImageUsageFlags::COLOR_ATTACHMENT,
image_sharing_mode: vk::SharingMode::EXCLUSIVE,
pre_transform: pre_transform,
composite_alpha: vk::COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
composite_alpha: vk::CompositeAlphaFlagsKHR::OPAQUE,
present_mode: present_mode,
clipped: 1,
old_swapchain: vk::SwapchainKHR::null(),
@ -448,18 +448,18 @@ impl ExampleBase {
.create_swapchain_khr(&swapchain_create_info, None)
.unwrap();
let pool_create_info = vk::CommandPoolCreateInfo {
s_type: vk::StructureType::CommandPoolCreateInfo,
s_type: vk::StructureType::COMMAND_POOL_CREATE_INFO,
p_next: ptr::null(),
flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER_BIT,
flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER,
queue_family_index: queue_family_index,
};
let pool = device.create_command_pool(&pool_create_info, None).unwrap();
let command_buffer_allocate_info = vk::CommandBufferAllocateInfo {
s_type: vk::StructureType::CommandBufferAllocateInfo,
s_type: vk::StructureType::COMMAND_BUFFER_ALLOCATE_INFO,
p_next: ptr::null(),
command_buffer_count: 2,
command_pool: pool,
level: vk::CommandBufferLevel::Primary,
level: vk::CommandBufferLevel::PRIMARY,
};
let command_buffers = device
.allocate_command_buffers(&command_buffer_allocate_info)
@ -474,10 +474,10 @@ impl ExampleBase {
.iter()
.map(|&image| {
let create_view_info = vk::ImageViewCreateInfo {
s_type: vk::StructureType::ImageViewCreateInfo,
s_type: vk::StructureType::IMAGE_VIEW_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
view_type: vk::ImageViewType::Type2d,
view_type: vk::ImageViewType::TYPE_2D,
format: surface_format.format,
components: vk::ComponentMapping {
r: vk::ComponentSwizzle::R,
@ -486,7 +486,7 @@ impl ExampleBase {
a: vk::ComponentSwizzle::A,
},
subresource_range: vk::ImageSubresourceRange {
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
aspect_mask: vk::ImageAspectFlags::COLOR,
base_mip_level: 0,
level_count: 1,
base_array_layer: 0,
@ -499,11 +499,11 @@ impl ExampleBase {
.collect();
let device_memory_properties = instance.get_physical_device_memory_properties(pdevice);
let depth_image_create_info = vk::ImageCreateInfo {
s_type: vk::StructureType::ImageCreateInfo,
s_type: vk::StructureType::IMAGE_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
image_type: vk::ImageType::Type2d,
format: vk::Format::D16Unorm,
image_type: vk::ImageType::TYPE_2D,
format: vk::Format::D16_UNORM,
extent: vk::Extent3D {
width: surface_resolution.width,
height: surface_resolution.height,
@ -511,13 +511,13 @@ impl ExampleBase {
},
mip_levels: 1,
array_layers: 1,
samples: vk::SAMPLE_COUNT_1_BIT,
tiling: vk::ImageTiling::Optimal,
usage: vk::IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
sharing_mode: vk::SharingMode::Exclusive,
samples: vk::SampleCountFlags::TYPE_1,
tiling: vk::ImageTiling::OPTIMAL,
usage: vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT,
sharing_mode: vk::SharingMode::EXCLUSIVE,
queue_family_index_count: 0,
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, None).unwrap();
let depth_image_memory_req = device.get_image_memory_requirements(depth_image);
@ -525,11 +525,11 @@ impl ExampleBase {
find_memorytype_index(
&depth_image_memory_req,
&device_memory_properties,
vk::MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
vk::MemoryPropertyFlags::DEVICE_LOCAL,
).expect("Unable to find suitable memory index for depth image.");
let depth_image_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MemoryAllocateInfo,
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
p_next: ptr::null(),
allocation_size: depth_image_memory_req.size,
memory_type_index: depth_image_memory_index,
@ -544,23 +544,23 @@ impl ExampleBase {
&device,
setup_command_buffer,
present_queue,
&[vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT],
&[vk::PipelineStageFlags::BOTTOM_OF_PIPE],
&[],
&[],
|device, setup_command_buffer| {
let layout_transition_barrier = vk::ImageMemoryBarrier {
s_type: vk::StructureType::ImageMemoryBarrier,
s_type: vk::StructureType::IMAGE_MEMORY_BARRIER,
p_next: ptr::null(),
src_access_mask: Default::default(),
dst_access_mask: vk::ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
| vk::ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
old_layout: vk::ImageLayout::Undefined,
new_layout: vk::ImageLayout::DepthStencilAttachmentOptimal,
dst_access_mask: vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ
| vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE,
old_layout: vk::ImageLayout::UNDEFINED,
new_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
image: depth_image,
subresource_range: vk::ImageSubresourceRange {
aspect_mask: vk::IMAGE_ASPECT_DEPTH_BIT,
aspect_mask: vk::ImageAspectFlags::DEPTH,
base_mip_level: 0,
level_count: 1,
base_array_layer: 0,
@ -569,8 +569,8 @@ impl ExampleBase {
};
device.cmd_pipeline_barrier(
setup_command_buffer,
vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
vk::PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
vk::PipelineStageFlags::BOTTOM_OF_PIPE,
vk::PipelineStageFlags::LATE_FRAGMENT_TESTS,
vk::DependencyFlags::empty(),
&[],
&[],
@ -579,19 +579,19 @@ impl ExampleBase {
},
);
let depth_image_view_info = vk::ImageViewCreateInfo {
s_type: vk::StructureType::ImageViewCreateInfo,
s_type: vk::StructureType::IMAGE_VIEW_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
view_type: vk::ImageViewType::Type2d,
view_type: vk::ImageViewType::TYPE_2D,
format: depth_image_create_info.format,
components: vk::ComponentMapping {
r: vk::ComponentSwizzle::Identity,
g: vk::ComponentSwizzle::Identity,
b: vk::ComponentSwizzle::Identity,
a: vk::ComponentSwizzle::Identity,
r: vk::ComponentSwizzle::IDENTITY,
g: vk::ComponentSwizzle::IDENTITY,
b: vk::ComponentSwizzle::IDENTITY,
a: vk::ComponentSwizzle::IDENTITY,
},
subresource_range: vk::ImageSubresourceRange {
aspect_mask: vk::IMAGE_ASPECT_DEPTH_BIT,
aspect_mask: vk::ImageAspectFlags::DEPTH,
base_mip_level: 0,
level_count: 1,
base_array_layer: 0,
@ -603,7 +603,7 @@ impl ExampleBase {
.create_image_view(&depth_image_view_info, None)
.unwrap();
let semaphore_create_info = vk::SemaphoreCreateInfo {
s_type: vk::StructureType::SemaphoreCreateInfo,
s_type: vk::StructureType::SEMAPHORE_CREATE_INFO,
p_next: ptr::null(),
flags: Default::default(),
};