From a18eb38c7031f04b5af5689aa1da3f2ed49e080d Mon Sep 17 00:00:00 2001 From: hodasemi Date: Fri, 24 Mar 2023 14:33:29 +0100 Subject: [PATCH] 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 {