From a18eb38c7031f04b5af5689aa1da3f2ed49e080d Mon Sep 17 00:00:00 2001 From: hodasemi Date: Fri, 24 Mar 2023 14:33:29 +0100 Subject: [PATCH 1/6] Correct driver version disassembly --- vulkan-rs/src/physicaldevice.rs | 2 +- .../structs/core/physicaldeviceproperties.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/vulkan-rs/src/physicaldevice.rs b/vulkan-rs/src/physicaldevice.rs index bc81034..13da5b2 100644 --- a/vulkan-rs/src/physicaldevice.rs +++ b/vulkan-rs/src/physicaldevice.rs @@ -128,7 +128,7 @@ impl PhysicalDevice { println!( "\nVulkan Device ({}, Driver: {}, {}.{}.{})", properties.device_name(), - properties.driverVersion, + properties.driver_version(), major, minor, patch diff --git a/vulkan-sys/src/structs/core/physicaldeviceproperties.rs b/vulkan-sys/src/structs/core/physicaldeviceproperties.rs index e03cddd..4ce4db6 100644 --- a/vulkan-sys/src/structs/core/physicaldeviceproperties.rs +++ b/vulkan-sys/src/structs/core/physicaldeviceproperties.rs @@ -23,6 +23,24 @@ impl VkPhysicalDeviceProperties { let device_name_cstr = unsafe { CStr::from_ptr(self.deviceName.as_ptr()) }; device_name_cstr.to_str().unwrap().to_string() } + + pub fn driver_version(&self) -> String { + if self.vendorID == 4318 { + let major = (self.driverVersion >> 22) & 0x3ff; + let minor = (self.driverVersion >> 14) & 0x0ff; + let secondary_branch = (self.driverVersion >> 6) & 0x0ff; + let tertiary_branch = self.driverVersion & 0x003f; + + format!( + "{}.{}.{}.{}", + major, minor, secondary_branch, tertiary_branch + ) + } else { + let (major, minor, patch) = VK_GET_VERSION(self.driverVersion); + + format!("{}.{}.{}", major, minor, patch) + } + } } impl Default for VkPhysicalDeviceProperties { From 79ce95f45b5115c126144b7dfbde71c8892d95f2 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Fri, 24 Mar 2023 14:36:02 +0100 Subject: [PATCH 2/6] Improve print output --- vulkan-rs/src/physicaldevice.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vulkan-rs/src/physicaldevice.rs b/vulkan-rs/src/physicaldevice.rs index 13da5b2..0028ded 100644 --- a/vulkan-rs/src/physicaldevice.rs +++ b/vulkan-rs/src/physicaldevice.rs @@ -126,7 +126,7 @@ impl PhysicalDevice { let (major, minor, patch) = VK_GET_VERSION(properties.apiVersion); println!( - "\nVulkan Device ({}, Driver: {}, {}.{}.{})", + "\nVulkan Device (Device Name: {}, Driver Version: {}, Vulkan Version: {}.{}.{})", properties.device_name(), properties.driver_version(), major, From 1358fee34f4077c1d7e594511d5d453e33ea66a5 Mon Sep 17 00:00:00 2001 From: RenovateBot Date: Sun, 26 Mar 2023 03:03:57 +0200 Subject: [PATCH 3/6] Update Rust crate image to 0.24.6 --- vulkan-rs/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vulkan-rs/Cargo.toml b/vulkan-rs/Cargo.toml index 4065306..828bc3a 100644 --- a/vulkan-rs/Cargo.toml +++ b/vulkan-rs/Cargo.toml @@ -5,7 +5,7 @@ authors = ["hodasemi "] edition = "2021" [dependencies] -image = "0.24.5" +image = "0.24.6" vulkan-sys = { path = "../vulkan-sys" } vma-rs = { path = "../vma-rs" } anyhow = { version = "1.0.70", features = ["backtrace"] } From 86a077ed025dfe739b92408c0b7a1f1cfe2fdbf6 Mon Sep 17 00:00:00 2001 From: RenovateBot Date: Wed, 29 Mar 2023 02:04:21 +0200 Subject: [PATCH 4/6] Update Rust crate serde to 1.0.159 --- assetpath/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assetpath/Cargo.toml b/assetpath/Cargo.toml index e847476..5a7c901 100644 --- a/assetpath/Cargo.toml +++ b/assetpath/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -serde = { version = "1.0.158", features = ["derive"] } +serde = { version = "1.0.159", features = ["derive"] } From 5db1d534a6ad22f7522d580a22a255161649565a Mon Sep 17 00:00:00 2001 From: hodasemi Date: Sun, 9 Apr 2023 23:07:15 +0200 Subject: [PATCH 5/6] Use VkString in vk debug --- vulkan-rs/src/instance.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vulkan-rs/src/instance.rs b/vulkan-rs/src/instance.rs index 188cb38..1f5d3be 100644 --- a/vulkan-rs/src/instance.rs +++ b/vulkan-rs/src/instance.rs @@ -12,7 +12,6 @@ use std::os::raw::c_char; use std::os::raw::c_void; use std::ffi::CStr; -use std::ffi::CString; Extensions!(InstanceExtensions, { (xlib_surface, "VK_KHR_xlib_surface"), @@ -433,9 +432,8 @@ impl Instance { } }; - let tmp1 = unsafe { CString::from_raw(msg as *mut c_char) }; - let tmp2 = match tmp1.into_string() { - Ok(string) => string, + let s = match VkString::try_from(msg) { + Ok(s) => s, Err(err) => { println!("{}", err); @@ -444,7 +442,7 @@ impl Instance { }; output += " ):\n\t"; - output += tmp2.as_ref(); + output += s.as_str(); println!("{}", output); From ac4dcf251850e7d5a312ccc560a478b69b9fe57f Mon Sep 17 00:00:00 2001 From: hodasemi Date: Sun, 9 Apr 2023 23:19:41 +0200 Subject: [PATCH 6/6] Simplify acquire next image function --- vulkan-rs/src/swapchain.rs | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/vulkan-rs/src/swapchain.rs b/vulkan-rs/src/swapchain.rs index ae23942..9dc1465 100644 --- a/vulkan-rs/src/swapchain.rs +++ b/vulkan-rs/src/swapchain.rs @@ -8,6 +8,23 @@ use std::sync::{ Arc, Mutex, }; +pub enum NextImageSynchronization<'a> { + Semaphore(&'a Arc), + Fence(&'a Arc), +} + +impl<'a> From<&'a Arc> for NextImageSynchronization<'a> { + fn from(value: &'a Arc) -> Self { + Self::Semaphore(value) + } +} + +impl<'a> From<&'a Arc> for NextImageSynchronization<'a> { + fn from(value: &'a Arc) -> Self { + Self::Fence(value) + } +} + #[derive(Debug)] pub struct Swapchain { width: AtomicU32, @@ -187,17 +204,24 @@ impl Swapchain { Ok(()) } - pub fn acquire_next_image( + pub fn acquire_next_image<'a>( &self, time_out: u64, - present_complete_semaphore: Option<&Arc>, - fence: Option<&Arc>, + synchro: impl Into>, ) -> Result> { + let synchro = synchro.into(); + let res = self.device.acquire_next_image( *self.swapchain.lock().unwrap(), time_out, - present_complete_semaphore.map(|sem| sem.vk_handle()), - fence.map(|fence| fence.vk_handle()), + match synchro { + NextImageSynchronization::Semaphore(semaphore) => Some(semaphore.vk_handle()), + NextImageSynchronization::Fence(_) => None, + }, + match synchro { + NextImageSynchronization::Semaphore(_) => None, + NextImageSynchronization::Fence(fence) => Some(fence.vk_handle()), + }, ); if let Ok(r) = &res {