From f905308c2497038028714f10852c82efd450adf2 Mon Sep 17 00:00:00 2001 From: Maik Klein Date: Thu, 22 Nov 2018 20:15:58 +0100 Subject: [PATCH] Add NvMeshShader --- ash/src/extensions/mesh_shader.rs | 67 +++++++++++++++++++++++++++++++ ash/src/extensions/mod.rs | 2 + 2 files changed, 69 insertions(+) create mode 100644 ash/src/extensions/mesh_shader.rs diff --git a/ash/src/extensions/mesh_shader.rs b/ash/src/extensions/mesh_shader.rs new file mode 100644 index 0000000..988b34b --- /dev/null +++ b/ash/src/extensions/mesh_shader.rs @@ -0,0 +1,67 @@ +#![allow(dead_code)] +use std::ffi::CStr; +use std::mem; +use version::{DeviceV1_0, InstanceV1_0}; +use vk; + +#[derive(Clone)] +pub struct MeshShader { + mesh_shader_fn: vk::NvMeshShaderFn, +} + +impl MeshShader { + pub fn new(instance: &I, device: &D) -> MeshShader { + let mesh_shader_fn = vk::NvMeshShaderFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + MeshShader { mesh_shader_fn } + } + pub unsafe fn cmd_draw_mesh_tasks_nv( + &self, + command_buffer: vk::CommandBuffer, + task_count: u32, + first_task: u32, + ) { + self.mesh_shader_fn + .cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task); + } + pub unsafe fn cmd_draw_mesh_tasks_indirect_nv( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + draw_count: u32, + stride: u32, + ) { + self.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_nv( + command_buffer, + buffer, + offset, + draw_count, + stride, + ); + } + pub unsafe fn cmd_draw_mesh_tasks_indirect_count_nv( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + self.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_count_nv( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + pub fn name() -> &'static CStr { + CStr::from_bytes_with_nul(b"VK_NV_mesh_shader\0").expect("Wrong extension string") + } +} diff --git a/ash/src/extensions/mod.rs b/ash/src/extensions/mod.rs index dc41390..8d28374 100644 --- a/ash/src/extensions/mod.rs +++ b/ash/src/extensions/mod.rs @@ -5,6 +5,7 @@ pub use self::debug_utils::DebugUtils; pub use self::display_swapchain::DisplaySwapchain; pub use self::ios_surface::IOSSurface; pub use self::macos_surface::MacOSSurface; +pub use self::mesh_shader::MeshShader; pub use self::surface::Surface; pub use self::swapchain::Swapchain; pub use self::wayland_surface::WaylandSurface; @@ -19,6 +20,7 @@ mod debug_utils; mod display_swapchain; mod ios_surface; mod macos_surface; +mod mesh_shader; mod surface; mod swapchain; mod wayland_surface;