Switch back to Mutex<Vec<>> instead of MsQueue

This commit is contained in:
Nicolas Koch 2017-07-14 10:10:52 +02:00
parent a04f214715
commit 710dec40e5
3 changed files with 8 additions and 8 deletions

@ -1 +1 @@
Subproject commit eee9d536bc12eeeca6d57310d60cd05824960a62
Subproject commit 4fbb8cb45e144ff63383b48fb1d3244522602438

View File

@ -89,7 +89,6 @@
//!
//! TODO: write
use crossbeam::sync::MsQueue;
use fnv::FnvHasher;
use smallvec::SmallVec;
use std::collections::HashMap;
@ -135,7 +134,7 @@ pub struct Device {
features: Features,
extensions: DeviceExtensions,
allocation_count: Mutex<u32>,
fence_pool: MsQueue<vk::Fence>,
fence_pool: Mutex<Vec<vk::Fence>>,
}
// The `StandardCommandPool` type doesn't implement Send/Sync, so we have to manually reimplement
@ -309,7 +308,7 @@ impl Device {
},
extensions: (&extensions).into(),
allocation_count: Mutex::new(0),
fence_pool: MsQueue::new(),
fence_pool: Mutex::new(Vec::new()),
});
// Iterator for the produced queues.
@ -435,7 +434,7 @@ impl Device {
&self.allocation_count
}
pub(crate) fn fence_pool(&self) -> &MsQueue<vk::Fence> {
pub(crate) fn fence_pool(&self) -> &Mutex<Vec<vk::Fence>> {
&self.fence_pool
}
}
@ -460,7 +459,7 @@ impl Drop for Device {
#[inline]
fn drop(&mut self) {
unsafe {
while let Some(raw_fence) = self.fence_pool.try_pop() {
for &raw_fence in self.fence_pool.lock().unwrap().iter() {
self.vk.DestroyFence(self.device, raw_fence, ptr::null());
}
self.vk.DeviceWaitIdle(self.device);

View File

@ -60,7 +60,8 @@ impl<D> Fence<D>
/// For most applications, using the fence pool should be preferred,
/// in order to avoid creating new fences every frame.
pub fn from_pool(device: D) -> Result<Fence<D>, OomError> {
match device.fence_pool().try_pop() {
let maybe_raw_fence = device.fence_pool().lock().unwrap().pop();
match maybe_raw_fence {
Some(raw_fence) => {
unsafe {
// Make sure the fence isn't signaled
@ -332,7 +333,7 @@ impl<D> Drop for Fence<D>
unsafe {
if self.must_put_in_pool {
let raw_fence = self.fence;
self.device.fence_pool().push(raw_fence);
self.device.fence_pool().lock().unwrap().push(raw_fence);
} else {
let vk = self.device.pointers();
vk.DestroyFence(self.device.internal_object(), self.fence, ptr::null());