]> git.nega.tv - josh/narcissus/commitdiff
vulkan-sys: Add VK_EXT_mesh_shader support
authorJoshua Simmons <josh@nega.tv>
Tue, 21 Oct 2025 17:15:36 +0000 (19:15 +0200)
committerJoshua Simmons <josh@nega.tv>
Tue, 21 Oct 2025 21:20:38 +0000 (23:20 +0200)
external/vulkan-sys/src/enums.rs
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 bd4a77dfc067386b32a3b06b818c53906829ecab..650a6c9f87b7f55b425076db88b3f8661da0ab00 100644 (file)
@@ -1323,6 +1323,10 @@ pub enum StructureType {
     AccelerationStructureGeometryMotionTrianglesDataNv = 1000327000,
     PhysicalDeviceRayTracingMotionBlurFeaturesNv = 1000327001,
     AccelerationStructureMotionInfoNv = 1000327002,
+    // Provided by VK_EXT_mesh_shader
+    PhysicalDeviceMeshShaderFeaturesExt = 1000328000,
+    // Provided by VK_EXT_mesh_shader
+    PhysicalDeviceMeshShaderPropertiesExt = 1000328001,
     PhysicalDeviceYcbcr2Plane444FormatsFeaturesExt = 1000330000,
     PhysicalDeviceFragmentDensityMap2FeaturesExt = 1000332000,
     PhysicalDeviceFragmentDensityMap2PropertiesExt = 1000332001,
index 533bcaf9306bb27eb2d7489e03f5c73e714ef1af..23ad2dd33c3685c1ccffa19cf4b98654e9526d98 100644 (file)
@@ -534,6 +534,10 @@ impl ShaderStageFlags {
     pub const MISS_KHR: Self = Self(2048);
     pub const INTERSECTION_KHR: Self = Self(4096);
     pub const CALLABLE_KHR: Self = Self(8192);
+    // Provided by VK_EXT_mesh_shader
+    pub const TASK_EXT: Self = Self(0x00000040);
+    // Provided by VK_EXT_mesh_shader
+    pub const MESH_EXT: Self = Self(0x00000080);
     pub const TASK_NV: Self = Self(64);
     pub const MESH_NV: Self = Self(128);
     pub const SUBPASS_SHADING_HUAWEI: Self = Self(16384);
@@ -869,10 +873,10 @@ impl PipelineStageFlags2 {
     pub const ACCELERATION_STRUCTURE_BUILD_NV: Self = Self(0x02000000);
     // Provided by VK_KHR_synchronization2 with VK_EXT_fragment_density_map
     pub const FRAGMENT_DENSITY_PROCESS_EXT: Self = Self(0x00800000);
-    // Provided by VK_KHR_synchronization2 with VK_NV_mesh_shader
-    pub const TASK_SHADER_NV: Self = Self(0x00080000);
-    // Provided by VK_KHR_synchronization2 with VK_NV_mesh_shader
-    pub const MESH_SHADER_NV: Self = Self(0x00100000);
+    // Provided by VK_KHR_synchronization2 with VK_EXT_mesh_shader
+    pub const TASK_SHADER_EXT: Self = Self(0x00080000);
+    // Provided by VK_KHR_synchronization2 with VK_EXT_mesh_shader
+    pub const MESH_SHADER_EXT: Self = Self(0x00100000);
     // Provided by VK_HUAWEI_subpass_shading
     pub const SUBPASS_SHADING_HUAWEI: Self = Self(0x8000000000);
     // Provided by VK_HUAWEI_invocation_mask
index 1146bb9e56b48a2946ef83e551a0d7fe9f27c9f2..c3ce9abd14ecd969e6dc0a1b5a850f944969e8a0 100644 (file)
@@ -987,3 +987,31 @@ pub type FnDebugUtilsMessengerCallbackExt = extern "system" fn(
     callback_data: &DebugUtilsMessengerCallbackDataExt,
     user_data: *mut c_void,
 ) -> Bool32;
+
+// Provided by VK_EXT_mesh_shader
+pub type FnCmdDrawMeshTasksExt = extern "system" fn(
+    command_buffer: CommandBuffer,
+    group_count_x: u32,
+    group_count_y: u32,
+    group_count_z: u32,
+);
+
+// Provided by VK_EXT_mesh_shader
+pub type FnCmdDrawMeshTasksIndirectExt = extern "system" fn(
+    command_buffer: CommandBuffer,
+    buffer: Buffer,
+    offset: DeviceSize,
+    draw_count: u32,
+    stride: u32,
+);
+
+// Provided by VK_EXT_mesh_shader
+pub type FnCmdDrawMeshTasksIndirectCountExt = extern "system" fn(
+    command_buffer: CommandBuffer,
+    buffer: Buffer,
+    offset: DeviceSize,
+    count_buffer: Buffer,
+    count_buffer_offset: DeviceSize,
+    max_draw_count: u32,
+    stride: u32,
+);
index b66e35162796b8fbc956a6e3b24e6fe51488efdd..5bf435a3811e30b458c08fbcfc9ec5a60c2cf20f 100644 (file)
@@ -2885,3 +2885,79 @@ impl DebugUtilsFunctions {
         )
     }
 }
+
+pub struct MeshShaderFunctions {
+    cmd_draw_mesh_tasks_ext: FnCmdDrawMeshTasksExt,
+    cmd_draw_mesh_tasks_indirect_ext: FnCmdDrawMeshTasksIndirectExt,
+    cmd_draw_mesh_tasks_indirect_count_ext: FnCmdDrawMeshTasksIndirectCountExt,
+}
+
+impl MeshShaderFunctions {
+    pub fn new(instance_functions: &InstanceFunctions, device: Device) -> Self {
+        unsafe {
+            let load_device = |name: &CStr| {
+                instance_functions
+                    .get_device_proc_addr(device, name)
+                    .unwrap_or_else(
+                        #[cold]
+                        || panic!("failed to load device function {}", name.to_string_lossy()),
+                    )
+            };
+
+            Self {
+                cmd_draw_mesh_tasks_ext: transmute::<_, _>(load_device(c"vkCmdDrawMeshTasksEXT")),
+                cmd_draw_mesh_tasks_indirect_ext: transmute::<_, _>(load_device(
+                    c"vkCmdDrawMeshTasksIndirectEXT",
+                )),
+                cmd_draw_mesh_tasks_indirect_count_ext: transmute::<_, _>(load_device(
+                    c"vkCmdDrawMeshTasksIndirectCountEXT",
+                )),
+            }
+        }
+    }
+
+    #[inline]
+    pub unsafe fn cmd_draw_mesh_tasks_ext(
+        &self,
+        command_buffer: CommandBuffer,
+        group_count_x: u32,
+        group_count_y: u32,
+        group_count_z: u32,
+    ) {
+        (self.cmd_draw_mesh_tasks_ext)(command_buffer, group_count_x, group_count_y, group_count_z)
+    }
+
+    #[inline]
+    pub unsafe fn cmd_draw_mesh_tasks_indirect_ext(
+        &self,
+        command_buffer: CommandBuffer,
+        buffer: Buffer,
+        offset: DeviceSize,
+        draw_count: u32,
+        stride: u32,
+    ) {
+        (self.cmd_draw_mesh_tasks_indirect_ext)(command_buffer, buffer, offset, draw_count, stride)
+    }
+
+    #[inline]
+    pub unsafe fn cmd_draw_mesh_tasks_indirect_count_ext(
+        &self,
+        command_buffer: CommandBuffer,
+        buffer: Buffer,
+        offset: DeviceSize,
+        count_buffer: Buffer,
+        count_buffer_offset: DeviceSize,
+        max_draw_count: u32,
+        stride: u32,
+    ) {
+        (self.cmd_draw_mesh_tasks_indirect_count_ext)(
+            command_buffer,
+            buffer,
+            offset,
+            count_buffer,
+            count_buffer_offset,
+            max_draw_count,
+            stride,
+        )
+    }
+}
index 5378103a7b63a4fc1e4eb4afb0054b1f72e36a82..4e87d85e7f5409bbb2438ce0d708019f34556b15 100644 (file)
@@ -3020,6 +3020,67 @@ impl Default for SurfaceFormat2KHR {
     }
 }
 
