]> git.nega.tv - josh/narcissus/commitdiff
vulkan-sys: Add buffer device address support
authorJosh Simmons <josh@nega.tv>
Mon, 3 Jun 2024 19:08:27 +0000 (21:08 +0200)
committerJosh Simmons <josh@nega.tv>
Mon, 3 Jun 2024 19:08:27 +0000 (21:08 +0200)
external/vulkan-sys/src/flags.rs
external/vulkan-sys/src/functions.rs
external/vulkan-sys/src/lib.rs
external/vulkan-sys/src/structs.rs

index 275b36d49168bbb52c5c93cbfb94149a6f694a16..4c8be059518bc23984f30b810743885fd12151b7 100644 (file)
@@ -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,
index 1926575b1e632823d05a79c79f6f36a4caa71057..65beece7c166c4945a7db3d06e6a3d8b56fdeaf6 100644 (file)
@@ -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,
index b18d778ce3a6f476f515843b14512b13cbda4ae7..efc805d251db58e8b98e80fd46d3c785242e0f0c 100644 (file)
@@ -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)
index 13f5f534467d00dfefcd1782201f8da4debb734d..6393dc42b8e500d75bfeff4fa647f29f51cfc0d9 100644 (file)
@@ -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,