From a9d7c451e4d4f1456465aa7015928499504571dd Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 5 Jan 2025 20:24:46 -0800 Subject: [PATCH] Update ash - Use CStr shorthand for extension_name - Function pointer structs were separated between instance and device in https://github.com/ash-rs/ash/pull/734 --- Cargo.lock | 77 ++++++++++++++++++++++++++++++++++---------- Cargo.toml | 4 +-- src/error.rs | 4 +-- src/video/session.rs | 31 +++++++----------- 4 files changed, 75 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80777b7..389b2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,11 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ash" -version = "0.37.0+1.3.260" -source = "git+https://github.com/ash-rs/ash?rev=3f5b96b3638a9ff341584e82188c3ba3aa5cb996#3f5b96b3638a9ff341584e82188c3ba3aa5cb996" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ "libloading", ] @@ -49,12 +50,12 @@ checksum = "5491a308e0214554f07a81d8944abe45f552871c12e3c3c6e7e5d354039a6c4c" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "winapi", + "windows-targets", ] [[package]] @@ -160,23 +161,65 @@ dependencies = [ ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index 031bc99..3443480 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,6 @@ license = "BSD-2-Clause" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ash = { git = "https://github.com/ash-rs/ash", rev="3f5b96b3638a9ff341584e82188c3ba3aa5cb996", version = "0.37.3+1.3.251" } +ash = "0.38.0" h264-reader = "0.7.0" -thiserror = "1.0.44" \ No newline at end of file +thiserror = "1.0.44" diff --git a/src/error.rs b/src/error.rs index 9531492..4dc941f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,8 +6,8 @@ pub enum Error { #[error("A NUL byte was encountered")] Nul(#[from] std::ffi::NulError), - #[error("A NUL byte was encountered")] - FromBytesWithNul(#[from] std::ffi::FromBytesWithNulError), + #[error("CStr too large for static array")] + CStrTooLargeForStaticArray(#[from] ash::vk::CStrTooLargeForStaticArray), #[error("Could not load Vulkan")] Loading(#[from] ash::LoadingError), diff --git a/src/video/session.rs b/src/video/session.rs index 2489316..2a6bc8e 100644 --- a/src/video/session.rs +++ b/src/video/session.rs @@ -2,30 +2,21 @@ use crate::allocation::Allocation; use crate::device::{Device, DeviceShared}; use crate::error::Error; use crate::video::h264::H264StreamInspector; +use ash::khr::{video_decode_queue::DeviceFn as KhrVideoDecodeQueueDeviceFn, video_queue::DeviceFn as KhrVideoQueueDeviceFn}; use ash::vk; use ash::vk::{ - BindVideoSessionMemoryInfoKHR, ExtensionProperties, Extent2D, Format, KhrVideoDecodeQueueFn, KhrVideoQueueFn, - VideoSessionCreateFlagsKHR, VideoSessionCreateInfoKHR, VideoSessionKHR, VideoSessionMemoryRequirementsKHR, + BindVideoSessionMemoryInfoKHR, ExtensionProperties, Extent2D, Format, VideoSessionCreateFlagsKHR, VideoSessionCreateInfoKHR, + VideoSessionKHR, VideoSessionMemoryRequirementsKHR, }; use std::ffi::c_char; use std::iter::zip; use std::ptr::null; use std::sync::Arc; -fn extension_name(name: &[u8]) -> [c_char; 256] { - let mut extension_name = [0; 256]; - - for (y, x) in zip(&mut extension_name, name) { - *y = *x as c_char; - } - - extension_name -} - pub(crate) struct VideoSessionShared { shared_device: Arc, - native_queue_fns: KhrVideoQueueFn, - native_decode_queue_fns: KhrVideoDecodeQueueFn, + native_queue_fns: KhrVideoQueueDeviceFn, + native_decode_queue_fns: KhrVideoDecodeQueueDeviceFn, native_session: VideoSessionKHR, allocations: Vec, } @@ -39,12 +30,12 @@ impl VideoSessionShared { let native_instance = shared_instance.native(); let native_entry = shared_instance.native_entry(); - let extension_name = extension_name(b"VK_STD_vulkan_video_codec_h264_decode"); + let extension_name = c"VK_STD_vulkan_video_codec_h264_decode"; let extension_version = vk::make_api_version(0, 1, 0, 0); let extensions_names = ExtensionProperties::default() .spec_version(extension_version) - .extension_name(extension_name); + .extension_name(extension_name)?; let profiles = stream_inspector.profiles(); @@ -60,7 +51,7 @@ impl VideoSessionShared { .std_header_version(&extensions_names); unsafe { - let queue_fns = KhrVideoQueueFn::load( + let queue_fns = KhrVideoQueueDeviceFn::load( |x| { native_entry .get_instance_proc_addr(native_instance.handle(), x.as_ptr() as *const _) @@ -68,7 +59,7 @@ impl VideoSessionShared { }, // TODO: Is this guaranteed to exist? ); - let decode_queue_fns = KhrVideoDecodeQueueFn::load( + let decode_queue_fns = KhrVideoDecodeQueueDeviceFn::load( |x| { native_entry .get_instance_proc_addr(native_instance.handle(), x.as_ptr() as *const _) @@ -131,11 +122,11 @@ impl VideoSessionShared { self.native_session } - pub(crate) fn queue_fns(&self) -> KhrVideoQueueFn { + pub(crate) fn queue_fns(&self) -> KhrVideoQueueDeviceFn { self.native_queue_fns.clone() } - pub(crate) fn decode_fns(&self) -> KhrVideoDecodeQueueFn { + pub(crate) fn decode_fns(&self) -> KhrVideoDecodeQueueDeviceFn { self.native_decode_queue_fns.clone() }