From 1f0aa0e78da08fbebc154bd333bd79c99e276bf4 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 19 Jul 2023 22:59:05 +0200 Subject: [PATCH] Preliminary `ash 0.38` from `master` branch --- Cargo.toml | 6 +- README.md | 27 +++--- .../d3d12-visualization/imgui_renderer.rs | 4 +- examples/vulkan-buffer.rs | 14 +-- examples/vulkan-visualization/helper.rs | 4 +- .../vulkan-visualization/imgui_renderer.rs | 96 +++++++++---------- examples/vulkan-visualization/main.rs | 28 +++--- release.toml | 4 +- src/lib.rs | 2 +- src/vulkan/mod.rs | 6 +- 10 files changed, 94 insertions(+), 97 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8afaf85a..e2074c42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ thiserror = "1.0" presser = { version = "0.3" } # Only needed for vulkan. Disable all default features as good practice, # such as the ability to link/load a Vulkan library. -ash = { version = ">=0.34, <=0.37", optional = true, default-features = false, features = ["debug"] } +ash = { git = "https://github.com/ash-rs/ash.git", rev = "6b56444", optional = true, default-features = false, features = ["debug"] } # Only needed for visualizer. imgui = { version = "0.11", features = ["tables-api"], optional = true } @@ -47,8 +47,8 @@ optional = true [dev-dependencies] # Enable the "loaded" feature to be able to access the Vulkan entrypoint. -ash = { version = "0.37", default-features = false, features = ["debug", "loaded"] } -ash-window = "0.12" +ash = { git = "https://github.com/ash-rs/ash.git", rev = "6b56444", default-features = false, features = ["debug", "loaded"] } +ash-window = { git = "https://github.com/ash-rs/ash.git", rev = "6b56444" } raw-window-handle = "0.5" winit = { version = "0.28", features = ["x11", "wayland"] } env_logger = "0.10" diff --git a/README.md b/README.md index cc67d1f6..b80e949c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # 📒 gpu-allocator - [![Actions Status](https://img.shields.io/github/actions/workflow/status/Traverse-Research/gpu-allocator/ci.yml?branch=main&logo=github)](https://github.com/Traverse-Research/gpu-allocator/actions) [![Latest version](https://img.shields.io/crates/v/gpu-allocator.svg?logo=rust)](https://crates.io/crates/gpu-allocator) [![Docs](https://img.shields.io/docsrs/gpu-allocator?logo=docs.rs)](https://docs.rs/gpu-allocator/) @@ -17,14 +16,14 @@ gpu-allocator = "0.22.0" This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12. -### [Windows-rs] and [winapi] +## [Windows-rs] and [winapi] `gpu-allocator` recently migrated from [winapi] to [windows-rs] but still provides convenient helpers to convert to and from [winapi] types, enabled when compiling with the `public-winapi` crate feature. [Windows-rs]: https://github.com/microsoft/windows-rs [winapi]: https://github.com/retep998/winapi-rs -### Setting up the Vulkan memory allocator +## Setting up the Vulkan memory allocator ```rust use gpu_allocator::vulkan::*; @@ -39,15 +38,14 @@ let mut allocator = Allocator::new(&AllocatorCreateDesc { }); ``` -### Simple Vulkan allocation example +## Simple Vulkan allocation example ```rust use gpu_allocator::vulkan::*; use gpu_allocator::MemoryLocation; - // Setup vulkan info -let vk_info = vk::BufferCreateInfo::builder() +let vk_info = vk::BufferCreateInfo::default() .size(512) .usage(vk::BufferUsageFlags::STORAGE_BUFFER); @@ -71,7 +69,7 @@ allocator.free(allocation).unwrap(); unsafe { device.destroy_buffer(buffer, None) }; ``` -### Setting up the D3D12 memory allocator +## Setting up the D3D12 memory allocator ```rust use gpu_allocator::d3d12::*; @@ -83,7 +81,7 @@ let mut allocator = Allocator::new(&AllocatorCreateDesc { }); ``` -### Simple d3d12 allocation example +## Simple d3d12 allocation example ```rust use gpu_allocator::d3d12::*; @@ -129,19 +127,20 @@ drop(resource); allocator.free(allocation).unwrap(); ``` -### License +## License Licensed under either of -* Apache License, Version 2.0, ([LICENSE-APACHE](../master/LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](../master/LICENSE-MIT) or http://opensource.org/licenses/MIT) +- Apache License, Version 2.0, ([LICENSE-APACHE](../master/LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](../master/LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. -### Alternative libraries -* [vk-mem-rs](https://github.com/gwihlidal/vk-mem-rs) +## Alternative libraries + +- [vk-mem-rs](https://github.com/gwihlidal/vk-mem-rs) -### Contribution +## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 diff --git a/examples/d3d12-visualization/imgui_renderer.rs b/examples/d3d12-visualization/imgui_renderer.rs index ba9835c1..4643f0cc 100644 --- a/examples/d3d12-visualization/imgui_renderer.rs +++ b/examples/d3d12-visualization/imgui_renderer.rs @@ -790,7 +790,7 @@ impl ImGuiRenderer { D3D12_VERTEX_BUFFER_VIEW { BufferLocation: address, - SizeInBytes: (vertices.len() * stride) as u32, + SizeInBytes: std::mem::size_of_val(vertices) as u32, StrideInBytes: stride as u32, } }; @@ -802,7 +802,7 @@ impl ImGuiRenderer { D3D12_INDEX_BUFFER_VIEW { BufferLocation: address, - SizeInBytes: (indices.len() * stride) as u32, + SizeInBytes: std::mem::size_of_val(indices) as u32, Format: all_dxgi::DXGI_FORMAT_R16_UINT, } }; diff --git a/examples/vulkan-buffer.rs b/examples/vulkan-buffer.rs index b2175de9..7f6d08c8 100644 --- a/examples/vulkan-buffer.rs +++ b/examples/vulkan-buffer.rs @@ -18,7 +18,7 @@ fn main() { let instance = { let app_name = CString::new("Vulkan gpu-allocator test").unwrap(); - let appinfo = vk::ApplicationInfo::builder() + let appinfo = vk::ApplicationInfo::default() .application_name(&app_name) .application_version(0) .engine_name(&app_name) @@ -33,7 +33,7 @@ fn main() { let extensions_names_raw = vec![]; - let create_info = vk::InstanceCreateInfo::builder() + let create_info = vk::InstanceCreateInfo::default() .application_info(&appinfo) .enabled_layer_names(&layers_names_raw) .enabled_extension_names(&extensions_names_raw); @@ -79,11 +79,11 @@ fn main() { }; let priorities = [1.0]; - let queue_info = vk::DeviceQueueCreateInfo::builder() + let queue_info = vk::DeviceQueueCreateInfo::default() .queue_family_index(queue_family_index as u32) .queue_priorities(&priorities); - let create_info = vk::DeviceCreateInfo::builder() + let create_info = vk::DeviceCreateInfo::default() .queue_create_infos(std::slice::from_ref(&queue_info)) .enabled_extension_names(&device_extension_names_raw) .enabled_features(&features); @@ -104,7 +104,7 @@ fn main() { // Test allocating Gpu Only memory { - let test_buffer_info = vk::BufferCreateInfo::builder() + let test_buffer_info = vk::BufferCreateInfo::default() .size(512) .usage(vk::BufferUsageFlags::STORAGE_BUFFER) .sharing_mode(vk::SharingMode::EXCLUSIVE); @@ -137,7 +137,7 @@ fn main() { // Test allocating Cpu to Gpu memory { - let test_buffer_info = vk::BufferCreateInfo::builder() + let test_buffer_info = vk::BufferCreateInfo::default() .size(512) .usage(vk::BufferUsageFlags::STORAGE_BUFFER) .sharing_mode(vk::SharingMode::EXCLUSIVE); @@ -170,7 +170,7 @@ fn main() { // Test allocating Gpu to Cpu memory { - let test_buffer_info = vk::BufferCreateInfo::builder() + let test_buffer_info = vk::BufferCreateInfo::default() .size(512) .usage(vk::BufferUsageFlags::STORAGE_BUFFER) .sharing_mode(vk::SharingMode::EXCLUSIVE); diff --git a/examples/vulkan-visualization/helper.rs b/examples/vulkan-visualization/helper.rs index d14abc29..020119f8 100644 --- a/examples/vulkan-visualization/helper.rs +++ b/examples/vulkan-visualization/helper.rs @@ -22,7 +22,7 @@ pub(crate) fn record_and_submit_command_buffer, vk::Result>>()?; - let layout_info = vk::PipelineLayoutCreateInfo::builder().set_layouts(&set_layouts); + let layout_info = vk::PipelineLayoutCreateInfo::default().set_layouts(&set_layouts); let pipeline_layout = unsafe { device.create_pipeline_layout(&layout_info, None) }?; (pipeline_layout, set_layouts) }; let render_pass = { - let attachments = vk::AttachmentDescription::builder() + let attachments = vk::AttachmentDescription::default() .format(render_target_format) .samples(vk::SampleCountFlags::TYPE_1) .load_op(vk::AttachmentLoadOp::CLEAR) .store_op(vk::AttachmentStoreOp::STORE) .final_layout(vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL); - let subpass_attachment = vk::AttachmentReference::builder() + let subpass_attachment = vk::AttachmentReference::default() .attachment(0) .layout(vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL); - let subpass_description = vk::SubpassDescription::builder() + let subpass_description = vk::SubpassDescription::default() .pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS) .color_attachments(std::slice::from_ref(&subpass_attachment)); - let dependencies = vk::SubpassDependency::builder() + let dependencies = vk::SubpassDependency::default() .src_subpass(vk::SUBPASS_EXTERNAL) .src_stage_mask(vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT) .dst_access_mask( @@ -111,7 +116,7 @@ impl ImGuiRenderer { ) .dst_stage_mask(vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT); - let render_pass_create_info = vk::RenderPassCreateInfo::builder() + let render_pass_create_info = vk::RenderPassCreateInfo::default() .attachments(std::slice::from_ref(&attachments)) .subpasses(std::slice::from_ref(&subpass_description)) .dependencies(std::slice::from_ref(&dependencies)); @@ -122,7 +127,7 @@ impl ImGuiRenderer { let vs = include_bytes!("./spirv/imgui.vs.spv"); #[allow(clippy::cast_ptr_alignment)] - let shader_info = vk::ShaderModuleCreateInfo::builder().code(unsafe { + let shader_info = vk::ShaderModuleCreateInfo::default().code(unsafe { assert_eq!(vs.len() % 4, 0); std::slice::from_raw_parts(vs.as_ptr().cast(), vs.len() / 4) }); @@ -132,7 +137,7 @@ impl ImGuiRenderer { let ps = include_bytes!("./spirv/imgui.ps.spv"); #[allow(clippy::cast_ptr_alignment)] - let shader_info = vk::ShaderModuleCreateInfo::builder().code(unsafe { + let shader_info = vk::ShaderModuleCreateInfo::default().code(unsafe { assert_eq!(ps.len() % 4, 0); std::slice::from_raw_parts(ps.as_ptr().cast(), ps.len() / 4) }); @@ -140,15 +145,15 @@ impl ImGuiRenderer { }; let pipeline = { - let vertex_stage = vk::PipelineShaderStageCreateInfo::builder() + let vertex_stage = vk::PipelineShaderStageCreateInfo::default() .stage(vk::ShaderStageFlags::VERTEX) .module(vs_module) .name(std::ffi::CStr::from_bytes_with_nul(b"main\0").unwrap()); - let fragment_stage = vk::PipelineShaderStageCreateInfo::builder() + let fragment_stage = vk::PipelineShaderStageCreateInfo::default() .stage(vk::ShaderStageFlags::FRAGMENT) .module(ps_module) .name(std::ffi::CStr::from_bytes_with_nul(b"main\0").unwrap()); - let stages = [vertex_stage.build(), fragment_stage.build()]; + let stages = [vertex_stage, fragment_stage]; let vertex_binding_descriptions = [vk::VertexInputBindingDescription { binding: 0, @@ -175,21 +180,21 @@ impl ImGuiRenderer { offset: 16, }, ]; - let vertex_input_state = vk::PipelineVertexInputStateCreateInfo::builder() + let vertex_input_state = vk::PipelineVertexInputStateCreateInfo::default() .vertex_binding_descriptions(&vertex_binding_descriptions) .vertex_attribute_descriptions(&vertex_attribute_descriptions); - let input_assembly_state = vk::PipelineInputAssemblyStateCreateInfo::builder() + let input_assembly_state = vk::PipelineInputAssemblyStateCreateInfo::default() .topology(vk::PrimitiveTopology::TRIANGLE_LIST); - let viewport_state = vk::PipelineViewportStateCreateInfo::builder() + let viewport_state = vk::PipelineViewportStateCreateInfo::default() .viewport_count(1) .scissor_count(1); - let rasterization_state = vk::PipelineRasterizationStateCreateInfo::builder() + let rasterization_state = vk::PipelineRasterizationStateCreateInfo::default() .polygon_mode(vk::PolygonMode::FILL) .cull_mode(vk::CullModeFlags::NONE) .front_face(vk::FrontFace::CLOCKWISE) .depth_bias_enable(false) .line_width(1.0); - let multisample_state = vk::PipelineMultisampleStateCreateInfo::builder() + let multisample_state = vk::PipelineMultisampleStateCreateInfo::default() .rasterization_samples(vk::SampleCountFlags::TYPE_1); let noop_stencil_state = vk::StencilOpState { fail_op: vk::StencilOp::KEEP, @@ -198,7 +203,7 @@ impl ImGuiRenderer { compare_op: vk::CompareOp::ALWAYS, ..Default::default() }; - let depth_stencil_state = vk::PipelineDepthStencilStateCreateInfo::builder() + let depth_stencil_state = vk::PipelineDepthStencilStateCreateInfo::default() .depth_test_enable(false) .depth_write_enable(false) .depth_compare_op(vk::CompareOp::ALWAYS) @@ -207,7 +212,7 @@ impl ImGuiRenderer { .front(noop_stencil_state) .back(noop_stencil_state) .max_depth_bounds(1.0); - let attachments = vk::PipelineColorBlendAttachmentState::builder() + let attachments = vk::PipelineColorBlendAttachmentState::default() .blend_enable(true) .src_color_blend_factor(vk::BlendFactor::SRC_ALPHA) .dst_color_blend_factor(vk::BlendFactor::ONE_MINUS_SRC_ALPHA) @@ -221,13 +226,13 @@ impl ImGuiRenderer { | vk::ColorComponentFlags::B | vk::ColorComponentFlags::A }); - let color_blend_state = vk::PipelineColorBlendStateCreateInfo::builder() + let color_blend_state = vk::PipelineColorBlendStateCreateInfo::default() .logic_op(vk::LogicOp::CLEAR) .attachments(std::slice::from_ref(&attachments)); - let dynamic_state = vk::PipelineDynamicStateCreateInfo::builder() + let dynamic_state = vk::PipelineDynamicStateCreateInfo::default() .dynamic_states(&[vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR]); - let pipeline_create_info = vk::GraphicsPipelineCreateInfo::builder() + let pipeline_create_info = vk::GraphicsPipelineCreateInfo::default() .stages(&stages) .vertex_input_state(&vertex_input_state) .input_assembly_state(&input_assembly_state) @@ -259,7 +264,7 @@ impl ImGuiRenderer { let image_usage = vk::ImageUsageFlags::SAMPLED | vk::ImageUsageFlags::TRANSFER_DST | vk::ImageUsageFlags::TRANSFER_SRC; - let create_info = vk::ImageCreateInfo::builder() + let create_info = vk::ImageCreateInfo::default() .image_type(vk::ImageType::TYPE_2D) .format(vk::Format::R8G8B8A8_UNORM) .extent(vk::Extent3D { @@ -290,7 +295,7 @@ impl ImGuiRenderer { .unwrap(); // Create image view - let view_create_info = vk::ImageViewCreateInfo::builder() + let view_create_info = vk::ImageViewCreateInfo::default() .image(image) .view_type(vk::ImageViewType::TYPE_2D) .format(vk::Format::R8G8B8A8_UNORM) @@ -311,7 +316,7 @@ impl ImGuiRenderer { // Create upload buffer let (upload_buffer, mut upload_buffer_memory) = { - let create_info = vk::BufferCreateInfo::builder() + let create_info = vk::BufferCreateInfo::default() .size((font_atlas.width * font_atlas.height * 4) as u64) .usage(vk::BufferUsageFlags::TRANSFER_SRC); let buffer = unsafe { device.create_buffer(&create_info, None) }?; @@ -356,7 +361,7 @@ impl ImGuiRenderer { &[], |device, cmd| { { - let layout_transition_barriers = vk::ImageMemoryBarrier::builder() + let layout_transition_barriers = vk::ImageMemoryBarrier::default() .image(image) .dst_access_mask(vk::AccessFlags::TRANSFER_WRITE) .new_layout(vk::ImageLayout::TRANSFER_DST_OPTIMAL) @@ -382,7 +387,7 @@ impl ImGuiRenderer { }; } - let regions = vk::BufferImageCopy::builder() + let regions = vk::BufferImageCopy::default() .buffer_offset(0) .buffer_row_length(font_atlas.width) .buffer_image_height(font_atlas.height) @@ -409,7 +414,7 @@ impl ImGuiRenderer { }; { - let layout_transition_barriers = vk::ImageMemoryBarrier::builder() + let layout_transition_barriers = vk::ImageMemoryBarrier::default() .image(image) .dst_access_mask(vk::AccessFlags::SHADER_READ) .new_layout(vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL) @@ -447,7 +452,7 @@ impl ImGuiRenderer { }; let sampler = { - let create_info = vk::SamplerCreateInfo::builder() + let create_info = vk::SamplerCreateInfo::default() .mag_filter(vk::Filter::NEAREST) .min_filter(vk::Filter::NEAREST) .mipmap_mode(vk::SamplerMipmapMode::NEAREST) @@ -464,7 +469,7 @@ impl ImGuiRenderer { let (vertex_buffer, vb_allocation, vb_capacity) = { let capacity = 1024 * 1024; - let create_info = vk::BufferCreateInfo::builder() + let create_info = vk::BufferCreateInfo::default() .size(capacity) .usage(vk::BufferUsageFlags::VERTEX_BUFFER) .sharing_mode(vk::SharingMode::EXCLUSIVE); @@ -490,7 +495,7 @@ impl ImGuiRenderer { let (index_buffer, ib_allocation, ib_capacity) = { let capacity = 1024 * 1024; - let create_info = vk::BufferCreateInfo::builder() + let create_info = vk::BufferCreateInfo::default() .size(capacity) .usage(vk::BufferUsageFlags::INDEX_BUFFER) .sharing_mode(vk::SharingMode::EXCLUSIVE); @@ -514,7 +519,7 @@ impl ImGuiRenderer { (buffer, allocation, capacity) }; let (constant_buffer, cb_allocation) = { - let create_info = vk::BufferCreateInfo::builder() + let create_info = vk::BufferCreateInfo::default() .size(std::mem::size_of::() as u64) .usage(vk::BufferUsageFlags::UNIFORM_BUFFER) .sharing_mode(vk::SharingMode::EXCLUSIVE); @@ -539,46 +544,39 @@ impl ImGuiRenderer { }; let descriptor_sets = { - let alloc_info = vk::DescriptorSetAllocateInfo::builder() + let alloc_info = vk::DescriptorSetAllocateInfo::default() .descriptor_pool(descriptor_pool) .set_layouts(&descriptor_set_layouts); let descriptor_sets = unsafe { device.allocate_descriptor_sets(&alloc_info) }?; - let buffer_info = vk::DescriptorBufferInfo::builder() + let buffer_info = vk::DescriptorBufferInfo::default() .buffer(constant_buffer) .offset(0) .range(std::mem::size_of::() as u64); - let uniform_buffer = vk::WriteDescriptorSet::builder() + let uniform_buffer = vk::WriteDescriptorSet::default() .dst_set(descriptor_sets[0]) .dst_binding(0) .descriptor_type(vk::DescriptorType::UNIFORM_BUFFER) .buffer_info(std::slice::from_ref(&buffer_info)); - let image_info = vk::DescriptorImageInfo::builder().sampler(sampler); - let sampler = vk::WriteDescriptorSet::builder() + let image_info = vk::DescriptorImageInfo::default().sampler(sampler); + let sampler = vk::WriteDescriptorSet::default() .dst_set(descriptor_sets[0]) .dst_binding(1) .descriptor_type(vk::DescriptorType::SAMPLER) .image_info(std::slice::from_ref(&image_info)); - let image_info = vk::DescriptorImageInfo::builder() + let image_info = vk::DescriptorImageInfo::default() .image_view(font_image_view) .image_layout(vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL); - let sampled_image = vk::WriteDescriptorSet::builder() + let sampled_image = vk::WriteDescriptorSet::default() .dst_set(descriptor_sets[0]) .dst_binding(2) .descriptor_type(vk::DescriptorType::SAMPLED_IMAGE) .image_info(std::slice::from_ref(&image_info)); unsafe { - device.update_descriptor_sets( - &[ - uniform_buffer.build(), - sampler.build(), - sampled_image.build(), - ], - &[], - ) + device.update_descriptor_sets(&[uniform_buffer, sampler, sampled_image], &[]) }; descriptor_sets }; @@ -639,7 +637,7 @@ impl ImGuiRenderer { assert_eq!(copy_record.copy_start_offset, 0); } - let render_pass_begin_info = vk::RenderPassBeginInfo::builder() + let render_pass_begin_info = vk::RenderPassBeginInfo::default() .render_pass(self.render_pass) .framebuffer(framebuffer) .render_area(vk::Rect2D { @@ -660,7 +658,7 @@ impl ImGuiRenderer { unsafe { device.cmd_bind_pipeline(cmd, vk::PipelineBindPoint::GRAPHICS, self.pipeline) }; - let viewport = vk::Viewport::builder() + let viewport = vk::Viewport::default() .x(0.0) .y(0.0) .width(window_width as f32) diff --git a/examples/vulkan-visualization/main.rs b/examples/vulkan-visualization/main.rs index 652a11d2..fe63e47c 100644 --- a/examples/vulkan-visualization/main.rs +++ b/examples/vulkan-visualization/main.rs @@ -34,7 +34,7 @@ fn main() -> ash::prelude::VkResult<()> { let instance = { let app_name = CString::new("gpu-allocator examples vulkan-visualization").unwrap(); - let appinfo = vk::ApplicationInfo::builder() + let appinfo = vk::ApplicationInfo::default() .application_name(&app_name) .application_version(0) .engine_name(&app_name) @@ -50,7 +50,7 @@ fn main() -> ash::prelude::VkResult<()> { let surface_extensions = ash_window::enumerate_required_extensions(event_loop.raw_display_handle()).unwrap(); - let create_info = vk::InstanceCreateInfo::builder() + let create_info = vk::InstanceCreateInfo::default() .application_info(&appinfo) .enabled_layer_names(&layers_names_raw) .enabled_extension_names(surface_extensions); @@ -109,18 +109,18 @@ fn main() -> ash::prelude::VkResult<()> { // Create Vulkan device let device = { - let device_extension_names_raw = [ash::extensions::khr::Swapchain::name().as_ptr()]; + let device_extension_names_raw = [ash::extensions::khr::Swapchain::NAME.as_ptr()]; let features = vk::PhysicalDeviceFeatures { shader_clip_distance: 1, ..Default::default() }; let priorities = [1.0]; - let queue_info = vk::DeviceQueueCreateInfo::builder() + let queue_info = vk::DeviceQueueCreateInfo::default() .queue_family_index(queue_family_index as u32) .queue_priorities(&priorities); - let create_info = vk::DeviceCreateInfo::builder() + let create_info = vk::DeviceCreateInfo::default() .queue_create_infos(std::slice::from_ref(&queue_info)) .enabled_extension_names(&device_extension_names_raw) .enabled_features(&features); @@ -166,7 +166,7 @@ fn main() -> ash::prelude::VkResult<()> { .unwrap_or(vk::PresentModeKHR::FIFO); let swapchain_loader = ash::extensions::khr::Swapchain::new(&instance, &device); - let swapchain_create_info = vk::SwapchainCreateInfoKHR::builder() + let swapchain_create_info = vk::SwapchainCreateInfoKHR::default() .surface(surface) .min_image_count(desired_image_count) .image_color_space(surface_format.color_space) @@ -183,12 +183,12 @@ fn main() -> ash::prelude::VkResult<()> { let swapchain = unsafe { swapchain_loader.create_swapchain(&swapchain_create_info, None) }.unwrap(); - let pool_create_info = vk::CommandPoolCreateInfo::builder() + let pool_create_info = vk::CommandPoolCreateInfo::default() .flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER) .queue_family_index(queue_family_index as u32); let command_pool = unsafe { device.create_command_pool(&pool_create_info, None) }.unwrap(); - let command_buffer_allocate_info = vk::CommandBufferAllocateInfo::builder() + let command_buffer_allocate_info = vk::CommandBufferAllocateInfo::default() .command_buffer_count(2) .command_pool(command_pool) .level(vk::CommandBufferLevel::PRIMARY); @@ -202,7 +202,7 @@ fn main() -> ash::prelude::VkResult<()> { let mut present_image_views = present_images .iter() .map(|&image| { - let create_view_info = vk::ImageViewCreateInfo::builder() + let create_view_info = vk::ImageViewCreateInfo::default() .view_type(vk::ImageViewType::TYPE_2D) .format(surface_format.format) .components(vk::ComponentMapping { @@ -236,7 +236,7 @@ fn main() -> ash::prelude::VkResult<()> { .unwrap(), ); - let fence_create_info = vk::FenceCreateInfo::builder().flags(vk::FenceCreateFlags::SIGNALED); + let fence_create_info = vk::FenceCreateInfo::default().flags(vk::FenceCreateFlags::SIGNALED); let draw_commands_reuse_fence = unsafe { device.create_fence(&fence_create_info, None) }.unwrap(); let setup_commands_reuse_fence = @@ -267,7 +267,7 @@ fn main() -> ash::prelude::VkResult<()> { descriptor_count: 1, }, ]; - let create_info = vk::DescriptorPoolCreateInfo::builder() + let create_info = vk::DescriptorPoolCreateInfo::default() .max_sets(1) .pool_sizes(&pool_sizes); unsafe { device.create_descriptor_pool(&create_info, None) }? @@ -287,7 +287,7 @@ fn main() -> ash::prelude::VkResult<()> { let mut framebuffers = present_image_views .iter() .map(|&view| { - let create_info = vk::FramebufferCreateInfo::builder() + let create_info = vk::FramebufferCreateInfo::default() .render_pass(imgui_renderer.as_ref().unwrap().render_pass) .attachments(std::slice::from_ref(&view)) .width(window_width) @@ -368,7 +368,7 @@ fn main() -> ash::prelude::VkResult<()> { ); // Transition swapchain image to present state - let image_barriers = vk::ImageMemoryBarrier::builder() + let image_barriers = vk::ImageMemoryBarrier::default() .src_access_mask( vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE, @@ -397,7 +397,7 @@ fn main() -> ash::prelude::VkResult<()> { }, ); - let present_create_info = vk::PresentInfoKHR::builder() + let present_create_info = vk::PresentInfoKHR::default() .wait_semaphores(std::slice::from_ref(&rendering_complete_semaphore)) .swapchains(std::slice::from_ref(&swapchain)) .image_indices(std::slice::from_ref(&present_index)); diff --git a/release.toml b/release.toml index e2b249bf..619bc93a 100644 --- a/release.toml +++ b/release.toml @@ -6,6 +6,6 @@ sign-tag = true publish = false pre-release-replacements = [ - {file="README.md", search="gpu-allocator = .*", replace="{{crate_name}} = \"{{version}}\""}, - {file="README.tpl", search="gpu-allocator = .*", replace="{{crate_name}} = \"{{version}}\""}, + { file = "README.md", search = "gpu-allocator = .*", replace = "{{crate_name}} = \"{{version}}\"" }, + { file = "README.tpl", search = "gpu-allocator = .*", replace = "{{crate_name}} = \"{{version}}\"" }, ] diff --git a/src/lib.rs b/src/lib.rs index 64ca125e..9c5edf0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ //! # }).unwrap(); //! //! // Setup vulkan info -//! let vk_info = vk::BufferCreateInfo::builder() +//! let vk_info = vk::BufferCreateInfo::default() //! .size(512) //! .usage(vk::BufferUsageFlags::STORAGE_BUFFER); //! diff --git a/src/vulkan/mod.rs b/src/vulkan/mod.rs index 973569d1..65c0e88d 100644 --- a/src/vulkan/mod.rs +++ b/src/vulkan/mod.rs @@ -353,12 +353,12 @@ impl MemoryBlock { ) -> Result { let dedicated_allocation = allocation_scheme != AllocationScheme::GpuAllocatorManaged; let device_memory = { - let alloc_info = vk::MemoryAllocateInfo::builder() + let alloc_info = vk::MemoryAllocateInfo::default() .allocation_size(size) .memory_type_index(mem_type_index as u32); let allocation_flags = vk::MemoryAllocateFlags::DEVICE_ADDRESS; - let mut flags_info = vk::MemoryAllocateFlagsInfo::builder().flags(allocation_flags); + let mut flags_info = vk::MemoryAllocateFlagsInfo::default().flags(allocation_flags); // TODO(manon): Test this based on if the device has this feature enabled or not let alloc_info = if buffer_device_address { alloc_info.push_next(&mut flags_info) @@ -367,7 +367,7 @@ impl MemoryBlock { }; // Flag the memory as dedicated if required. - let mut dedicated_memory_info = vk::MemoryDedicatedAllocateInfo::builder(); + let mut dedicated_memory_info = vk::MemoryDedicatedAllocateInfo::default(); let alloc_info = match allocation_scheme { AllocationScheme::DedicatedBuffer(buffer) => { dedicated_memory_info = dedicated_memory_info.buffer(buffer);