diff --git a/ash/src/extensions/ext/extended_dynamic_state.rs b/ash/src/extensions/ext/extended_dynamic_state.rs new file mode 100644 index 0000000..5ad7ae5 --- /dev/null +++ b/ash/src/extensions/ext/extended_dynamic_state.rs @@ -0,0 +1,198 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct ExtendedDynamicState { + handle: vk::Instance, + extended_dynamic_state_fn: vk::ExtExtendedDynamicStateFn, +} + +impl ExtendedDynamicState { + pub fn new(instance: &I, device: &D) -> Self { + let extended_dynamic_state_fn = vk::ExtExtendedDynamicStateFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { + handle: instance.handle(), + extended_dynamic_state_fn, + } + } + + pub fn name() -> &'static CStr { + vk::ExtExtendedDynamicStateFn::name() + } + + #[doc = ""] + pub unsafe fn cmd_set_cull_mode( + &self, + command_buffer: vk::CommandBuffer, + cull_mode: vk::CullModeFlags, + ) { + self.extended_dynamic_state_fn + .cmd_set_cull_mode_ext(command_buffer, cull_mode) + } + + #[doc = ""] + pub unsafe fn cmd_set_front_face( + &self, + command_buffer: vk::CommandBuffer, + front_face: vk::FrontFace, + ) { + self.extended_dynamic_state_fn + .cmd_set_front_face_ext(command_buffer, front_face) + } + + #[doc = ""] + pub unsafe fn cmd_set_primitive_topology( + &self, + command_buffer: vk::CommandBuffer, + primitive_topology: vk::PrimitiveTopology, + ) { + self.extended_dynamic_state_fn + .cmd_set_primitive_topology_ext(command_buffer, primitive_topology) + } + + #[doc = ""] + pub unsafe fn cmd_set_viewport_with_count( + &self, + command_buffer: vk::CommandBuffer, + viewports: &[vk::Viewport], + ) { + self.extended_dynamic_state_fn + .cmd_set_viewport_with_count_ext( + command_buffer, + viewports.len() as u32, + viewports.as_ptr(), + ) + } + + #[doc = ""] + pub unsafe fn cmd_set_scissor_with_count( + &self, + command_buffer: vk::CommandBuffer, + scissors: &[vk::Rect2D], + ) { + self.extended_dynamic_state_fn + .cmd_set_scissor_with_count_ext( + command_buffer, + scissors.len() as u32, + scissors.as_ptr(), + ) + } + + #[doc = ""] + pub unsafe fn cmd_bind_vertex_buffers2( + &self, + command_buffer: vk::CommandBuffer, + first_binding: u32, + buffers: &[vk::Buffer], + offsets: &[vk::DeviceSize], + sizes: Option<&[vk::DeviceSize]>, + strides: Option<&[vk::DeviceSize]>, + ) { + assert_eq!(offsets.len(), buffers.len()); + let p_sizes = if let Some(sizes) = sizes { + assert_eq!(sizes.len(), buffers.len()); + sizes.as_ptr() + } else { + ptr::null() + }; + let p_strides = if let Some(strides) = strides { + assert_eq!(strides.len(), buffers.len()); + strides.as_ptr() + } else { + ptr::null() + }; + self.extended_dynamic_state_fn.cmd_bind_vertex_buffers2_ext( + command_buffer, + first_binding, + buffers.len() as u32, + buffers.as_ptr(), + offsets.as_ptr(), + p_sizes, + p_strides, + ) + } + + #[doc = ""] + pub unsafe fn cmd_set_depth_test_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_test_enable: bool, + ) { + self.extended_dynamic_state_fn + .cmd_set_depth_test_enable_ext(command_buffer, depth_test_enable.into()) + } + + #[doc = ""] + pub unsafe fn cmd_set_depth_write_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_write_enable: bool, + ) { + self.extended_dynamic_state_fn + .cmd_set_depth_write_enable_ext(command_buffer, depth_write_enable.into()) + } + + #[doc = ""] + pub unsafe fn cmd_set_depth_compare_op( + &self, + command_buffer: vk::CommandBuffer, + depth_compare_op: vk::CompareOp, + ) { + self.extended_dynamic_state_fn + .cmd_set_depth_compare_op_ext(command_buffer, depth_compare_op) + } + + #[doc = ""] + pub unsafe fn cmd_set_depth_bounds_test_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_bounds_test_enable: bool, + ) { + self.extended_dynamic_state_fn + .cmd_set_depth_bounds_test_enable_ext(command_buffer, depth_bounds_test_enable.into()) + } + + #[doc = ""] + pub unsafe fn cmd_set_stencil_test_enable( + &self, + command_buffer: vk::CommandBuffer, + stencil_test_enable: bool, + ) { + self.extended_dynamic_state_fn + .cmd_set_stencil_test_enable_ext(command_buffer, stencil_test_enable.into()) + } + + #[doc = ""] + pub unsafe fn cmd_set_stencil_op( + &self, + command_buffer: vk::CommandBuffer, + face_mask: vk::StencilFaceFlags, + fail_op: vk::StencilOp, + pass_op: vk::StencilOp, + depth_fail_op: vk::StencilOp, + compare_op: vk::CompareOp, + ) { + self.extended_dynamic_state_fn.cmd_set_stencil_op_ext( + command_buffer, + face_mask, + fail_op, + pass_op, + depth_fail_op, + compare_op, + ) + } + + pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn { + &self.extended_dynamic_state_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index e744feb..a5a1c68 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -4,6 +4,7 @@ pub use self::debug_marker::DebugMarker; #[allow(deprecated)] pub use self::debug_report::DebugReport; pub use self::debug_utils::DebugUtils; +pub use self::extended_dynamic_state::ExtendedDynamicState; pub use self::full_screen_exclusive::FullScreenExclusive; pub use self::metal_surface::MetalSurface; pub use self::tooling_info::ToolingInfo; @@ -14,6 +15,7 @@ mod debug_marker; #[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")] mod debug_report; mod debug_utils; +mod extended_dynamic_state; mod full_screen_exclusive; mod metal_surface; mod tooling_info;