]> git.nega.tv - josh/narcissus/commitdiff
Add vk descriptor management functions
authorJoshua Simmons <josh@nega.tv>
Wed, 2 Nov 2022 21:15:47 +0000 (22:15 +0100)
committerJoshua Simmons <josh@nega.tv>
Wed, 2 Nov 2022 21:15:47 +0000 (22:15 +0100)
ffi/vulkan-sys/src/handles.rs
ffi/vulkan-sys/src/lib.rs
ffi/vulkan-sys/src/structs.rs

index 478d7d4e4ce03ce1f59ecdd621c8fd34a33e2306..ebf32d1add91fa8e8ab139c13cdac7bfa0b310d1 100644 (file)
@@ -20,7 +20,7 @@ pub struct CommandBuffer(u64);
 
 #[repr(C)]
 #[derive(Copy, Clone, PartialEq, Eq, Default, Debug)]
-pub struct DeviceMemory(u64);
+pub struct DeviceMemory(pub u64);
 
 #[repr(C)]
 #[derive(Copy, Clone, PartialEq, Eq, Default, Debug)]
index 7bf66b5ffbe798c49f8ab0d426ac0147d31891c9..7eeba0cc53482d236a14b869faa9b41e9be816e5 100644 (file)
@@ -537,6 +537,12 @@ pub struct DeviceFunctions {
     destroy_sampler: FnDestroySampler,
     create_descriptor_set_layout: FnCreateDescriptorSetLayout,
     destroy_descriptor_set_layout: FnDestroyDescriptorSetLayout,
+    create_descriptor_pool: FnCreateDescriptorPool,
+    destroy_descriptor_pool: FnDestroyDescriptorPool,
+    reset_descriptor_pool: FnResetDescriptorPool,
+    allocate_descriptor_sets: FnAllocateDescriptorSets,
+    free_descriptor_sets: FnFreeDescriptorSets,
+    update_descriptor_sets: FnUpdateDescriptorSets,
     create_pipeline_layout: FnCreatePipelineLayout,
     destroy_pipeline_layout: FnDestroyPipelineLayout,
     create_graphics_pipelines: FnCreateGraphicsPipelines,
@@ -734,6 +740,30 @@ impl DeviceFunctions {
                     cstr!("vkDestroyDescriptorSetLayout"),
                     VERSION_1_0,
                 )),
