From: Josh Simmons Date: Mon, 3 Jun 2024 19:08:27 +0000 (+0200) Subject: vulkan-sys: Add buffer device address support X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=fde354daf4e18cfc737fbd80256a8b081979386b;p=josh%2Fnarcissus vulkan-sys: Add buffer device address support --- diff --git a/external/vulkan-sys/src/flags.rs b/external/vulkan-sys/src/flags.rs index 275b36d..4c8be05 100644 --- a/external/vulkan-sys/src/flags.rs +++ b/external/vulkan-sys/src/flags.rs @@ -109,6 +109,15 @@ impl MemoryHeapFlags { #[repr(C)] pub struct MemoryMapFlags(u32); +#[repr(C)] +pub struct MemoryAllocateFlags(u32); + +impl MemoryAllocateFlags { + pub const DEVICE_MASK: Self = Self(0x00000001); + pub const DEVICE_ADDRESS_BIT: Self = Self(0x00000002); + pub const DEVICE_ADDRESS_CAPTURE_REPLAY_BIT: Self = Self(0x00000004); +} + #[repr(C)] pub struct ImageAspectFlags(u32); impl ImageAspectFlags { @@ -1085,6 +1094,7 @@ impl_flags_u32!( MemoryPropertyFlags, MemoryHeapFlags, MemoryMapFlags, + MemoryAllocateFlags, ImageAspectFlags, SparseMemoryBindFlags, SparseImageFormatFlags, diff --git a/external/vulkan-sys/src/functions.rs b/external/vulkan-sys/src/functions.rs index 1926575..65beece 100644 --- a/external/vulkan-sys/src/functions.rs +++ b/external/vulkan-sys/src/functions.rs @@ -792,6 +792,9 @@ pub type FnGetBufferMemoryRequirements2 = extern "system" fn( pub type FnBindBufferMemory2 = extern "system" fn(device: Device, bind_info_count: u32, *const BindBufferMemoryInfo); +pub type FnGetBufferDeviceAddress = + extern "system" fn(device: Device, info: *const BufferDeviceAddressInfo) -> DeviceAddress; + pub type FnCmdWriteTimestamp = extern "system" fn( command_buffer: CommandBuffer, pipeline_stage: PipelineStageFlags, diff --git a/external/vulkan-sys/src/lib.rs b/external/vulkan-sys/src/lib.rs index b18d778..efc805d 100644 --- a/external/vulkan-sys/src/lib.rs +++ b/external/vulkan-sys/src/lib.rs @@ -607,7 +607,6 @@ pub struct DeviceFunctions { destroy_render_pass: FnDestroyRenderPass, create_semaphore: FnCreateSemaphore, destroy_semaphore: FnDestroySemaphore, - get_semaphore_counter_value: FnGetSemaphoreCounterValue, wait_semaphores: FnWaitSemaphores, signal_semaphore: FnSignalSemaphore, create_fence: FnCreateFence, @@ -684,6 +683,10 @@ pub struct DeviceFunctions { get_buffer_memory_requirements2: FnGetBufferMemoryRequirements2, bind_buffer_memory2: FnBindBufferMemory2, + // VERSION_1_2 + get_buffer_device_address: FnGetBufferDeviceAddress, + get_semaphore_counter_value: FnGetSemaphoreCounterValue, + // VERSION_1_3 cmd_pipeline_barrier2: FnCmdPipelineBarrier2, cmd_wait_events2: FnCmdWaitEvents2, @@ -921,6 +924,11 @@ impl DeviceFunctions { bind_buffer_memory2: transmute::<_, _>(load(c"vkBindBufferMemory2", VERSION_1_1)), // VERSION_1_2 + get_buffer_device_address: transmute::<_, _>(load( + c"vkGetBufferDeviceAddress", + VERSION_1_2, + )), + get_semaphore_counter_value: transmute::<_, _>(load( c"vkGetSemaphoreCounterValue", VERSION_1_2, @@ -2283,6 +2291,15 @@ impl DeviceFunctions { (self.bind_buffer_memory2)(device, bind_infos.len() as u32, bind_infos.as_ptr()) } + #[inline] + pub unsafe fn get_buffer_device_address( + &self, + device: Device, + info: &BufferDeviceAddressInfo, + ) -> DeviceAddress { + (self.get_buffer_device_address)(device, info) + } + #[inline] pub unsafe fn queue_wait_idle(&self, queue: Queue) -> Result { (self.queue_wait_idle)(queue) diff --git a/external/vulkan-sys/src/structs.rs b/external/vulkan-sys/src/structs.rs index 13f5f53..6393dc4 100644 --- a/external/vulkan-sys/src/structs.rs +++ b/external/vulkan-sys/src/structs.rs @@ -256,6 +256,25 @@ impl Default for MemoryAllocateInfo { } } +#[repr(C)] +pub struct MemoryAllocateFlagsInfo { + pub _type: StructureType, + pub _next: *const c_void, + pub flags: MemoryAllocateFlags, + pub device_mask: u32, +} + +impl Default for MemoryAllocateFlagsInfo { + fn default() -> Self { + MemoryAllocateFlagsInfo { + _type: StructureType::MemoryAllocateFlagsInfo, + _next: std::ptr::null(), + flags: MemoryAllocateFlags::default(), + device_mask: 0, + } + } +} + #[repr(C)] pub struct MemoryRequirements { pub size: DeviceSize, // Specified in bytes @@ -1870,6 +1889,23 @@ impl Default for BufferViewCreateInfo { } } +#[repr(C)] +pub struct BufferDeviceAddressInfo { + pub _type: StructureType, + pub _next: *const c_void, + pub buffer: Buffer, +} + +impl Default for BufferDeviceAddressInfo { + fn default() -> Self { + BufferDeviceAddressInfo { + _type: StructureType::BufferDeviceAddressInfo, + _next: std::ptr::null(), + buffer: Buffer::null(), + } + } +} + #[repr(C)] pub struct ImageSubresource { pub aspect_mask: ImageAspectFlags,