From 7c8ab2a876a680616e8e1966c099664d843b05b6 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 12:45:29 +0200 Subject: [PATCH 01/10] Adjust `lib.rs` for examples --- examples/src/lib.rs | 116 ++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 8d1ad5a..0d0b0de 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -43,14 +43,14 @@ pub fn record_submit_commandbuffer( 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(), }; From c6be07f5f59be8d8942570d5c3c61c6c731452af Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 13:15:39 +0200 Subject: [PATCH 02/10] Port texture example --- examples/src/bin/texture.rs | 296 ++++++++++++++++++------------------ 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index 4eec9c1..765c3cb 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -36,50 +36,50 @@ fn main() { vk::AttachmentDescription { format: base.surface_format.format, flags: vk::AttachmentDescriptionFlags::empty(), - samples: vk::SAMPLE_COUNT_1_BIT, - load_op: vk::AttachmentLoadOp::Clear, - store_op: vk::AttachmentStoreOp::Store, - stencil_load_op: vk::AttachmentLoadOp::DontCare, - stencil_store_op: vk::AttachmentStoreOp::DontCare, - initial_layout: vk::ImageLayout::Undefined, - final_layout: vk::ImageLayout::PresentSrcKhr, + samples: vk::SampleCountFlags::TYPE_1, + load_op: vk::AttachmentLoadOp::CLEAR, + store_op: vk::AttachmentStoreOp::STORE, + stencil_load_op: vk::AttachmentLoadOp::DONT_CARE, + stencil_store_op: vk::AttachmentStoreOp::DONT_CARE, + initial_layout: vk::ImageLayout::UNDEFINED, + final_layout: vk::ImageLayout::PRESENT_SRC_KHR, }, vk::AttachmentDescription { - format: vk::Format::D16Unorm, + format: vk::Format::D16_UNORM, flags: vk::AttachmentDescriptionFlags::empty(), - samples: vk::SAMPLE_COUNT_1_BIT, - load_op: vk::AttachmentLoadOp::Clear, - store_op: vk::AttachmentStoreOp::DontCare, - stencil_load_op: vk::AttachmentLoadOp::DontCare, - stencil_store_op: vk::AttachmentStoreOp::DontCare, - initial_layout: vk::ImageLayout::DepthStencilAttachmentOptimal, - final_layout: vk::ImageLayout::DepthStencilAttachmentOptimal, + samples: vk::SampleCountFlags::TYPE_1, + load_op: vk::AttachmentLoadOp::CLEAR, + store_op: vk::AttachmentStoreOp::DONT_CARE, + stencil_load_op: vk::AttachmentLoadOp::DONT_CARE, + stencil_store_op: vk::AttachmentStoreOp::DONT_CARE, + initial_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, + final_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }, ]; let color_attachment_ref = vk::AttachmentReference { attachment: 0, - layout: vk::ImageLayout::ColorAttachmentOptimal, + layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL, }; let depth_attachment_ref = vk::AttachmentReference { attachment: 1, - layout: vk::ImageLayout::DepthStencilAttachmentOptimal, + layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }; let dependency = vk::SubpassDependency { dependency_flags: Default::default(), - src_subpass: vk::VK_SUBPASS_EXTERNAL, + src_subpass: vk::SUBPASS_EXTERNAL, dst_subpass: Default::default(), - src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, + src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, src_access_mask: Default::default(), - dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT - | vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT, - dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, + dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ + | vk::AccessFlags::COLOR_ATTACHMENT_WRITE, + dst_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, }; let subpass = vk::SubpassDescription { color_attachment_count: 1, p_color_attachments: &color_attachment_ref, p_depth_stencil_attachment: &depth_attachment_ref, flags: Default::default(), - pipeline_bind_point: vk::PipelineBindPoint::Graphics, + pipeline_bind_point: vk::PipelineBindPoint::GRAPHICS, input_attachment_count: 0, p_input_attachments: ptr::null(), p_resolve_attachments: ptr::null(), @@ -87,7 +87,7 @@ fn main() { p_preserve_attachments: ptr::null(), }; let renderpass_create_info = vk::RenderPassCreateInfo { - s_type: vk::StructureType::RenderPassCreateInfo, + s_type: vk::StructureType::RENDER_PASS_CREATE_INFO, flags: Default::default(), p_next: ptr::null(), attachment_count: renderpass_attachments.len() as u32, @@ -105,7 +105,7 @@ fn main() { .map(|&present_image_view| { let framebuffer_attachments = [present_image_view, base.depth_image_view]; let frame_buffer_create_info = vk::FramebufferCreateInfo { - s_type: vk::StructureType::FramebufferCreateInfo, + s_type: vk::StructureType::FRAMEBUFFER_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), render_pass: renderpass, @@ -122,12 +122,12 @@ fn main() { .collect(); let index_buffer_data = [0u32, 1, 2, 2, 3, 0]; let index_buffer_info = vk::BufferCreateInfo { - s_type: vk::StructureType::BufferCreateInfo, + s_type: vk::StructureType::BUFFER_CREATE_INFO, p_next: ptr::null(), flags: vk::BufferCreateFlags::empty(), size: std::mem::size_of_val(&index_buffer_data) as u64, - usage: vk::BUFFER_USAGE_INDEX_BUFFER_BIT, - sharing_mode: vk::SharingMode::Exclusive, + usage: vk::BufferUsageFlags::INDEX_BUFFER, + sharing_mode: vk::SharingMode::EXCLUSIVE, queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; @@ -137,10 +137,10 @@ fn main() { find_memorytype_index( &index_buffer_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT, + vk::MemoryPropertyFlags::HOST_VISIBLE, ).expect("Unable to find suitable memorytype for the index buffer."); let index_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: index_buffer_memory_req.size, memory_type_index: index_buffer_memory_index, @@ -186,12 +186,12 @@ fn main() { }, ]; let vertex_input_buffer_info = vk::BufferCreateInfo { - s_type: vk::StructureType::BufferCreateInfo, + s_type: vk::StructureType::BUFFER_CREATE_INFO, p_next: ptr::null(), flags: vk::BufferCreateFlags::empty(), size: std::mem::size_of_val(&vertices) as u64, - usage: vk::BUFFER_USAGE_VERTEX_BUFFER_BIT, - sharing_mode: vk::SharingMode::Exclusive, + usage: vk::BufferUsageFlags::VERTEX_BUFFER, + sharing_mode: vk::SharingMode::EXCLUSIVE, queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; @@ -204,11 +204,11 @@ fn main() { find_memorytype_index( &vertex_input_buffer_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT, + vk::MemoryPropertyFlags::HOST_VISIBLE, ).expect("Unable to find suitable memorytype for the vertex buffer."); let vertex_buffer_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: vertex_input_buffer_memory_req.size, memory_type_index: vertex_input_buffer_memory_index, @@ -242,12 +242,12 @@ fn main() { _pad: 0.0, }; let uniform_color_buffer_info = vk::BufferCreateInfo { - s_type: vk::StructureType::BufferCreateInfo, + s_type: vk::StructureType::BUFFER_CREATE_INFO, p_next: ptr::null(), flags: vk::BufferCreateFlags::empty(), size: std::mem::size_of_val(&uniform_color_buffer_data) as u64, - usage: vk::BUFFER_USAGE_UNIFORM_BUFFER_BIT, - sharing_mode: vk::SharingMode::Exclusive, + usage: vk::BufferUsageFlags::UNIFORM_BUFFER, + sharing_mode: vk::SharingMode::EXCLUSIVE, queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; @@ -260,11 +260,11 @@ fn main() { find_memorytype_index( &uniform_color_buffer_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT, + vk::MemoryPropertyFlags::HOST_VISIBLE, ).expect("Unable to find suitable memorytype for the vertex buffer."); let uniform_color_buffer_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: uniform_color_buffer_memory_req.size, memory_type_index: uniform_color_buffer_memory_index, @@ -295,12 +295,12 @@ fn main() { let image_dimensions = image.dimensions(); let image_data = image.into_raw(); let image_buffer_info = vk::BufferCreateInfo { - s_type: vk::StructureType::BufferCreateInfo, + s_type: vk::StructureType::BUFFER_CREATE_INFO, p_next: ptr::null(), flags: vk::BufferCreateFlags::empty(), size: (std::mem::size_of::() * image_data.len()) as u64, - usage: vk::BUFFER_USAGE_TRANSFER_SRC_BIT, - sharing_mode: vk::SharingMode::Exclusive, + usage: vk::BufferUsageFlags::TRANSFER_SRC, + sharing_mode: vk::SharingMode::EXCLUSIVE, queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; @@ -310,11 +310,11 @@ fn main() { find_memorytype_index( &image_buffer_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT, + vk::MemoryPropertyFlags::HOST_VISIBLE, ).expect("Unable to find suitable memorytype for the vertex buffer."); let image_buffer_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: image_buffer_memory_req.size, memory_type_index: image_buffer_memory_index, @@ -342,11 +342,11 @@ fn main() { .unwrap(); let texture_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::R8g8b8a8Unorm, + image_type: vk::ImageType::TYPE_2D, + format: vk::Format::R8G8B8A8_UNORM, extent: vk::Extent3D { width: image_dimensions.0, height: image_dimensions.1, @@ -354,13 +354,13 @@ fn main() { }, mip_levels: 1, array_layers: 1, - samples: vk::SAMPLE_COUNT_1_BIT, - tiling: vk::ImageTiling::Optimal, - usage: vk::IMAGE_USAGE_TRANSFER_DST_BIT | vk::IMAGE_USAGE_SAMPLED_BIT, - sharing_mode: vk::SharingMode::Exclusive, + samples: vk::SampleCountFlags::TYPE_1, + tiling: vk::ImageTiling::OPTIMAL, + usage: vk::ImageUsageFlags::TRANSFER_DST | vk::ImageUsageFlags::SAMPLED, + 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 texture_image = base.device .create_image(&texture_create_info, None) @@ -370,11 +370,11 @@ fn main() { find_memorytype_index( &texture_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_DEVICE_LOCAL_BIT, + vk::MemoryPropertyFlags::DEVICE_LOCAL, ).expect("Unable to find suitable memory index for depth image."); let texture_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: texture_memory_req.size, memory_type_index: texture_memory_index, @@ -390,22 +390,22 @@ fn main() { &base.device, base.setup_command_buffer, base.present_queue, - &[vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT], + &[vk::PipelineStageFlags::TOP_OF_PIPE], &[], &[], |device, texture_command_buffer| { let texture_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_TRANSFER_WRITE_BIT, - old_layout: vk::ImageLayout::Undefined, - new_layout: vk::ImageLayout::TransferDstOptimal, - src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, - dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, + dst_access_mask: vk::AccessFlags::TRANSFER_WRITE, + old_layout: vk::ImageLayout::UNDEFINED, + new_layout: vk::ImageLayout::TRANSFER_DST_OPTIMAL, + src_queue_family_index: vk::QUEUE_FAMILY_IGNORED, + dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED, image: texture_image, 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, @@ -414,8 +414,8 @@ fn main() { }; device.cmd_pipeline_barrier( texture_command_buffer, - vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, - vk::PIPELINE_STAGE_TRANSFER_BIT, + vk::PipelineStageFlags::BOTTOM_OF_PIPE, + vk::PipelineStageFlags::TRANSFER, vk::DependencyFlags::empty(), &[], &[], @@ -424,7 +424,7 @@ fn main() { let buffer_copy_regions = [ vk::BufferImageCopy { image_subresource: vk::ImageSubresourceLayers { - aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT, + aspect_mask: vk::ImageAspectFlags::COLOR, mip_level: 0, base_array_layer: 0, layer_count: 1, @@ -445,21 +445,21 @@ fn main() { texture_command_buffer, image_buffer, texture_image, - vk::ImageLayout::TransferDstOptimal, + vk::ImageLayout::TRANSFER_DST_OPTIMAL, &buffer_copy_regions, ); let texture_barrier_end = vk::ImageMemoryBarrier { - s_type: vk::StructureType::ImageMemoryBarrier, + s_type: vk::StructureType::IMAGE_MEMORY_BARRIER, p_next: ptr::null(), - src_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT, - dst_access_mask: vk::ACCESS_SHADER_READ_BIT, - old_layout: vk::ImageLayout::TransferDstOptimal, - new_layout: vk::ImageLayout::ShaderReadOnlyOptimal, - src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, - dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, + src_access_mask: vk::AccessFlags::TRANSFER_WRITE, + dst_access_mask: vk::AccessFlags::SHADER_READ, + old_layout: vk::ImageLayout::TRANSFER_DST_OPTIMAL, + new_layout: vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL, + src_queue_family_index: vk::QUEUE_FAMILY_IGNORED, + dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED, image: texture_image, 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, @@ -468,8 +468,8 @@ fn main() { }; device.cmd_pipeline_barrier( texture_command_buffer, - vk::PIPELINE_STAGE_TRANSFER_BIT, - vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + vk::PipelineStageFlags::TRANSFER, + vk::PipelineStageFlags::FRAGMENT_SHADER, vk::DependencyFlags::empty(), &[], &[], @@ -479,33 +479,33 @@ fn main() { ); let sampler_info = vk::SamplerCreateInfo { - s_type: vk::StructureType::SamplerCreateInfo, + s_type: vk::StructureType::SAMPLER_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), - mag_filter: vk::Filter::Linear, - min_filter: vk::Filter::Linear, - mipmap_mode: vk::SamplerMipmapMode::Linear, - address_mode_u: vk::SamplerAddressMode::MirroredRepeat, - address_mode_v: vk::SamplerAddressMode::MirroredRepeat, - address_mode_w: vk::SamplerAddressMode::MirroredRepeat, + mag_filter: vk::Filter::LINEAR, + min_filter: vk::Filter::LINEAR, + mipmap_mode: vk::SamplerMipmapMode::LINEAR, + address_mode_u: vk::SamplerAddressMode::MIRRORED_REPEAT, + address_mode_v: vk::SamplerAddressMode::MIRRORED_REPEAT, + address_mode_w: vk::SamplerAddressMode::MIRRORED_REPEAT, mip_lod_bias: 0.0, min_lod: 0.0, max_lod: 0.0, anisotropy_enable: 0, max_anisotropy: 1.0, - border_color: vk::BorderColor::FloatOpaqueWhite, + border_color: vk::BorderColor::FLOAT_OPAQUE_WHITE, compare_enable: 0, - compare_op: vk::CompareOp::Never, + compare_op: vk::CompareOp::NEVER, unnormalized_coordinates: 0, }; let sampler = base.device.create_sampler(&sampler_info, None).unwrap(); let tex_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: texture_create_info.format, components: vk::ComponentMapping { r: vk::ComponentSwizzle::R, @@ -514,7 +514,7 @@ fn main() { 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, @@ -527,16 +527,16 @@ fn main() { .unwrap(); let descriptor_sizes = [ vk::DescriptorPoolSize { - typ: vk::DescriptorType::UniformBuffer, + ty: vk::DescriptorType::UNIFORM_BUFFER, descriptor_count: 1, }, vk::DescriptorPoolSize { - typ: vk::DescriptorType::CombinedImageSampler, + ty: vk::DescriptorType::COMBINED_IMAGE_SAMPLER, descriptor_count: 1, }, ]; let descriptor_pool_info = vk::DescriptorPoolCreateInfo { - s_type: vk::StructureType::DescriptorPoolCreateInfo, + s_type: vk::StructureType::DESCRIPTOR_POOL_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), pool_size_count: descriptor_sizes.len() as u32, @@ -549,21 +549,21 @@ fn main() { let desc_layout_bindings = [ vk::DescriptorSetLayoutBinding { binding: 0, - descriptor_type: vk::DescriptorType::UniformBuffer, + descriptor_type: vk::DescriptorType::UNIFORM_BUFFER, descriptor_count: 1, - stage_flags: vk::SHADER_STAGE_FRAGMENT_BIT, + stage_flags: vk::ShaderStageFlags::FRAGMENT, p_immutable_samplers: ptr::null(), }, vk::DescriptorSetLayoutBinding { binding: 1, - descriptor_type: vk::DescriptorType::CombinedImageSampler, + descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER, descriptor_count: 1, - stage_flags: vk::SHADER_STAGE_FRAGMENT_BIT, + stage_flags: vk::ShaderStageFlags::FRAGMENT, p_immutable_samplers: ptr::null(), }, ]; let descriptor_info = vk::DescriptorSetLayoutCreateInfo { - s_type: vk::StructureType::DescriptorSetLayoutCreateInfo, + s_type: vk::StructureType::DESCRIPTOR_SET_LAYOUT_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), binding_count: desc_layout_bindings.len() as u32, @@ -576,7 +576,7 @@ fn main() { .unwrap(), ]; let desc_alloc_info = vk::DescriptorSetAllocateInfo { - s_type: vk::StructureType::DescriptorSetAllocateInfo, + s_type: vk::StructureType::DESCRIPTOR_SET_ALLOCATE_INFO, p_next: ptr::null(), descriptor_pool: descriptor_pool, descriptor_set_count: desc_set_layouts.len() as u32, @@ -593,32 +593,32 @@ fn main() { }; let tex_descriptor = vk::DescriptorImageInfo { - image_layout: vk::ImageLayout::General, + image_layout: vk::ImageLayout::GENERAL, image_view: tex_image_view, sampler: sampler, }; let write_desc_sets = [ vk::WriteDescriptorSet { - s_type: vk::StructureType::WriteDescriptorSet, + s_type: vk::StructureType::WRITE_DESCRIPTOR_SET, p_next: ptr::null(), dst_set: descriptor_sets[0], dst_binding: 0, dst_array_element: 0, descriptor_count: 1, - descriptor_type: vk::DescriptorType::UniformBuffer, + descriptor_type: vk::DescriptorType::UNIFORM_BUFFER, p_image_info: ptr::null(), p_buffer_info: &uniform_color_buffer_descriptor, p_texel_buffer_view: ptr::null(), }, vk::WriteDescriptorSet { - s_type: vk::StructureType::WriteDescriptorSet, + s_type: vk::StructureType::WRITE_DESCRIPTOR_SET, p_next: ptr::null(), dst_set: descriptor_sets[0], dst_binding: 1, dst_array_element: 0, descriptor_count: 1, - descriptor_type: vk::DescriptorType::CombinedImageSampler, + descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER, p_image_info: &tex_descriptor, p_buffer_info: ptr::null(), p_texel_buffer_view: ptr::null(), @@ -636,7 +636,7 @@ fn main() { .filter_map(|byte| byte.ok()) .collect(); let vertex_shader_info = vk::ShaderModuleCreateInfo { - s_type: vk::StructureType::ShaderModuleCreateInfo, + s_type: vk::StructureType::SHADER_MODULE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), code_size: vertex_bytes.len(), @@ -644,7 +644,7 @@ fn main() { }; let frag_bytes: Vec = frag_spv_file.bytes().filter_map(|byte| byte.ok()).collect(); let frag_shader_info = vk::ShaderModuleCreateInfo { - s_type: vk::StructureType::ShaderModuleCreateInfo, + s_type: vk::StructureType::SHADER_MODULE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), code_size: frag_bytes.len(), @@ -659,7 +659,7 @@ fn main() { .expect("Fragment shader module error"); let layout_create_info = vk::PipelineLayoutCreateInfo { - s_type: vk::StructureType::PipelineLayoutCreateInfo, + s_type: vk::StructureType::PIPELINE_LAYOUT_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), set_layout_count: desc_set_layouts.len() as u32, @@ -675,47 +675,47 @@ fn main() { let shader_entry_name = CString::new("main").unwrap(); let shader_stage_create_infos = [ vk::PipelineShaderStageCreateInfo { - s_type: vk::StructureType::PipelineShaderStageCreateInfo, + s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), module: vertex_shader_module, p_name: shader_entry_name.as_ptr(), p_specialization_info: ptr::null(), - stage: vk::SHADER_STAGE_VERTEX_BIT, + stage: vk::ShaderStageFlags::VERTEX, }, vk::PipelineShaderStageCreateInfo { - s_type: vk::StructureType::PipelineShaderStageCreateInfo, + s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), module: fragment_shader_module, p_name: shader_entry_name.as_ptr(), p_specialization_info: ptr::null(), - stage: vk::SHADER_STAGE_FRAGMENT_BIT, + stage: vk::ShaderStageFlags::FRAGMENT, }, ]; let vertex_input_binding_descriptions = [ vk::VertexInputBindingDescription { binding: 0, stride: mem::size_of::() as u32, - input_rate: vk::VertexInputRate::Vertex, + input_rate: vk::VertexInputRate::VERTEX, }, ]; let vertex_input_attribute_descriptions = [ vk::VertexInputAttributeDescription { location: 0, binding: 0, - format: vk::Format::R32g32b32a32Sfloat, + format: vk::Format::R32G32B32A32_SFLOAT, offset: offset_of!(Vertex, pos) as u32, }, vk::VertexInputAttributeDescription { location: 1, binding: 0, - format: vk::Format::R32g32Sfloat, + format: vk::Format::R32G32_SFLOAT, offset: offset_of!(Vertex, uv) as u32, }, ]; let vertex_input_state_info = vk::PipelineVertexInputStateCreateInfo { - s_type: vk::StructureType::PipelineVertexInputStateCreateInfo, + s_type: vk::StructureType::PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), vertex_attribute_description_count: vertex_input_attribute_descriptions.len() as u32, @@ -724,11 +724,11 @@ fn main() { p_vertex_binding_descriptions: vertex_input_binding_descriptions.as_ptr(), }; let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo { - s_type: vk::StructureType::PipelineInputAssemblyStateCreateInfo, + s_type: vk::StructureType::PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, flags: Default::default(), p_next: ptr::null(), primitive_restart_enable: 0, - topology: vk::PrimitiveTopology::TriangleList, + topology: vk::PrimitiveTopology::TRIANGLE_LIST, }; let viewports = [ vk::Viewport { @@ -747,7 +747,7 @@ fn main() { }, ]; let viewport_state_info = vk::PipelineViewportStateCreateInfo { - s_type: vk::StructureType::PipelineViewportStateCreateInfo, + s_type: vk::StructureType::PIPELINE_VIEWPORT_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), scissor_count: scissors.len() as u32, @@ -756,25 +756,25 @@ fn main() { p_viewports: viewports.as_ptr(), }; let rasterization_info = vk::PipelineRasterizationStateCreateInfo { - s_type: vk::StructureType::PipelineRasterizationStateCreateInfo, + s_type: vk::StructureType::PIPELINE_RASTERIZATION_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), - cull_mode: vk::CULL_MODE_NONE, + cull_mode: vk::CullModeFlags::NONE, depth_bias_clamp: 0.0, depth_bias_constant_factor: 0.0, depth_bias_enable: 0, depth_bias_slope_factor: 0.0, depth_clamp_enable: 0, - front_face: vk::FrontFace::CounterClockwise, + front_face: vk::FrontFace::COUNTER_CLOCKWISE, line_width: 1.0, - polygon_mode: vk::PolygonMode::Fill, + polygon_mode: vk::PolygonMode::FILL, rasterizer_discard_enable: 0, }; let multisample_state_info = vk::PipelineMultisampleStateCreateInfo { - s_type: vk::StructureType::PipelineMultisampleStateCreateInfo, + s_type: vk::StructureType::PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, flags: Default::default(), p_next: ptr::null(), - rasterization_samples: vk::SAMPLE_COUNT_1_BIT, + rasterization_samples: vk::SampleCountFlags::TYPE_1, sample_shading_enable: 0, min_sample_shading: 0.0, p_sample_mask: ptr::null(), @@ -782,21 +782,21 @@ fn main() { alpha_to_coverage_enable: 0, }; let noop_stencil_state = vk::StencilOpState { - fail_op: vk::StencilOp::Keep, - pass_op: vk::StencilOp::Keep, - depth_fail_op: vk::StencilOp::Keep, - compare_op: vk::CompareOp::Always, + fail_op: vk::StencilOp::KEEP, + pass_op: vk::StencilOp::KEEP, + depth_fail_op: vk::StencilOp::KEEP, + compare_op: vk::CompareOp::ALWAYS, compare_mask: 0, write_mask: 0, reference: 0, }; let depth_state_info = vk::PipelineDepthStencilStateCreateInfo { - s_type: vk::StructureType::PipelineDepthStencilStateCreateInfo, + s_type: vk::StructureType::PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), depth_test_enable: 1, depth_write_enable: 1, - depth_compare_op: vk::CompareOp::LessOrEqual, + depth_compare_op: vk::CompareOp::LESS_OR_EQUAL, depth_bounds_test_enable: 0, stencil_test_enable: 0, front: noop_stencil_state.clone(), @@ -807,35 +807,35 @@ fn main() { let color_blend_attachment_states = [ vk::PipelineColorBlendAttachmentState { blend_enable: 0, - src_color_blend_factor: vk::BlendFactor::SrcColor, - dst_color_blend_factor: vk::BlendFactor::OneMinusDstColor, - color_blend_op: vk::BlendOp::Add, - src_alpha_blend_factor: vk::BlendFactor::Zero, - dst_alpha_blend_factor: vk::BlendFactor::Zero, - alpha_blend_op: vk::BlendOp::Add, + src_color_blend_factor: vk::BlendFactor::SRC_COLOR, + dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR, + color_blend_op: vk::BlendOp::ADD, + src_alpha_blend_factor: vk::BlendFactor::ZERO, + dst_alpha_blend_factor: vk::BlendFactor::ZERO, + alpha_blend_op: vk::BlendOp::ADD, color_write_mask: vk::ColorComponentFlags::all(), }, ]; let color_blend_state = vk::PipelineColorBlendStateCreateInfo { - s_type: vk::StructureType::PipelineColorBlendStateCreateInfo, + s_type: vk::StructureType::PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), logic_op_enable: 0, - logic_op: vk::LogicOp::Clear, + logic_op: vk::LogicOp::CLEAR, attachment_count: color_blend_attachment_states.len() as u32, p_attachments: color_blend_attachment_states.as_ptr(), blend_constants: [0.0, 0.0, 0.0, 0.0], }; - let dynamic_state = [vk::DynamicState::Viewport, vk::DynamicState::Scissor]; + let dynamic_state = [vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR]; let dynamic_state_info = vk::PipelineDynamicStateCreateInfo { - s_type: vk::StructureType::PipelineDynamicStateCreateInfo, + s_type: vk::StructureType::PIPELINE_DYNAMIC_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), dynamic_state_count: dynamic_state.len() as u32, p_dynamic_states: dynamic_state.as_ptr(), }; let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo { - s_type: vk::StructureType::GraphicsPipelineCreateInfo, + s_type: vk::StructureType::GRAPHICS_PIPELINE_CREATE_INFO, p_next: ptr::null(), flags: vk::PipelineCreateFlags::empty(), stage_count: shader_stage_create_infos.len() as u32, @@ -877,7 +877,7 @@ fn main() { }, }, vk::ClearValue { - depth: vk::ClearDepthStencilValue { + depth_stencil: vk::ClearDepthStencilValue { depth: 1.0, stencil: 0, }, @@ -885,7 +885,7 @@ fn main() { ]; let render_pass_begin_info = vk::RenderPassBeginInfo { - s_type: vk::StructureType::RenderPassBeginInfo, + s_type: vk::StructureType::RENDER_PASS_BEGIN_INFO, p_next: ptr::null(), render_pass: renderpass, framebuffer: framebuffers[present_index as usize], @@ -899,21 +899,21 @@ fn main() { record_submit_commandbuffer(&base.device, base.draw_command_buffer, base.present_queue, - &[vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT], + &[vk::PipelineStageFlags::BOTTOM_OF_PIPE], &[base.present_complete_semaphore], &[base.rendering_complete_semaphore], |device, draw_command_buffer| { device.cmd_begin_render_pass(draw_command_buffer, &render_pass_begin_info, - vk::SubpassContents::Inline); + vk::SubpassContents::INLINE); device.cmd_bind_descriptor_sets(draw_command_buffer, - vk::PipelineBindPoint::Graphics, + vk::PipelineBindPoint::GRAPHICS, pipeline_layout, 0, &descriptor_sets[..], &[]); device.cmd_bind_pipeline(draw_command_buffer, - vk::PipelineBindPoint::Graphics, + vk::PipelineBindPoint::GRAPHICS, graphic_pipeline); device.cmd_set_viewport(draw_command_buffer, 0, &viewports); device.cmd_set_scissor(draw_command_buffer, 0, &scissors); @@ -922,7 +922,7 @@ fn main() { device.cmd_bind_index_buffer(draw_command_buffer, index_buffer, 0, - vk::IndexType::Uint32); + vk::IndexType::UINT32); device.cmd_draw_indexed(draw_command_buffer, index_buffer_data.len() as u32, 1, @@ -935,7 +935,7 @@ fn main() { }); //let mut present_info_err = mem::uninitialized(); let present_info = vk::PresentInfoKHR { - s_type: vk::StructureType::PresentInfoKhr, + s_type: vk::StructureType::PRESENT_INFO_KHR, p_next: ptr::null(), wait_semaphore_count: 1, p_wait_semaphores: &base.rendering_complete_semaphore, From 253f79eef533c7677125eca5538b20268c15162b Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 13:16:04 +0200 Subject: [PATCH 03/10] Adjust examples lib to match #75 --- examples/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 0d0b0de..81750a0 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -556,8 +556,8 @@ impl ExampleBase { | 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, + src_queue_family_index: vk::QUEUE_FAMILY_IGNORED, + dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED, image: depth_image, subresource_range: vk::ImageSubresourceRange { aspect_mask: vk::ImageAspectFlags::DEPTH, From dc80b74ea909c68724951c6b7de5d3e94d290427 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 13:22:16 +0200 Subject: [PATCH 04/10] Port triangle example --- examples/src/bin/triangle.rs | 158 +++++++++++++++++------------------ 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index e05837d..9192e6b 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -27,50 +27,50 @@ fn main() { vk::AttachmentDescription { format: base.surface_format.format, flags: vk::AttachmentDescriptionFlags::empty(), - samples: vk::SAMPLE_COUNT_1_BIT, - load_op: vk::AttachmentLoadOp::Clear, - store_op: vk::AttachmentStoreOp::Store, - stencil_load_op: vk::AttachmentLoadOp::DontCare, - stencil_store_op: vk::AttachmentStoreOp::DontCare, - initial_layout: vk::ImageLayout::Undefined, - final_layout: vk::ImageLayout::PresentSrcKhr, + samples: vk::SampleCountFlags::TYPE_1, + load_op: vk::AttachmentLoadOp::CLEAR, + store_op: vk::AttachmentStoreOp::STORE, + stencil_load_op: vk::AttachmentLoadOp::DONT_CARE, + stencil_store_op: vk::AttachmentStoreOp::DONT_CARE, + initial_layout: vk::ImageLayout::UNDEFINED, + final_layout: vk::ImageLayout::PRESENT_SRC_KHR, }, vk::AttachmentDescription { - format: vk::Format::D16Unorm, + format: vk::Format::D16_UNORM, flags: vk::AttachmentDescriptionFlags::empty(), - samples: vk::SAMPLE_COUNT_1_BIT, - load_op: vk::AttachmentLoadOp::Clear, - store_op: vk::AttachmentStoreOp::DontCare, - stencil_load_op: vk::AttachmentLoadOp::DontCare, - stencil_store_op: vk::AttachmentStoreOp::DontCare, - initial_layout: vk::ImageLayout::DepthStencilAttachmentOptimal, - final_layout: vk::ImageLayout::DepthStencilAttachmentOptimal, + samples: vk::SampleCountFlags::TYPE_1, + load_op: vk::AttachmentLoadOp::CLEAR, + store_op: vk::AttachmentStoreOp::DONT_CARE, + stencil_load_op: vk::AttachmentLoadOp::DONT_CARE, + stencil_store_op: vk::AttachmentStoreOp::DONT_CARE, + initial_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, + final_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }, ]; let color_attachment_ref = vk::AttachmentReference { attachment: 0, - layout: vk::ImageLayout::ColorAttachmentOptimal, + layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL, }; let depth_attachment_ref = vk::AttachmentReference { attachment: 1, - layout: vk::ImageLayout::DepthStencilAttachmentOptimal, + layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }; let dependency = vk::SubpassDependency { dependency_flags: Default::default(), - src_subpass: vk::VK_SUBPASS_EXTERNAL, + src_subpass: vk::SUBPASS_EXTERNAL, dst_subpass: Default::default(), - src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, + src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, src_access_mask: Default::default(), - dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT - | vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT, - dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, + dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ + | vk::AccessFlags::COLOR_ATTACHMENT_WRITE, + dst_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, }; let subpass = vk::SubpassDescription { color_attachment_count: 1, p_color_attachments: &color_attachment_ref, p_depth_stencil_attachment: &depth_attachment_ref, flags: Default::default(), - pipeline_bind_point: vk::PipelineBindPoint::Graphics, + pipeline_bind_point: vk::PipelineBindPoint::GRAPHICS, input_attachment_count: 0, p_input_attachments: ptr::null(), p_resolve_attachments: ptr::null(), @@ -78,7 +78,7 @@ fn main() { p_preserve_attachments: ptr::null(), }; let renderpass_create_info = vk::RenderPassCreateInfo { - s_type: vk::StructureType::RenderPassCreateInfo, + s_type: vk::StructureType::RENDER_PASS_CREATE_INFO, flags: Default::default(), p_next: ptr::null(), attachment_count: renderpass_attachments.len() as u32, @@ -96,7 +96,7 @@ fn main() { .map(|&present_image_view| { let framebuffer_attachments = [present_image_view, base.depth_image_view]; let frame_buffer_create_info = vk::FramebufferCreateInfo { - s_type: vk::StructureType::FramebufferCreateInfo, + s_type: vk::StructureType::FRAMEBUFFER_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), render_pass: renderpass, @@ -113,12 +113,12 @@ fn main() { .collect(); let index_buffer_data = [0u32, 1, 2]; let index_buffer_info = vk::BufferCreateInfo { - s_type: vk::StructureType::BufferCreateInfo, + s_type: vk::StructureType::BUFFER_CREATE_INFO, p_next: ptr::null(), flags: vk::BufferCreateFlags::empty(), size: std::mem::size_of_val(&index_buffer_data) as u64, - usage: vk::BUFFER_USAGE_INDEX_BUFFER_BIT, - sharing_mode: vk::SharingMode::Exclusive, + usage: vk::BufferUsageFlags::INDEX_BUFFER, + sharing_mode: vk::SharingMode::EXCLUSIVE, queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; @@ -128,10 +128,10 @@ fn main() { find_memorytype_index( &index_buffer_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT, + vk::MemoryPropertyFlags::HOST_VISIBLE, ).expect("Unable to find suitable memorytype for the index buffer."); let index_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: index_buffer_memory_req.size, memory_type_index: index_buffer_memory_index, @@ -159,12 +159,12 @@ fn main() { .unwrap(); let vertex_input_buffer_info = vk::BufferCreateInfo { - s_type: vk::StructureType::BufferCreateInfo, + s_type: vk::StructureType::BUFFER_CREATE_INFO, p_next: ptr::null(), flags: vk::BufferCreateFlags::empty(), size: 3 * std::mem::size_of::() as u64, - usage: vk::BUFFER_USAGE_VERTEX_BUFFER_BIT, - sharing_mode: vk::SharingMode::Exclusive, + usage: vk::BufferUsageFlags::VERTEX_BUFFER, + sharing_mode: vk::SharingMode::EXCLUSIVE, queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; @@ -177,11 +177,11 @@ fn main() { find_memorytype_index( &vertex_input_buffer_memory_req, &base.device_memory_properties, - vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT, + vk::MemoryPropertyFlags::HOST_VISIBLE, ).expect("Unable to find suitable memorytype for the vertex buffer."); let vertex_buffer_allocate_info = vk::MemoryAllocateInfo { - s_type: vk::StructureType::MemoryAllocateInfo, + s_type: vk::StructureType::MEMORY_ALLOCATE_INFO, p_next: ptr::null(), allocation_size: vertex_input_buffer_memory_req.size, memory_type_index: vertex_input_buffer_memory_index, @@ -231,7 +231,7 @@ fn main() { .filter_map(|byte| byte.ok()) .collect(); let vertex_shader_info = vk::ShaderModuleCreateInfo { - s_type: vk::StructureType::ShaderModuleCreateInfo, + s_type: vk::StructureType::SHADER_MODULE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), code_size: vertex_bytes.len(), @@ -239,7 +239,7 @@ fn main() { }; let frag_bytes: Vec = frag_spv_file.bytes().filter_map(|byte| byte.ok()).collect(); let frag_shader_info = vk::ShaderModuleCreateInfo { - s_type: vk::StructureType::ShaderModuleCreateInfo, + s_type: vk::StructureType::SHADER_MODULE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), code_size: frag_bytes.len(), @@ -254,7 +254,7 @@ fn main() { .expect("Fragment shader module error"); let layout_create_info = vk::PipelineLayoutCreateInfo { - s_type: vk::StructureType::PipelineLayoutCreateInfo, + s_type: vk::StructureType::PIPELINE_LAYOUT_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), set_layout_count: 0, @@ -270,47 +270,47 @@ fn main() { let shader_entry_name = CString::new("main").unwrap(); let shader_stage_create_infos = [ vk::PipelineShaderStageCreateInfo { - s_type: vk::StructureType::PipelineShaderStageCreateInfo, + s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), module: vertex_shader_module, p_name: shader_entry_name.as_ptr(), p_specialization_info: ptr::null(), - stage: vk::SHADER_STAGE_VERTEX_BIT, + stage: vk::ShaderStageFlags::VERTEX, }, vk::PipelineShaderStageCreateInfo { - s_type: vk::StructureType::PipelineShaderStageCreateInfo, + s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), module: fragment_shader_module, p_name: shader_entry_name.as_ptr(), p_specialization_info: ptr::null(), - stage: vk::SHADER_STAGE_FRAGMENT_BIT, + stage: vk::ShaderStageFlags::FRAGMENT, }, ]; let vertex_input_binding_descriptions = [ vk::VertexInputBindingDescription { binding: 0, stride: mem::size_of::() as u32, - input_rate: vk::VertexInputRate::Vertex, + input_rate: vk::VertexInputRate::VERTEX, }, ]; let vertex_input_attribute_descriptions = [ vk::VertexInputAttributeDescription { location: 0, binding: 0, - format: vk::Format::R32g32b32a32Sfloat, + format: vk::Format::R32G32B32A32_SFLOAT, offset: offset_of!(Vertex, pos) as u32, }, vk::VertexInputAttributeDescription { location: 1, binding: 0, - format: vk::Format::R32g32b32a32Sfloat, + format: vk::Format::R32G32B32A32_SFLOAT, offset: offset_of!(Vertex, color) as u32, }, ]; let vertex_input_state_info = vk::PipelineVertexInputStateCreateInfo { - s_type: vk::StructureType::PipelineVertexInputStateCreateInfo, + s_type: vk::StructureType::PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), vertex_attribute_description_count: vertex_input_attribute_descriptions.len() as u32, @@ -319,11 +319,11 @@ fn main() { p_vertex_binding_descriptions: vertex_input_binding_descriptions.as_ptr(), }; let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo { - s_type: vk::StructureType::PipelineInputAssemblyStateCreateInfo, + s_type: vk::StructureType::PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, flags: Default::default(), p_next: ptr::null(), primitive_restart_enable: 0, - topology: vk::PrimitiveTopology::TriangleList, + topology: vk::PrimitiveTopology::TRIANGLE_LIST, }; let viewports = [ vk::Viewport { @@ -342,7 +342,7 @@ fn main() { }, ]; let viewport_state_info = vk::PipelineViewportStateCreateInfo { - s_type: vk::StructureType::PipelineViewportStateCreateInfo, + s_type: vk::StructureType::PIPELINE_VIEWPORT_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), scissor_count: scissors.len() as u32, @@ -351,25 +351,25 @@ fn main() { p_viewports: viewports.as_ptr(), }; let rasterization_info = vk::PipelineRasterizationStateCreateInfo { - s_type: vk::StructureType::PipelineRasterizationStateCreateInfo, + s_type: vk::StructureType::PIPELINE_RASTERIZATION_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), - cull_mode: vk::CULL_MODE_NONE, + cull_mode: vk::CullModeFlags::NONE, depth_bias_clamp: 0.0, depth_bias_constant_factor: 0.0, depth_bias_enable: 0, depth_bias_slope_factor: 0.0, depth_clamp_enable: 0, - front_face: vk::FrontFace::CounterClockwise, + front_face: vk::FrontFace::COUNTER_CLOCKWISE, line_width: 1.0, - polygon_mode: vk::PolygonMode::Fill, + polygon_mode: vk::PolygonMode::FILL, rasterizer_discard_enable: 0, }; let multisample_state_info = vk::PipelineMultisampleStateCreateInfo { - s_type: vk::StructureType::PipelineMultisampleStateCreateInfo, + s_type: vk::StructureType::PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, flags: Default::default(), p_next: ptr::null(), - rasterization_samples: vk::SAMPLE_COUNT_1_BIT, + rasterization_samples: vk::SampleCountFlags::TYPE_1, sample_shading_enable: 0, min_sample_shading: 0.0, p_sample_mask: ptr::null(), @@ -377,21 +377,21 @@ fn main() { alpha_to_coverage_enable: 0, }; let noop_stencil_state = vk::StencilOpState { - fail_op: vk::StencilOp::Keep, - pass_op: vk::StencilOp::Keep, - depth_fail_op: vk::StencilOp::Keep, - compare_op: vk::CompareOp::Always, + fail_op: vk::StencilOp::KEEP, + pass_op: vk::StencilOp::KEEP, + depth_fail_op: vk::StencilOp::KEEP, + compare_op: vk::CompareOp::ALWAYS, compare_mask: 0, write_mask: 0, reference: 0, }; let depth_state_info = vk::PipelineDepthStencilStateCreateInfo { - s_type: vk::StructureType::PipelineDepthStencilStateCreateInfo, + s_type: vk::StructureType::PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), depth_test_enable: 1, depth_write_enable: 1, - depth_compare_op: vk::CompareOp::LessOrEqual, + depth_compare_op: vk::CompareOp::LESS_OR_EQUAL, depth_bounds_test_enable: 0, stencil_test_enable: 0, front: noop_stencil_state.clone(), @@ -402,35 +402,35 @@ fn main() { let color_blend_attachment_states = [ vk::PipelineColorBlendAttachmentState { blend_enable: 0, - src_color_blend_factor: vk::BlendFactor::SrcColor, - dst_color_blend_factor: vk::BlendFactor::OneMinusDstColor, - color_blend_op: vk::BlendOp::Add, - src_alpha_blend_factor: vk::BlendFactor::Zero, - dst_alpha_blend_factor: vk::BlendFactor::Zero, - alpha_blend_op: vk::BlendOp::Add, + src_color_blend_factor: vk::BlendFactor::SRC_COLOR, + dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR, + color_blend_op: vk::BlendOp::ADD, + src_alpha_blend_factor: vk::BlendFactor::ZERO, + dst_alpha_blend_factor: vk::BlendFactor::ZERO, + alpha_blend_op: vk::BlendOp::ADD, color_write_mask: vk::ColorComponentFlags::all(), }, ]; let color_blend_state = vk::PipelineColorBlendStateCreateInfo { - s_type: vk::StructureType::PipelineColorBlendStateCreateInfo, + s_type: vk::StructureType::PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), logic_op_enable: 0, - logic_op: vk::LogicOp::Clear, + logic_op: vk::LogicOp::CLEAR, attachment_count: color_blend_attachment_states.len() as u32, p_attachments: color_blend_attachment_states.as_ptr(), blend_constants: [0.0, 0.0, 0.0, 0.0], }; - let dynamic_state = [vk::DynamicState::Viewport, vk::DynamicState::Scissor]; + let dynamic_state = [vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR]; let dynamic_state_info = vk::PipelineDynamicStateCreateInfo { - s_type: vk::StructureType::PipelineDynamicStateCreateInfo, + s_type: vk::StructureType::PIPELINE_DYNAMIC_STATE_CREATE_INFO, p_next: ptr::null(), flags: Default::default(), dynamic_state_count: dynamic_state.len() as u32, p_dynamic_states: dynamic_state.as_ptr(), }; let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo { - s_type: vk::StructureType::GraphicsPipelineCreateInfo, + s_type: vk::StructureType::GRAPHICS_PIPELINE_CREATE_INFO, p_next: ptr::null(), flags: vk::PipelineCreateFlags::empty(), stage_count: shader_stage_create_infos.len() as u32, @@ -472,7 +472,7 @@ fn main() { }, }, vk::ClearValue { - depth: vk::ClearDepthStencilValue { + depth_stencil: vk::ClearDepthStencilValue { depth: 1.0, stencil: 0, }, @@ -480,7 +480,7 @@ fn main() { ]; let render_pass_begin_info = vk::RenderPassBeginInfo { - s_type: vk::StructureType::RenderPassBeginInfo, + s_type: vk::StructureType::RENDER_PASS_BEGIN_INFO, p_next: ptr::null(), render_pass: renderpass, framebuffer: framebuffers[present_index as usize], @@ -495,18 +495,18 @@ fn main() { &base.device, base.draw_command_buffer, base.present_queue, - &[vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT], + &[vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT], &[base.present_complete_semaphore], &[base.rendering_complete_semaphore], |device, draw_command_buffer| { device.cmd_begin_render_pass( draw_command_buffer, &render_pass_begin_info, - vk::SubpassContents::Inline, + vk::SubpassContents::INLINE, ); device.cmd_bind_pipeline( draw_command_buffer, - vk::PipelineBindPoint::Graphics, + vk::PipelineBindPoint::GRAPHICS, graphic_pipeline, ); device.cmd_set_viewport(draw_command_buffer, 0, &viewports); @@ -521,7 +521,7 @@ fn main() { draw_command_buffer, index_buffer, 0, - vk::IndexType::Uint32, + vk::IndexType::UINT32, ); device.cmd_draw_indexed( draw_command_buffer, @@ -538,7 +538,7 @@ fn main() { ); //let mut present_info_err = mem::uninitialized(); let present_info = vk::PresentInfoKHR { - s_type: vk::StructureType::PresentInfoKhr, + s_type: vk::StructureType::PRESENT_INFO_KHR, p_next: ptr::null(), wait_semaphore_count: 1, p_wait_semaphores: &base.rendering_complete_semaphore, From 1b5f2b105cd11dbb261685c9f8cfab192f65068e Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 14:31:52 +0200 Subject: [PATCH 05/10] Ignore #75 and #84 since it's cosmetic only --- examples/src/bin/texture.rs | 10 +++++----- examples/src/bin/triangle.rs | 2 +- examples/src/lib.rs | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index 765c3cb..315d6cc 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -66,7 +66,7 @@ fn main() { }; let dependency = vk::SubpassDependency { dependency_flags: Default::default(), - src_subpass: vk::SUBPASS_EXTERNAL, + src_subpass: vk::VK_SUBPASS_EXTERNAL, dst_subpass: Default::default(), src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, src_access_mask: Default::default(), @@ -401,8 +401,8 @@ fn main() { dst_access_mask: vk::AccessFlags::TRANSFER_WRITE, old_layout: vk::ImageLayout::UNDEFINED, new_layout: vk::ImageLayout::TRANSFER_DST_OPTIMAL, - src_queue_family_index: vk::QUEUE_FAMILY_IGNORED, - dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED, + src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, + dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, image: texture_image, subresource_range: vk::ImageSubresourceRange { aspect_mask: vk::ImageAspectFlags::COLOR, @@ -455,8 +455,8 @@ fn main() { dst_access_mask: vk::AccessFlags::SHADER_READ, old_layout: vk::ImageLayout::TRANSFER_DST_OPTIMAL, new_layout: vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL, - src_queue_family_index: vk::QUEUE_FAMILY_IGNORED, - dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED, + src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, + dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED, image: texture_image, subresource_range: vk::ImageSubresourceRange { aspect_mask: vk::ImageAspectFlags::COLOR, diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index 9192e6b..2329ba9 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -57,7 +57,7 @@ fn main() { }; let dependency = vk::SubpassDependency { dependency_flags: Default::default(), - src_subpass: vk::SUBPASS_EXTERNAL, + src_subpass: vk::VK_SUBPASS_EXTERNAL, dst_subpass: Default::default(), src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, src_access_mask: Default::default(), diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 81750a0..0fae665 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -303,8 +303,8 @@ impl ExampleBase { let debug_info = vk::DebugReportCallbackCreateInfoEXT { s_type: vk::StructureType::DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, p_next: ptr::null(), - flags: vk::DebugReportFlagsEXT::ERROR | vk::DebugReportFlagsEXT::WARNING - | vk::DebugReportFlagsEXT::PERFORMANCE_WARNING, + flags: vk::DebugReportFlagsEXT::ERROR_EXT | vk::DebugReportFlagsEXT::WARNING_EXT + | vk::DebugReportFlagsEXT::PERFORMANCE_WARNING_EXT, pfn_callback: vulkan_debug_callback, p_user_data: ptr::null_mut(), }; @@ -408,9 +408,9 @@ impl ExampleBase { }; let pre_transform = if surface_capabilities .supported_transforms - .subset(vk::SurfaceTransformFlagsKHR::IDENTITY) + .subset(vk::SurfaceTransformFlagsKHR::IDENTITY_KHR) { - vk::SurfaceTransformFlagsKHR::IDENTITY + vk::SurfaceTransformFlagsKHR::IDENTITY_KHR } else { surface_capabilities.current_transform }; @@ -420,8 +420,8 @@ 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_KHR) + .unwrap_or(vk::PresentModeKHR::FIFO_KHR); let swapchain_loader = Swapchain::new(&instance, &device).expect("Unable to load swapchain"); let swapchain_create_info = vk::SwapchainCreateInfoKHR { @@ -436,7 +436,7 @@ impl ExampleBase { image_usage: vk::ImageUsageFlags::COLOR_ATTACHMENT, image_sharing_mode: vk::SharingMode::EXCLUSIVE, pre_transform: pre_transform, - composite_alpha: vk::CompositeAlphaFlagsKHR::OPAQUE, + composite_alpha: vk::CompositeAlphaFlagsKHR::OPAQUE_KHR, present_mode: present_mode, clipped: 1, old_swapchain: vk::SwapchainKHR::null(), @@ -556,8 +556,8 @@ impl ExampleBase { | vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE, old_layout: vk::ImageLayout::UNDEFINED, new_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL, - src_queue_family_index: vk::QUEUE_FAMILY_IGNORED, - dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED, + 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::ImageAspectFlags::DEPTH, From c4566b6ca9aaa435c73aed27372a6e93d56ce858 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 14:38:11 +0200 Subject: [PATCH 06/10] Conditionally use `XlibSurface` and `Win32Surface` --- examples/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 0fae665..0626631 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -10,7 +10,11 @@ use ash::Entry; use ash::Instance; use ash::Device; pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0, V1_0}; -use ash::extensions::{DebugReport, Surface, Swapchain, Win32Surface, XlibSurface}; +use ash::extensions::{DebugReport, Surface, Swapchain}; +#[cfg(windows)] +use ash::extensions::Win32Surface; +#[cfg(not(windows))] +use ash::extensions::XlibSurface; use std::cell::RefCell; use std::ptr; use std::ffi::{CStr, CString}; From c0d29d49404346e9e2352096406c10c24368ccaf Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 14:51:37 +0200 Subject: [PATCH 07/10] Fix windows structure type --- examples/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 0626631..5cc309a 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -126,7 +126,7 @@ unsafe fn create_surface( let hwnd = window.get_hwnd() as HWND; let hinstance = GetWindow(hwnd, 0) as *const vk::c_void; let win32_create_info = vk::Win32SurfaceCreateInfoKHR { - s_type: vk::StructureType::Win32SurfaceCreateInfoKhr, + s_type: vk::StructureType::WIN32_SURFACE_CREATE_INFO_KHR, p_next: ptr::null(), flags: Default::default(), hinstance: hinstance, From 77cfbf2367eb335717e286981d92db0ff85e656e Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 14:51:45 +0200 Subject: [PATCH 08/10] Apply rustfmt to examples --- examples/src/bin/texture.rs | 291 +++++++++++++++++++---------------- examples/src/bin/triangle.rs | 111 ++++++------- examples/src/lib.rs | 49 +++--- 3 files changed, 243 insertions(+), 208 deletions(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index 315d6cc..aeb29e4 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -3,17 +3,19 @@ extern crate ash; extern crate examples; extern crate image; -use ash::vk; -use std::default::Default; -use std::ptr; -use std::ffi::CString; -use std::mem; -use std::path::Path; -use std::fs::File; -use std::io::Read; +use std::{ + default::Default, + ffi::CString, + fs::File, + io::Read, + mem::{self, align_of}, + path::Path, + ptr, +}; + +use ash::{util::*, vk}; + use examples::*; -use ash::util::*; -use std::mem::align_of; #[derive(Clone, Debug, Copy)] struct Vertex { @@ -97,10 +99,12 @@ fn main() { dependency_count: 1, p_dependencies: &dependency, }; - let renderpass = base.device + let renderpass = base + .device .create_render_pass(&renderpass_create_info, None) .unwrap(); - let framebuffers: Vec = base.present_image_views + let framebuffers: Vec = base + .present_image_views .iter() .map(|&present_image_view| { let framebuffer_attachments = [present_image_view, base.depth_image_view]; @@ -145,10 +149,12 @@ fn main() { allocation_size: index_buffer_memory_req.size, memory_type_index: index_buffer_memory_index, }; - let index_buffer_memory = base.device + let index_buffer_memory = base + .device .allocate_memory(&index_allocate_info, None) .unwrap(); - let index_ptr: *mut vk::c_void = base.device + let index_ptr: *mut vk::c_void = base + .device .map_memory( index_buffer_memory, 0, @@ -195,10 +201,12 @@ fn main() { queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; - let vertex_input_buffer = base.device + 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); let vertex_input_buffer_memory_index = find_memorytype_index( @@ -213,10 +221,12 @@ fn main() { allocation_size: vertex_input_buffer_memory_req.size, 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, None) .unwrap(); - let vert_ptr = base.device + let vert_ptr = base + .device .map_memory( vertex_input_buffer_memory, 0, @@ -251,10 +261,12 @@ fn main() { queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; - let uniform_color_buffer = base.device + 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); let uniform_color_buffer_memory_index = find_memorytype_index( @@ -269,10 +281,12 @@ fn main() { allocation_size: uniform_color_buffer_memory_req.size, 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, None) .unwrap(); - let uniform_ptr = base.device + let uniform_ptr = base + .device .map_memory( uniform_color_buffer_memory, 0, @@ -319,10 +333,12 @@ fn main() { allocation_size: image_buffer_memory_req.size, memory_type_index: image_buffer_memory_index, }; - let image_buffer_memory = base.device + let image_buffer_memory = base + .device .allocate_memory(&image_buffer_allocate_info, None) .unwrap(); - let image_ptr = base.device + let image_ptr = base + .device .map_memory( image_buffer_memory, 0, @@ -362,7 +378,8 @@ fn main() { p_queue_family_indices: ptr::null(), initial_layout: vk::ImageLayout::UNDEFINED, }; - let texture_image = base.device + let texture_image = base + .device .create_image(&texture_create_info, None) .unwrap(); let texture_memory_req = base.device.get_image_memory_requirements(texture_image); @@ -379,7 +396,8 @@ fn main() { allocation_size: texture_memory_req.size, memory_type_index: texture_memory_index, }; - let texture_memory = base.device + let texture_memory = base + .device .allocate_memory(&texture_allocate_info, None) .unwrap(); base.device @@ -421,26 +439,24 @@ fn main() { &[], &[texture_barrier], ); - let buffer_copy_regions = [ - vk::BufferImageCopy { - image_subresource: vk::ImageSubresourceLayers { - aspect_mask: vk::ImageAspectFlags::COLOR, - mip_level: 0, - base_array_layer: 0, - layer_count: 1, - }, - image_extent: vk::Extent3D { - width: image_dimensions.0, - height: image_dimensions.1, - depth: 1, - }, - buffer_offset: 0, - // FIX ME - buffer_image_height: 0, - buffer_row_length: 0, - image_offset: vk::Offset3D { x: 0, y: 0, z: 0 }, + let buffer_copy_regions = [vk::BufferImageCopy { + image_subresource: vk::ImageSubresourceLayers { + aspect_mask: vk::ImageAspectFlags::COLOR, + mip_level: 0, + base_array_layer: 0, + layer_count: 1, }, - ]; + image_extent: vk::Extent3D { + width: image_dimensions.0, + height: image_dimensions.1, + depth: 1, + }, + buffer_offset: 0, + // FIX ME + buffer_image_height: 0, + buffer_row_length: 0, + image_offset: vk::Offset3D { x: 0, y: 0, z: 0 }, + }]; device.cmd_copy_buffer_to_image( texture_command_buffer, image_buffer, @@ -522,7 +538,8 @@ fn main() { }, image: texture_image, }; - let tex_image_view = base.device + let tex_image_view = base + .device .create_image_view(&tex_image_view_info, None) .unwrap(); let descriptor_sizes = [ @@ -543,7 +560,8 @@ fn main() { p_pool_sizes: descriptor_sizes.as_ptr(), max_sets: 1, }; - let descriptor_pool = base.device + let descriptor_pool = base + .device .create_descriptor_pool(&descriptor_pool_info, None) .unwrap(); let desc_layout_bindings = [ @@ -570,11 +588,10 @@ fn main() { p_bindings: desc_layout_bindings.as_ptr(), }; - let desc_set_layouts = [ - base.device - .create_descriptor_set_layout(&descriptor_info, None) - .unwrap(), - ]; + let desc_set_layouts = [base + .device + .create_descriptor_set_layout(&descriptor_info, None) + .unwrap()]; let desc_alloc_info = vk::DescriptorSetAllocateInfo { s_type: vk::StructureType::DESCRIPTOR_SET_ALLOCATE_INFO, p_next: ptr::null(), @@ -582,7 +599,8 @@ fn main() { descriptor_set_count: desc_set_layouts.len() as u32, p_set_layouts: desc_set_layouts.as_ptr(), }; - let descriptor_sets = base.device + let descriptor_sets = base + .device .allocate_descriptor_sets(&desc_alloc_info) .unwrap(); @@ -650,11 +668,13 @@ fn main() { code_size: frag_bytes.len(), 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, None) .expect("Vertex shader module error"); - let fragment_shader_module = base.device + let fragment_shader_module = base + .device .create_shader_module(&frag_shader_info, None) .expect("Fragment shader module error"); @@ -668,7 +688,8 @@ fn main() { p_push_constant_ranges: ptr::null(), }; - let pipeline_layout = base.device + let pipeline_layout = base + .device .create_pipeline_layout(&layout_create_info, None) .unwrap(); @@ -693,13 +714,11 @@ fn main() { stage: vk::ShaderStageFlags::FRAGMENT, }, ]; - let vertex_input_binding_descriptions = [ - vk::VertexInputBindingDescription { - binding: 0, - stride: mem::size_of::() as u32, - input_rate: vk::VertexInputRate::VERTEX, - }, - ]; + let vertex_input_binding_descriptions = [vk::VertexInputBindingDescription { + binding: 0, + stride: mem::size_of::() as u32, + input_rate: vk::VertexInputRate::VERTEX, + }]; let vertex_input_attribute_descriptions = [ vk::VertexInputAttributeDescription { location: 0, @@ -730,22 +749,18 @@ fn main() { primitive_restart_enable: 0, topology: vk::PrimitiveTopology::TRIANGLE_LIST, }; - let viewports = [ - vk::Viewport { - x: 0.0, - y: 0.0, - width: base.surface_resolution.width as f32, - height: base.surface_resolution.height as f32, - min_depth: 0.0, - max_depth: 1.0, - }, - ]; - let scissors = [ - vk::Rect2D { - offset: vk::Offset2D { x: 0, y: 0 }, - extent: base.surface_resolution.clone(), - }, - ]; + let viewports = [vk::Viewport { + x: 0.0, + y: 0.0, + width: base.surface_resolution.width as f32, + height: base.surface_resolution.height as f32, + min_depth: 0.0, + max_depth: 1.0, + }]; + let scissors = [vk::Rect2D { + offset: vk::Offset2D { x: 0, y: 0 }, + extent: base.surface_resolution.clone(), + }]; let viewport_state_info = vk::PipelineViewportStateCreateInfo { s_type: vk::StructureType::PIPELINE_VIEWPORT_STATE_CREATE_INFO, p_next: ptr::null(), @@ -804,18 +819,16 @@ fn main() { max_depth_bounds: 1.0, min_depth_bounds: 0.0, }; - let color_blend_attachment_states = [ - vk::PipelineColorBlendAttachmentState { - blend_enable: 0, - src_color_blend_factor: vk::BlendFactor::SRC_COLOR, - dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR, - color_blend_op: vk::BlendOp::ADD, - src_alpha_blend_factor: vk::BlendFactor::ZERO, - dst_alpha_blend_factor: vk::BlendFactor::ZERO, - alpha_blend_op: vk::BlendOp::ADD, - color_write_mask: vk::ColorComponentFlags::all(), - }, - ]; + let color_blend_attachment_states = [vk::PipelineColorBlendAttachmentState { + blend_enable: 0, + src_color_blend_factor: vk::BlendFactor::SRC_COLOR, + dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR, + color_blend_op: vk::BlendOp::ADD, + src_alpha_blend_factor: vk::BlendFactor::ZERO, + dst_alpha_blend_factor: vk::BlendFactor::ZERO, + alpha_blend_op: vk::BlendOp::ADD, + color_write_mask: vk::ColorComponentFlags::all(), + }]; let color_blend_state = vk::PipelineColorBlendStateCreateInfo { s_type: vk::StructureType::PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, p_next: ptr::null(), @@ -855,14 +868,16 @@ fn main() { base_pipeline_handle: vk::Pipeline::null(), base_pipeline_index: 0, }; - let graphics_pipelines = base.device + let graphics_pipelines = base + .device .create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info], None) .unwrap(); let graphic_pipeline = graphics_pipelines[0]; base.render_loop(|| { - let present_index = base.swapchain_loader + let present_index = base + .swapchain_loader .acquire_next_image_khr( base.swapchain, std::u64::MAX, @@ -896,43 +911,59 @@ fn main() { clear_value_count: clear_values.len() as u32, p_clear_values: clear_values.as_ptr(), }; - record_submit_commandbuffer(&base.device, - base.draw_command_buffer, - base.present_queue, - &[vk::PipelineStageFlags::BOTTOM_OF_PIPE], - &[base.present_complete_semaphore], - &[base.rendering_complete_semaphore], - |device, draw_command_buffer| { - device.cmd_begin_render_pass(draw_command_buffer, - &render_pass_begin_info, - vk::SubpassContents::INLINE); - device.cmd_bind_descriptor_sets(draw_command_buffer, - vk::PipelineBindPoint::GRAPHICS, - pipeline_layout, - 0, - &descriptor_sets[..], - &[]); - device.cmd_bind_pipeline(draw_command_buffer, - vk::PipelineBindPoint::GRAPHICS, - graphic_pipeline); - device.cmd_set_viewport(draw_command_buffer, 0, &viewports); - device.cmd_set_scissor(draw_command_buffer, 0, &scissors); - device - .cmd_bind_vertex_buffers(draw_command_buffer, 0, &[vertex_input_buffer], &[0]); - device.cmd_bind_index_buffer(draw_command_buffer, - index_buffer, - 0, - vk::IndexType::UINT32); - device.cmd_draw_indexed(draw_command_buffer, - index_buffer_data.len() as u32, - 1, - 0, - 0, - 1); - // Or draw without the index buffer - // device.cmd_draw(draw_command_buffer, 3, 1, 0, 0); - device.cmd_end_render_pass(draw_command_buffer); - }); + record_submit_commandbuffer( + &base.device, + base.draw_command_buffer, + base.present_queue, + &[vk::PipelineStageFlags::BOTTOM_OF_PIPE], + &[base.present_complete_semaphore], + &[base.rendering_complete_semaphore], + |device, draw_command_buffer| { + device.cmd_begin_render_pass( + draw_command_buffer, + &render_pass_begin_info, + vk::SubpassContents::INLINE, + ); + device.cmd_bind_descriptor_sets( + draw_command_buffer, + vk::PipelineBindPoint::GRAPHICS, + pipeline_layout, + 0, + &descriptor_sets[..], + &[], + ); + device.cmd_bind_pipeline( + draw_command_buffer, + vk::PipelineBindPoint::GRAPHICS, + graphic_pipeline, + ); + device.cmd_set_viewport(draw_command_buffer, 0, &viewports); + device.cmd_set_scissor(draw_command_buffer, 0, &scissors); + device.cmd_bind_vertex_buffers( + draw_command_buffer, + 0, + &[vertex_input_buffer], + &[0], + ); + device.cmd_bind_index_buffer( + draw_command_buffer, + index_buffer, + 0, + vk::IndexType::UINT32, + ); + device.cmd_draw_indexed( + draw_command_buffer, + index_buffer_data.len() as u32, + 1, + 0, + 0, + 1, + ); + // Or draw without the index buffer + // device.cmd_draw(draw_command_buffer, 3, 1, 0, 0); + device.cmd_end_render_pass(draw_command_buffer); + }, + ); //let mut present_info_err = mem::uninitialized(); let present_info = vk::PresentInfoKHR { s_type: vk::StructureType::PRESENT_INFO_KHR, diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index 2329ba9..d84d142 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -2,17 +2,17 @@ extern crate ash; #[macro_use] extern crate examples; +use ash::util::*; use ash::vk; +use examples::*; use std::default::Default; -use std::ptr; use std::ffi::CString; -use std::mem; -use std::path::Path; use std::fs::File; use std::io::Read; -use examples::*; -use ash::util::*; +use std::mem; use std::mem::align_of; +use std::path::Path; +use std::ptr; #[derive(Clone, Debug, Copy)] struct Vertex { @@ -88,10 +88,12 @@ fn main() { dependency_count: 1, p_dependencies: &dependency, }; - let renderpass = base.device + let renderpass = base + .device .create_render_pass(&renderpass_create_info, None) .unwrap(); - let framebuffers: Vec = base.present_image_views + let framebuffers: Vec = base + .present_image_views .iter() .map(|&present_image_view| { let framebuffer_attachments = [present_image_view, base.depth_image_view]; @@ -136,10 +138,12 @@ fn main() { allocation_size: index_buffer_memory_req.size, memory_type_index: index_buffer_memory_index, }; - let index_buffer_memory = base.device + let index_buffer_memory = base + .device .allocate_memory(&index_allocate_info, None) .unwrap(); - let index_ptr = base.device + let index_ptr = base + .device .map_memory( index_buffer_memory, 0, @@ -168,10 +172,12 @@ fn main() { queue_family_index_count: 0, p_queue_family_indices: ptr::null(), }; - let vertex_input_buffer = base.device + 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); let vertex_input_buffer_memory_index = find_memorytype_index( @@ -186,7 +192,8 @@ fn main() { allocation_size: vertex_input_buffer_memory_req.size, 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, None) .unwrap(); let vertices = [ @@ -203,7 +210,8 @@ fn main() { color: [1.0, 0.0, 0.0, 1.0], }, ]; - let vert_ptr = base.device + let vert_ptr = base + .device .map_memory( vertex_input_buffer_memory, 0, @@ -245,11 +253,13 @@ fn main() { code_size: frag_bytes.len(), 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, None) .expect("Vertex shader module error"); - let fragment_shader_module = base.device + let fragment_shader_module = base + .device .create_shader_module(&frag_shader_info, None) .expect("Fragment shader module error"); @@ -263,7 +273,8 @@ fn main() { p_push_constant_ranges: ptr::null(), }; - let pipeline_layout = base.device + let pipeline_layout = base + .device .create_pipeline_layout(&layout_create_info, None) .unwrap(); @@ -288,13 +299,11 @@ fn main() { stage: vk::ShaderStageFlags::FRAGMENT, }, ]; - let vertex_input_binding_descriptions = [ - vk::VertexInputBindingDescription { - binding: 0, - stride: mem::size_of::() as u32, - input_rate: vk::VertexInputRate::VERTEX, - }, - ]; + let vertex_input_binding_descriptions = [vk::VertexInputBindingDescription { + binding: 0, + stride: mem::size_of::() as u32, + input_rate: vk::VertexInputRate::VERTEX, + }]; let vertex_input_attribute_descriptions = [ vk::VertexInputAttributeDescription { location: 0, @@ -325,22 +334,18 @@ fn main() { primitive_restart_enable: 0, topology: vk::PrimitiveTopology::TRIANGLE_LIST, }; - let viewports = [ - vk::Viewport { - x: 0.0, - y: 0.0, - width: base.surface_resolution.width as f32, - height: base.surface_resolution.height as f32, - min_depth: 0.0, - max_depth: 1.0, - }, - ]; - let scissors = [ - vk::Rect2D { - offset: vk::Offset2D { x: 0, y: 0 }, - extent: base.surface_resolution.clone(), - }, - ]; + let viewports = [vk::Viewport { + x: 0.0, + y: 0.0, + width: base.surface_resolution.width as f32, + height: base.surface_resolution.height as f32, + min_depth: 0.0, + max_depth: 1.0, + }]; + let scissors = [vk::Rect2D { + offset: vk::Offset2D { x: 0, y: 0 }, + extent: base.surface_resolution.clone(), + }]; let viewport_state_info = vk::PipelineViewportStateCreateInfo { s_type: vk::StructureType::PIPELINE_VIEWPORT_STATE_CREATE_INFO, p_next: ptr::null(), @@ -399,18 +404,16 @@ fn main() { max_depth_bounds: 1.0, min_depth_bounds: 0.0, }; - let color_blend_attachment_states = [ - vk::PipelineColorBlendAttachmentState { - blend_enable: 0, - src_color_blend_factor: vk::BlendFactor::SRC_COLOR, - dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR, - color_blend_op: vk::BlendOp::ADD, - src_alpha_blend_factor: vk::BlendFactor::ZERO, - dst_alpha_blend_factor: vk::BlendFactor::ZERO, - alpha_blend_op: vk::BlendOp::ADD, - color_write_mask: vk::ColorComponentFlags::all(), - }, - ]; + let color_blend_attachment_states = [vk::PipelineColorBlendAttachmentState { + blend_enable: 0, + src_color_blend_factor: vk::BlendFactor::SRC_COLOR, + dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR, + color_blend_op: vk::BlendOp::ADD, + src_alpha_blend_factor: vk::BlendFactor::ZERO, + dst_alpha_blend_factor: vk::BlendFactor::ZERO, + alpha_blend_op: vk::BlendOp::ADD, + color_write_mask: vk::ColorComponentFlags::all(), + }]; let color_blend_state = vk::PipelineColorBlendStateCreateInfo { s_type: vk::StructureType::PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, p_next: ptr::null(), @@ -450,14 +453,16 @@ fn main() { base_pipeline_handle: vk::Pipeline::null(), base_pipeline_index: 0, }; - let graphics_pipelines = base.device + let graphics_pipelines = base + .device .create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info], None) .expect("Unable to create graphics pipeline"); let graphic_pipeline = graphics_pipelines[0]; base.render_loop(|| { - let present_index = base.swapchain_loader + let present_index = base + .swapchain_loader .acquire_next_image_khr( base.swapchain, std::u64::MAX, diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 5cc309a..a7740c8 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -4,34 +4,32 @@ extern crate ash; extern crate winapi; extern crate winit; -use ash::vk; -use std::default::Default; -use ash::Entry; -use ash::Instance; -use ash::Device; -pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0, V1_0}; -use ash::extensions::{DebugReport, Surface, Swapchain}; #[cfg(windows)] use ash::extensions::Win32Surface; #[cfg(not(windows))] use ash::extensions::XlibSurface; +use ash::extensions::{DebugReport, Surface, Swapchain}; +pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0, V1_0}; +use ash::vk; +use ash::Device; +use ash::Entry; +use ash::Instance; use std::cell::RefCell; -use std::ptr; +use std::default::Default; use std::ffi::{CStr, CString}; use std::ops::Drop; +use std::ptr; // Simple offset_of macro akin to C++ offsetof #[macro_export] -macro_rules! offset_of{ - ($base: path, $field: ident) => { - { - #[allow(unused_unsafe)] - unsafe{ - let b: $base = mem::uninitialized(); - (&b.$field as *const _ as isize) - (&b as *const _ as isize) - } +macro_rules! offset_of { + ($base:path, $field:ident) => {{ + #[allow(unused_unsafe)] + unsafe { + let b: $base = mem::uninitialized(); + (&b.$field as *const _ as isize) - (&b as *const _ as isize) } - } + }}; } pub fn record_submit_commandbuffer( @@ -307,7 +305,8 @@ impl ExampleBase { let debug_info = vk::DebugReportCallbackCreateInfoEXT { s_type: vk::StructureType::DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, p_next: ptr::null(), - flags: vk::DebugReportFlagsEXT::ERROR_EXT | vk::DebugReportFlagsEXT::WARNING_EXT + flags: vk::DebugReportFlagsEXT::ERROR_EXT + | vk::DebugReportFlagsEXT::WARNING_EXT | vk::DebugReportFlagsEXT::PERFORMANCE_WARNING_EXT, pfn_callback: vulkan_debug_callback, p_user_data: ptr::null_mut(), @@ -331,13 +330,13 @@ impl ExampleBase { .iter() .enumerate() .filter_map(|(index, ref info)| { - let supports_graphic_and_surface = info.queue_flags - .subset(vk::QueueFlags::GRAPHICS) - && surface_loader.get_physical_device_surface_support_khr( - *pdevice, - index as u32, - surface, - ); + let supports_graphic_and_surface = + info.queue_flags.subset(vk::QueueFlags::GRAPHICS) + && surface_loader.get_physical_device_surface_support_khr( + *pdevice, + index as u32, + surface, + ); match supports_graphic_and_surface { true => Some((*pdevice, index)), _ => None, From ec41984cb5fac729137d281a3a5290babdddcc09 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 14:59:21 +0200 Subject: [PATCH 09/10] Fix formatting in textures.rs --- examples/src/bin/texture.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index aeb29e4..9a5d117 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -3,15 +3,13 @@ extern crate ash; extern crate examples; extern crate image; -use std::{ - default::Default, - ffi::CString, - fs::File, - io::Read, - mem::{self, align_of}, - path::Path, - ptr, -}; +use std::default::Default; +use std::ffi::CString; +use std::fs::File; +use std::io::Read; +use std::mem::{self, align_of}; +use std::path::Path; +use std::ptr; use ash::{util::*, vk}; From d9aa575318f7bde07d3650c638af2dda7638cf62 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Jul 2018 15:00:28 +0200 Subject: [PATCH 10/10] Fix formatting in textures.rs --- examples/src/bin/texture.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index 9a5d117..bce408c 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -11,7 +11,8 @@ use std::mem::{self, align_of}; use std::path::Path; use std::ptr; -use ash::{util::*, vk}; +use ash::util::*; +use ash::vk; use examples::*;