From b7aff3b432d853528a47bf99fa3e7f0d841c4112 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 29 Jan 2022 21:39:48 +0100 Subject: [PATCH] extensions/ext: Add VK_EXT_extended_dynamic_state2 (#572) --- Changelog.md | 1 + .../extensions/ext/extended_dynamic_state2.rs | 76 +++++++++++++++++++ ash/src/extensions/ext/mod.rs | 2 + 3 files changed, 79 insertions(+) create mode 100644 ash/src/extensions/ext/extended_dynamic_state2.rs diff --git a/Changelog.md b/Changelog.md index f4fc9ff..0edf1cc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `VK_EXT_extended_dynamic_state2` device extension (#572) - Added `VK_KHR_copy_commands2` device extension (#571) - Added `VK_EXT_private_data` device extension (#570) - Added conversions from `Extent2D` to `Extent3D` and `Rect2D` (#557) diff --git a/ash/src/extensions/ext/extended_dynamic_state2.rs b/ash/src/extensions/ext/extended_dynamic_state2.rs new file mode 100644 index 0000000..223b159 --- /dev/null +++ b/ash/src/extensions/ext/extended_dynamic_state2.rs @@ -0,0 +1,76 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct ExtendedDynamicState2 { + fp: vk::ExtExtendedDynamicState2Fn, +} + +impl ExtendedDynamicState2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::ExtExtendedDynamicState2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// + pub unsafe fn cmd_set_patch_control_points( + &self, + command_buffer: vk::CommandBuffer, + patch_control_points: u32, + ) { + self.fp + .cmd_set_patch_control_points_ext(command_buffer, patch_control_points) + } + + /// + pub unsafe fn cmd_set_rasterizer_discard_enable( + &self, + command_buffer: vk::CommandBuffer, + rasterizer_discard_enable: bool, + ) { + self.fp + .cmd_set_rasterizer_discard_enable_ext(command_buffer, rasterizer_discard_enable.into()) + } + + /// + pub unsafe fn cmd_set_depth_bias_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_bias_enable: bool, + ) { + self.fp + .cmd_set_depth_bias_enable_ext(command_buffer, depth_bias_enable.into()) + } + + /// + pub unsafe fn cmd_set_logic_op( + &self, + command_buffer: vk::CommandBuffer, + logic_op: vk::LogicOp, + ) { + self.fp.cmd_set_logic_op_ext(command_buffer, logic_op) + } + + /// + pub unsafe fn cmd_set_primitive_restart_enable( + &self, + command_buffer: vk::CommandBuffer, + primitive_restart_enable: bool, + ) { + self.fp + .cmd_set_primitive_restart_enable_ext(command_buffer, primitive_restart_enable.into()) + } + + pub fn name() -> &'static CStr { + vk::ExtExtendedDynamicState2Fn::name() + } + + pub fn fp(&self) -> &vk::ExtExtendedDynamicState2Fn { + &self.fp + } +} diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index 22f142a..8260ce6 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -6,6 +6,7 @@ pub use self::debug_marker::DebugMarker; pub use self::debug_report::DebugReport; pub use self::debug_utils::DebugUtils; pub use self::extended_dynamic_state::ExtendedDynamicState; +pub use self::extended_dynamic_state2::ExtendedDynamicState2; pub use self::full_screen_exclusive::FullScreenExclusive; pub use self::metal_surface::MetalSurface; pub use self::physical_device_drm::PhysicalDeviceDrm; @@ -20,6 +21,7 @@ mod debug_marker; mod debug_report; mod debug_utils; mod extended_dynamic_state; +mod extended_dynamic_state2; mod full_screen_exclusive; mod metal_surface; mod physical_device_drm;