From 74ac8f3ac49d1914b8e09d4f98846186b5a1e212 Mon Sep 17 00:00:00 2001 From: Maik Klein Date: Wed, 9 Jan 2019 19:56:57 +0100 Subject: [PATCH 1/2] Add event function --- ash/src/device.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ash/src/device.rs b/ash/src/device.rs index 0d0312a..24ac9d4 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -256,6 +256,51 @@ pub trait DeviceV1_0 { ); } + unsafe fn create_event( + &self, + create_info: &vk::EventCreateInfo, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult { + let mut event = mem::uninitialized(); + let err_code = self.fp_v1_0().create_event( + self.handle(), + create_info, + allocation_callbacks.as_raw_ptr(), + &mut event, + ); + match err_code { + vk::Result::SUCCESS => Ok(event), + _ => Err(err_code), + } + } + + /// Returns true if the event was set, and false if the event was reset, otherwise it will + /// return the error code. + unsafe fn get_event_status(&self, event: vk::Event) -> VkResult { + let err_code = self.fp_v1_0().get_event_status(self.handle(), event); + match err_code { + vk::Result::EVENT_SET => Ok(true), + vk::Result::EVENT_RESET => Ok(false), + _ => Err(err_code), + } + } + + unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> { + let err_code = self.fp_v1_0().set_event(self.handle(), event); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> { + let err_code = self.fp_v1_0().reset_event(self.handle(), event); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + unsafe fn destroy_fence( &self, fence: vk::Fence, From 6e5029cac9552616787c9621d890691a1c5bdf99 Mon Sep 17 00:00:00 2001 From: Maik Klein Date: Thu, 10 Jan 2019 22:34:53 +0100 Subject: [PATCH 2/2] Add command events --- ash/src/device.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ash/src/device.rs b/ash/src/device.rs index 24ac9d4..ba6783a 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -300,6 +300,49 @@ pub trait DeviceV1_0 { _ => Err(err_code), } } + unsafe fn cmd_set_event( + &self, + command_buffer: vk::CommandBuffer, + event: vk::Event, + stage_mask: vk::PipelineStageFlags, + ) { + self.fp_v1_0() + .cmd_set_event(command_buffer, event, stage_mask); + } + unsafe fn cmd_reset_event( + &self, + command_buffer: vk::CommandBuffer, + event: vk::Event, + stage_mask: vk::PipelineStageFlags, + ) { + self.fp_v1_0() + .cmd_reset_event(command_buffer, event, stage_mask); + } + + unsafe fn cmd_wait_events( + &self, + command_buffer: vk::CommandBuffer, + events: &[vk::Event], + src_stage_mask: vk::PipelineStageFlags, + dst_stage_mask: vk::PipelineStageFlags, + memory_barriers: &[vk::MemoryBarrier], + buffer_memory_barriers: &[vk::BufferMemoryBarrier], + image_memory_barriers: &[vk::ImageMemoryBarrier], + ) { + self.fp_v1_0().cmd_wait_events( + command_buffer, + events.len() as _, + events.as_ptr(), + src_stage_mask, + dst_stage_mask, + memory_barriers.len() as _, + memory_barriers.as_ptr(), + buffer_memory_barriers.len() as _, + buffer_memory_barriers.as_ptr(), + image_memory_barriers.len() as _, + image_memory_barriers.as_ptr(), + ); + } unsafe fn destroy_fence( &self,