+                create_descriptor_pool: transmute::<_, _>(load(
+                    cstr!("vkCreateDescriptorPool"),
+                    VERSION_1_0,
+                )),
+                destroy_descriptor_pool: transmute::<_, _>(load(
+                    cstr!("vkDestroyDescriptorPool"),
+                    VERSION_1_0,
+                )),
+                reset_descriptor_pool: transmute::<_, _>(load(
+                    cstr!("vkResetDescriptorPool"),
+                    VERSION_1_0,
+                )),
+                allocate_descriptor_sets: transmute::<_, _>(load(
+                    cstr!("vkAllocateDescriptorSets"),
+                    VERSION_1_0,
+                )),
+                free_descriptor_sets: transmute::<_, _>(load(
+                    cstr!("vkFreeDescriptorSets"),
+                    VERSION_1_0,
+                )),
+                update_descriptor_sets: transmute::<_, _>(load(
+                    cstr!("vkUpdateDescriptorSets"),
+                    VERSION_1_0,
+                )),
                 create_pipeline_layout: transmute::<_, _>(load(
                     cstr!("vkCreatePipelineLayout"),
                     VERSION_1_0,
@@ -1381,6 +1411,79 @@ impl DeviceFunctions {
         (self.destroy_descriptor_set_layout)(device, descriptor_set_layout, allocator)
     }
 
+    #[inline]
+    pub unsafe fn create_descriptor_pool(
+        &self,
+        device: Device,
+        create_info: &DescriptorPoolCreateInfo,
+        allocator: Option<&AllocationCallbacks>,
+        descriptor_pool: &mut DescriptorPool,
+    ) -> Result {
+        (self.create_descriptor_pool)(device, create_info, allocator, descriptor_pool)
+    }
+
+    #[inline]
+    pub unsafe fn destroy_descriptor_pool(
+        &self,
+        device: Device,
+        descriptor_pool: DescriptorPool,
+        allocator: Option<&AllocationCallbacks>,
+    ) {
+        (self.destroy_descriptor_pool)(device, descriptor_pool, allocator)
+    }
+
+    #[inline]
+    pub unsafe fn reset_descriptor_pool(
+        &self,
+        device: Device,
+        descriptor_pool: DescriptorPool,
+        flags: DescriptorPoolResetFlags,
+    ) -> Result {
+        (self.reset_descriptor_pool)(device, descriptor_pool, flags)
+    }
+
+    #[inline]
+    pub unsafe fn allocate_descriptor_sets(
+        &self,
+        device: Device,
+        allocate_info: &DescriptorSetAllocateInfo,
+        descriptor_sets: *mut DescriptorSet,
+    ) -> Result {
+        (self.allocate_descriptor_sets)(device, allocate_info, descriptor_sets)
+    }
+
+    #[inline]
+    pub unsafe fn free_descriptor_sets(
+        &self,
+        device: Device,
+        descriptor_pool: DescriptorPool,
+        descriptor_set_count: u32,
+        descriptor_sets: *const DescriptorSet,
+    ) -> Result {
+        (self.free_descriptor_sets)(
+            device,
+            descriptor_pool,
+            descriptor_set_count,
+            descriptor_sets,
+        )
+    }
+
+    #[inline]
+    pub unsafe fn update_descriptor_sets(
+        &self,
+        device: Device,
+        descriptor_writes: &[WriteDescriptorSet],
+        descriptor_copies: &[CopyDescriptorSet],
+    ) {
+        (self.update_descriptor_sets)(
+            device,
+            descriptor_writes.len() as u32,
+            descriptor_writes.as_ptr(),
+            descriptor_copies.len() as u32,
+            descriptor_copies.as_ptr(),
+        )
+    }
+
     #[inline]
     pub unsafe fn create_pipeline_layout(
         &self,
index a704ec5e43f825227c66c49e1c733abce99ef865..0c0a1e4b40c44bf3c7ae14615841bbca617b17e2 100644 (file)
@@ -1062,7 +1062,7 @@ impl<'a> Default for DescriptorSetLayoutCreateInfo<'a> {
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct DescriptorPoolSize {
-    pub r#type: DescriptorType,
+    pub descriptor_type: DescriptorType,
     pub descriptor_count: u32,
 }
 
@@ -1536,7 +1536,7 @@ pub struct DescriptorImageInfo {
 
 #[repr(C)]
 #[derive(Copy, Clone)]
-pub struct WriteDescriptorSet<'a> {
+pub struct WriteDescriptorSet {
     pub _type: StructureType,
     pub _next: *const c_void,
     /// Destination descriptor set
@@ -1550,14 +1550,14 @@ pub struct WriteDescriptorSet<'a> {
     /// Descriptor type to write (determines which members of the array pointed by pDescriptors are going to be used)
     pub descriptor_type: DescriptorType,
     /// Sampler, image view, and layout for SAMPLER, COMBINED_IMAGE_SAMPLER, {SAMPLED,STORAGE}_IMAGE, and INPUT_ATTACHMENT descriptor types.
-    pub image_info: Option<&'a DescriptorImageInfo>,
+    pub image_info: *const DescriptorImageInfo,
     /// Raw buffer, size, and offset for {UNIFORM,STORAGE}_BUFFER\[_DYNAMIC\] descriptor types.
-    pub buffer_info: Option<&'a DescriptorBufferInfo>,
+    pub buffer_info: *const DescriptorBufferInfo,
     /// Buffer view to write to the descriptor for {UNIFORM,STORAGE}_TEXEL_BUFFER descriptor types.
-    pub texel_buffer_view: Option<&'a BufferView>,
+    pub texel_buffer_view: *const BufferView,
 }
 
-impl<'a> Default for WriteDescriptorSet<'a> {
+impl Default for WriteDescriptorSet {
     fn default() -> Self {
         let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
         x._type = StructureType::WriteDescriptorSet;