From 3fb4a30a9fe8ba014385226ad1d4eb866f08932d Mon Sep 17 00:00:00 2001 From: Martin Charles Date: Fri, 19 Apr 2024 03:32:23 -0500 Subject: [PATCH 1/7] fix null handling of array fields in autogen properties (#2518) * add UnalignedSlice * Revert "add UnalignedSlice" This reverts commit 8bb1603ed34fb631fd3d0af78f738912ef6c5aa1. * add null check * clippy * rerun ci --- vulkano/autogen/properties.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/vulkano/autogen/properties.rs b/vulkano/autogen/properties.rs index 9be0da6667..a0c39d17df 100644 --- a/vulkano/autogen/properties.rs +++ b/vulkano/autogen/properties.rs @@ -92,14 +92,19 @@ fn properties_output(members: &[PropertiesMember]) -> TokenStream { let len_field_name = Ident::new(len_field_name.as_str(), Span::call_site()); quote! { - properties_ffi.#ffi_member.map(|s| - unsafe { + properties_ffi.#ffi_member.and_then(|s| { + let ptr = s #ffi_member_field .#ffi_name .cast_const(); + if ptr.is_null() { + return None; + }; + + Some(unsafe { std::slice::from_raw_parts( - s #ffi_member_field .#ffi_name .cast_const(), + ptr, s #ffi_member_field .#len_field_name as _, ) - } - ) + }) + }) } } else { quote! { properties_ffi.#ffi_member.map(|s| s #ffi_member_field .#ffi_name) } From 87993aa3d7696ceb3eafcb669477b6cfbe879506 Mon Sep 17 00:00:00 2001 From: Rua Date: Fri, 19 Apr 2024 12:27:26 +0200 Subject: [PATCH 2/7] Set MSRV to 1.72.0 (#2516) * Set MSRV to 1.72.0 * Use workspace inheritance for some package fields * Authors seem to differ, so don't inherit that * Consistency --- Cargo.toml | 8 ++++++++ vulkano-macros/Cargo.toml | 11 ++++++----- vulkano-shaders/Cargo.toml | 11 ++++++----- vulkano-util/Cargo.toml | 11 ++++++----- vulkano/Cargo.toml | 11 ++++++----- .../commands/acceleration_structure.rs | 4 ++-- vulkano/src/pipeline/graphics/mod.rs | 18 +++++++++--------- 7 files changed, 43 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5acff72343..31c0b24ec6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,14 @@ members = [ ] resolver = "2" +[workspace.package] +edition = "2021" +rust-version = "1.72.0" +license = "MIT OR Apache-2.0" +homepage = "https://vulkano.rs" +keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] +categories = ["rendering::graphics-api"] + [workspace.dependencies.vulkano] version = "0.34" path = "vulkano" diff --git a/vulkano-macros/Cargo.toml b/vulkano-macros/Cargo.toml index b89ec69273..6f94d35181 100644 --- a/vulkano-macros/Cargo.toml +++ b/vulkano-macros/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "vulkano-macros" version = "0.34.0" -edition = "2021" authors = ["The vulkano contributors"] repository = "https://github.com/vulkano-rs/vulkano/tree/master/vulkano-macros" description = "Macros used by vulkano" -license = "MIT OR Apache-2.0" documentation = "https://docs.rs/vulkano-macros" -homepage = "https://vulkano.rs" -keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] -categories = ["rendering::graphics-api"] readme = "../README.md" +edition = { workspace = true } +rust-version = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [lib] proc-macro = true diff --git a/vulkano-shaders/Cargo.toml b/vulkano-shaders/Cargo.toml index 75b6076e64..e21e1e5a86 100644 --- a/vulkano-shaders/Cargo.toml +++ b/vulkano-shaders/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "vulkano-shaders" version = "0.34.0" -edition = "2021" authors = ["Pierre Krieger ", "The vulkano contributors"] repository = "https://github.com/vulkano-rs/vulkano/tree/master/vulkano-shaders" description = "Macro for generating Rust code from shaders" -license = "MIT OR Apache-2.0" documentation = "https://docs.rs/vulkano-shaders" -homepage = "https://vulkano.rs" -keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] -categories = ["rendering::graphics-api"] readme = "../README.md" +edition = { workspace = true } +rust-version = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [lib] proc-macro = true diff --git a/vulkano-util/Cargo.toml b/vulkano-util/Cargo.toml index c149d9cb5b..c17a9b1922 100644 --- a/vulkano-util/Cargo.toml +++ b/vulkano-util/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "vulkano-util" version = "0.34.0" -edition = "2021" authors = ["The vulkano contributors"] repository = "https://github.com/vulkano-rs/vulkano/tree/master/vulkano-util" description = "Utility functionality to make usage of vulkano easier" -license = "MIT OR Apache-2.0" documentation = "https://docs.rs/vulkano-util" -homepage = "https://vulkano.rs" -keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] -categories = ["rendering::graphics-api"] readme = "../README.md" +edition = { workspace = true } +rust-version = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] ahash = { workspace = true } diff --git a/vulkano/Cargo.toml b/vulkano/Cargo.toml index 9120f1895c..af9c6d09e3 100644 --- a/vulkano/Cargo.toml +++ b/vulkano/Cargo.toml @@ -1,17 +1,18 @@ [package] name = "vulkano" version = "0.34.0" -edition = "2021" authors = ["Pierre Krieger ", "The vulkano contributors"] repository = "https://github.com/vulkano-rs/vulkano/tree/master/vulkano" description = "Safe wrapper for the Vulkan graphics API" -license = "MIT OR Apache-2.0" documentation = "https://docs.rs/vulkano" -homepage = "https://vulkano.rs" -keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] -categories = ["rendering::graphics-api"] readme = "../README.md" build = "build.rs" +edition = { workspace = true } +rust-version = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] ahash = { workspace = true } diff --git a/vulkano/src/command_buffer/commands/acceleration_structure.rs b/vulkano/src/command_buffer/commands/acceleration_structure.rs index 1d8c9a7021..eaafe2407a 100644 --- a/vulkano/src/command_buffer/commands/acceleration_structure.rs +++ b/vulkano/src/command_buffer/commands/acceleration_structure.rs @@ -21,7 +21,7 @@ use crate::{ DeviceSize, Requires, RequiresAllOf, RequiresOneOf, ValidationError, VulkanObject, }; use smallvec::SmallVec; -use std::{mem::size_of, ptr, sync::Arc}; +use std::{mem::size_of, sync::Arc}; /// # Commands to do operations on acceleration structures. impl RecordingCommandBuffer { @@ -1568,7 +1568,7 @@ impl RawRecordingCommandBuffer { .collect(); let build_range_info_pointers_vk: SmallVec<[_; 8]> = build_range_info_elements_vk .iter() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .collect(); let fns = self.device().fns(); diff --git a/vulkano/src/pipeline/graphics/mod.rs b/vulkano/src/pipeline/graphics/mod.rs index 6a583ea3d7..23ee8abb9e 100644 --- a/vulkano/src/pipeline/graphics/mod.rs +++ b/vulkano/src/pipeline/graphics/mod.rs @@ -855,39 +855,39 @@ impl GraphicsPipeline { p_stages: stages_vk.as_ptr(), p_vertex_input_state: vertex_input_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_input_assembly_state: input_assembly_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_tessellation_state: tessellation_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_viewport_state: viewport_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_rasterization_state: rasterization_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_multisample_state: multisample_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_depth_stencil_state: depth_stencil_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_color_blend_state: color_blend_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), p_dynamic_state: dynamic_state_vk .as_ref() - .map(ptr::from_ref) + .map(|p| -> *const _ { p }) .unwrap_or(ptr::null()), layout: layout.handle(), render_pass: render_pass_vk, From d7f7e49d18a6c3a0147566d941793d9792cfc4a1 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:29:38 +0200 Subject: [PATCH 3/7] #2516 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a39cc68b54..87eab5b405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - [raw-window-handle](https://crates.io/raw-window-handle) 0.6 - [winit](https://crates.io/crates/winit) 0.29 - [regex](https://crates.io/crates/regex) has been replaced with [nom](https://crates.io/crates/nom) 7.1 +- Rust version: 1.72.0 ### Public dependency updates From bb622ea4baa68667f06e0660c264c87381aec0b6 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:54:50 +0200 Subject: [PATCH 4/7] Add `ResourceMemory::from_device_memory_unchecked` (#2519) --- vulkano/src/memory/mod.rs | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/vulkano/src/memory/mod.rs b/vulkano/src/memory/mod.rs index b5564cd115..4c73cab0d0 100644 --- a/vulkano/src/memory/mod.rs +++ b/vulkano/src/memory/mod.rs @@ -146,11 +146,43 @@ impl ResourceMemory { unsafe { Self::new_dedicated_unchecked(Arc::new(device_memory)) } } - #[cfg_attr(not(feature = "document_unchecked"), doc(hidden))] + /// Same as [`new_dedicated`], except that this allows creating aliasing resources. + /// + /// # Safety + /// + /// - Two resources must not alias each other, and if they do, you must ensure correct + /// synchronization yourself. pub unsafe fn new_dedicated_unchecked(device_memory: Arc) -> Self { + let size = device_memory.allocation_size(); + + unsafe { Self::from_device_memory_unchecked(device_memory, 0, size) } + } + + /// Creates a new `ResourceMemory` from the given portion of the given device memory block. You + /// may use this when you need to portion an existing memory block in a specific way. Note that + /// when you don't have this requirement of placing resources at specific offsets, you should + /// use a memory allocator instead. + /// + /// # Safety + /// + /// - Two resources must not alias each other (as returned by [`Buffer::memory_requirements`] + /// or [`Image::memory_requirements`]), and if they do, you must ensure correct + /// synchronization yourself. + /// + /// # Panics + /// + /// - Panics if `offset + size` is greater than `device_memory.allocation_size()`. + pub unsafe fn from_device_memory_unchecked( + device_memory: Arc, + offset: DeviceSize, + size: DeviceSize, + ) -> Self { + assert!(offset <= device_memory.allocation_size()); + assert!(size <= device_memory.allocation_size() - offset); + ResourceMemory { - offset: 0, - size: device_memory.allocation_size(), + offset, + size, allocation_type: AllocationType::Unknown, allocation_handle: AllocationHandle::null(), suballocation_handle: None, From c03e2b926c86e8e8570cf312c22fb0343154610b Mon Sep 17 00:00:00 2001 From: Rua Date: Fri, 19 Apr 2024 13:55:23 +0200 Subject: [PATCH 5/7] #2519 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87eab5b405..3892c4284b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -131,6 +131,7 @@ Changes to vulkano-util: - Support for the `ext_conservative_rasterization` extension. - Support for the `extended_dynamic_state3_conservative_rasterization_mode` device feature. - Support for the `extended_dynamic_state3_extra_primitive_overestimation_size` device feature. +- Added `ResourceMemory::from_device_memory_unchecked`. - Vulkano-shaders: Support for Vulkan 1.3 target environment. - Vulkano-shaders: Added `generate_structs: true` option that may be used to disable rust structs from generating. Useful in e.g. rust-gpu contexts where such functionality is not needed. - Vulkano-util: `VulkanoWindowsRenderer::swapchain_image_views` allows access to the swapchain images. From 42e4d0b7c3ff742d81339cadfd291257ee864110 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Sun, 5 May 2024 22:17:47 +0200 Subject: [PATCH 6/7] Fix `shaderc` dependency version See https://github.com/vulkano-rs/vulkano/pull/2467#issuecomment-2094935117 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 31c0b24ec6..746f52a87f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ quote = "1.0" raw-window-handle = "0.6" serde = "1.0" serde_json = "1.0" -shaderc = "0.8" +shaderc = "0.8.3" slabbin = "1.0" smallvec = "1.8" syn = "2.0" From 978c922e1b9dda8bfd6040aa057fd15a5d5a9ed2 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Sat, 1 Jun 2024 15:42:17 +0200 Subject: [PATCH 7/7] Fix latest clippy warning --- vulkano/src/device/physical.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vulkano/src/device/physical.rs b/vulkano/src/device/physical.rs index c1ae355e98..1586abef72 100644 --- a/vulkano/src/device/physical.rs +++ b/vulkano/src/device/physical.rs @@ -812,7 +812,10 @@ impl PhysicalDevice { .collect() }; - *self.display_plane_properties.write() = properties_raw.clone(); + self.display_plane_properties + .write() + .clone_from(&properties_raw); + Ok(properties_raw) }