better single fences, support dummy submissions

This commit is contained in:
Dzmitry Malyshau 2019-03-04 16:48:59 -05:00
parent 2c6886401d
commit 241416cf89

View file

@ -1094,6 +1094,23 @@ pub extern "C" fn gfxQueueSubmit(
}; };
unsafe { queue.submit(submission, fence); } unsafe { queue.submit(submission, fence); }
} }
// sometimes, all you need is a fence...
if submits.is_empty() {
use std::iter::empty;
let submission = hal::queue::Submission {
command_buffers: empty(),
wait_semaphores: empty(),
signal_semaphores: empty(),
};
unsafe {
queue.submit::<VkCommandBuffer, _, VkSemaphore, _, _>(
submission,
fence.as_ref(),
)
};
}
VkResult::VK_SUCCESS VkResult::VK_SUCCESS
} }
#[inline] #[inline]
@ -1392,21 +1409,29 @@ pub extern "C" fn gfxWaitForFences(
waitAll: VkBool32, waitAll: VkBool32,
timeout: u64, timeout: u64,
) -> VkResult { ) -> VkResult {
let fence_slice = unsafe { let result = match fenceCount {
slice::from_raw_parts(pFences, fenceCount as _) 0 => Ok(true),
}; 1 => unsafe {
let fences = fence_slice gpu.device.wait_for_fence(&**pFences, timeout)
.into_iter() },
.map(|fence| &**fence); _ => {
let fence_slice = unsafe {
let wait_for = match waitAll { slice::from_raw_parts(pFences, fenceCount as _)
VK_FALSE => WaitFor::Any, };
_ => WaitFor::All, let fences = fence_slice
.into_iter()
.map(|fence| &**fence);
let wait_for = match waitAll {
VK_FALSE => WaitFor::Any,
_ => WaitFor::All,
};
unsafe {
gpu.device.wait_for_fences(fences, wait_for, timeout)
}
}
}; };
match unsafe { match result {
gpu.device.wait_for_fences(fences, wait_for, timeout as _)
} {
Ok(true) => VkResult::VK_SUCCESS, Ok(true) => VkResult::VK_SUCCESS,
Ok(false) => VkResult::VK_TIMEOUT, Ok(false) => VkResult::VK_TIMEOUT,
Err(hal::device::OomOrDeviceLost::OutOfMemory(oom)) => map_oom(oom), Err(hal::device::OomOrDeviceLost::OutOfMemory(oom)) => map_oom(oom),