pub fn wait_for_fences<'a>(
        &self,
        fences: impl IntoIterator<Item = &'a mut (impl BorrowMut<Fence<B>> + 'a)>,
        wait_for: WaitFor,
        timeout_ns: u64,
    ) -> Result<bool, OomOrDeviceLost> {
        let fences = fences
            .into_iter()
            .map(|f| f.borrow_mut())
            .collect::<SmallVec<[_; 32]>>();

        unsafe {
            if !self
                .device
                .wait_for_fences(fences.iter().map(|f| f.raw()), wait_for, timeout_ns)?
            {
                return Ok(false);
            }
        }

        let mut epoch_locks = SmallVec::<[_; 32]>::new();
        for fence in &fences {
            let family_index = self.families_indices[fence.epoch().queue.family().0];
            while family_index >= epoch_locks.len() {
                epoch_locks.push(None);
            }
        }

        match wait_for {
            WaitFor::Any => {
                for fence in fences {
                    if unsafe { self.device.get_fence_status(fence.raw()) }? {
                        let epoch = unsafe {
                            /*status checked*/
                            fence.mark_signaled()
                        };
                        let family_index = self.families_indices[epoch.queue.family().0];
                        let lock = epoch_locks[family_index]
                            .get_or_insert_with(|| self.epochs[family_index].write());
                        let queue_epoch = &mut lock[epoch.queue.index()];
                        *queue_epoch = max(*queue_epoch, epoch.epoch);
                    }
                }
            }
            WaitFor::All => {
                for fence in fences {
                    let epoch = unsafe {
                        /*all fences signaled*/
                        fence.mark_signaled()
                    };
                    let family_index = self.families_indices[epoch.queue.family().0];
                    let lock = epoch_locks[family_index]
                        .get_or_insert_with(|| self.epochs[family_index].write());
                    let queue_epoch = &mut lock[epoch.queue.index()];
                    *queue_epoch = max(*queue_epoch, epoch.epoch);
                }
            }
        }
        Ok(true)
    }
/// Wait for the fences become signeled.
Wait for the fences become signeled.
Wait for the fences become signeled .
pub fn wait_for_fences<'a>(
        &self,
        fences: impl IntoIterator<Item = &'a mut (impl BorrowMut<Fence<B>> + 'a)>,
        wait_for: WaitFor,
        timeout_ns: u64,
    ) -> Result<bool, OomOrDeviceLost> {
        let fences = fences
            .into_iter()
            .map(|f| f.borrow_mut())
            .collect::<SmallVec<[_; 32]>>();
        unsafe {
            if !self
                .device
                .wait_for_fences(fences.iter().map(|f| f.raw()), wait_for, timeout_ns)?
            {
                return Ok(false);
            }
        }
        let mut epoch_locks = SmallVec::<[_; 32]>::new();
        for fence in &fences {
            let family_index = self.families_indices[fence.epoch().queue.family().0];
            while family_index >= epoch_locks.len() {
                epoch_locks.push(None);
            }
        }
        match wait_for {
            WaitFor::Any => {
                for fence in fences {
                    if unsafe { self.device.get_fence_status(fence.raw()) }? {
                        let epoch = unsafe {
                            /*status checked*/
                            fence.mark_signaled()
                        };
                        let family_index = self.families_indices[epoch.queue.family().0];
                        let lock = epoch_locks[family_index]
                            .get_or_insert_with(|| self.epochs[family_index].write());
                        let queue_epoch = &mut lock[epoch.queue.index()];
                        *queue_epoch = max(*queue_epoch, epoch.epoch);
                    }
                }
            }
            WaitFor::All => {
                for fence in fences {
                    let epoch = unsafe {
                        /*all fences signaled*/
                        fence.mark_signaled()
                    };
                    let family_index = self.families_indices[epoch.queue.family().0];
                    let lock = epoch_locks[family_index]
                        .get_or_insert_with(|| self.epochs[family_index].write());
                    let queue_epoch = &mut lock[epoch.queue.index()];
                    *queue_epoch = max(*queue_epoch, epoch.epoch);
                }
            }
        }
        Ok(true)
    }
pub fn wait_for_fences < ' a > ( & self , fences : impl IntoIterator < Item = & ' a mut ( impl BorrowMut < Fence < B > > + ' a ) > , wait_for : WaitFor , timeout_ns : u64 , ) -> Result < bool , OomOrDeviceLost > { let fences = fences . into_iter ( ) . map ( | f | f . borrow_mut ( ) ) . collect :: < SmallVec < [ _ ; 32 ] > > ( ) ; unsafe { if ! self . device . wait_for_fences ( fences . iter ( ) . map ( | f | f . raw ( ) ) , wait_for , timeout_ns ) ? { return Ok ( false ) ; } } let mut epoch_locks = SmallVec :: < [ _ ; 32 ] > :: new ( ) ; for fence in & fences { let family_index = self . families_indices [ fence . epoch ( ) . queue . family ( ) . 0 ] ; while family_index >= epoch_locks . len ( ) { epoch_locks . push ( None ) ; } } match wait_for { WaitFor :: Any => { for fence in fences { if unsafe { self . device . get_fence_status ( fence . raw ( ) ) } ? { let epoch = unsafe { /*status checked*/ fence . mark_signaled ( ) } ; let family_index = self . families_indices [ epoch . queue . family ( ) . 0 ] ; let lock = epoch_locks [ family_index ] . get_or_insert_with ( | | self . epochs [ family_index ] . write ( ) ) ; let queue_epoch = & mut lock [ epoch . queue . index ( ) ] ; * queue_epoch = max ( * queue_epoch , epoch . epoch ) ; } } } WaitFor :: All => { for fence in fences { let epoch = unsafe { /*all fences signaled*/ fence . mark_signaled ( ) } ; let family_index = self . families_indices [ epoch . queue . family ( ) . 0 ] ; let lock = epoch_locks [ family_index ] . get_or_insert_with ( | | self . epochs [ family_index ] . write ( ) ) ; let queue_epoch = & mut lock [ epoch . queue . index ( ) ] ; * queue_epoch = max ( * queue_epoch , epoch . epoch ) ; } } } Ok ( true ) }
Wait for the fences become signeled.
Wait for the fences become signeled .
&self
fences
impl IntoIterator<Item = &'a mut (impl BorrowMut<Fence<B>> + 'a)>
wait_for
WaitFor
timeout_ns
u64
&self
fences
impl IntoIterator<Item = &'a mut (impl BorrowMut<Fence<B>> + 'a)>
wait_for
WaitFor
timeout_ns
u64