+#[repr(C)]
+pub struct PhysicalDeviceMeshShaderFeaturesExt {
+    pub _type: StructureType,
+    pub _next: *mut c_void,
+    pub task_shader: Bool32,
+    pub mesh_shader: Bool32,
+    pub multiview_mesh_shader: Bool32,
+    pub primitive_fragment_shading_rate_mesh_shader: Bool32,
+    pub mesh_shader_queries: Bool32,
+}
+
+impl Default for PhysicalDeviceMeshShaderFeaturesExt {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::PhysicalDeviceMeshShaderFeaturesExt;
+        x
+    }
+}
+
+#[repr(C)]
+pub struct PhysicalDeviceMeshShaderPropertiesExt {
+    pub _type: StructureType,
+    pub _next: *mut c_void,
+    pub max_task_work_group_total_count: u32,
+    pub max_task_work_group_count: [u32; 3],
+    pub max_task_work_group_invocations: u32,
+    pub max_task_work_group_size: [u32; 3],
+    pub max_task_payload_size: u32,
+    pub max_task_shared_memory_size: u32,
+    pub max_task_payload_and_shared_memory_size: u32,
+    pub max_mesh_work_group_total_count: u32,
+    pub max_mesh_work_group_count: [u32; 3],
+    pub max_mesh_work_group_invocations: u32,
+    pub max_mesh_work_group_size: [u32; 3],
+    pub max_mesh_shared_memory_size: u32,
+    pub max_mesh_payload_and_shared_memory_size: u32,
+    pub max_mesh_output_memory_size: u32,
+    pub max_mesh_payload_and_output_memory_size: u32,
+    pub max_mesh_output_components: u32,
+    pub max_mesh_output_vertices: u32,
+    pub max_mesh_output_primitives: u32,
+    pub max_mesh_output_layers: u32,
+    pub max_mesh_multiview_view_count: u32,
+    pub mesh_output_per_vertex_granularity: u32,
+    pub mesh_output_per_primitive_granularity: u32,
+    pub max_preferred_task_work_group_invocations: u32,
+    pub max_preferred_mesh_work_group_invocations: u32,
+    pub prefers_local_invocation_vertex_output: Bool32,
+    pub prefers_local_invocation_primitive_output: Bool32,
+    pub prefers_compact_vertex_output: Bool32,
+    pub prefers_compact_primitive_output: Bool32,
+}
+
+impl Default for PhysicalDeviceMeshShaderPropertiesExt {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::PhysicalDeviceMeshShaderPropertiesExt;
+        x
+    }
+}
+
 #[cfg(test)]
 mod test {
     use super::*;