mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-23 07:21:31 +11:00
better single fences, support dummy submissions
This commit is contained in:
parent
2c6886401d
commit
241416cf89
|
@ -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 result = match fenceCount {
|
||||||
|
0 => Ok(true),
|
||||||
|
1 => unsafe {
|
||||||
|
gpu.device.wait_for_fence(&**pFences, timeout)
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
let fence_slice = unsafe {
|
let fence_slice = unsafe {
|
||||||
slice::from_raw_parts(pFences, fenceCount as _)
|
slice::from_raw_parts(pFences, fenceCount as _)
|
||||||
};
|
};
|
||||||
let fences = fence_slice
|
let fences = fence_slice
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|fence| &**fence);
|
.map(|fence| &**fence);
|
||||||
|
|
||||||
let wait_for = match waitAll {
|
let wait_for = match waitAll {
|
||||||
VK_FALSE => WaitFor::Any,
|
VK_FALSE => WaitFor::Any,
|
||||||
_ => WaitFor::All,
|
_ => 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),
|
||||||
|
|
Loading…
Reference in a new issue