fn allocate_query_pair(&mut self, device: &wgpu::Device) -> QueryPoolQueryAddress {
        let num_pools = self.active_frame.query_pools.len();

        if let Some(active_pool) = self.active_frame.query_pools.last_mut() {
            if active_pool.capacity > active_pool.num_used_queries {
                let address = QueryPoolQueryAddress {
                    pool_idx: num_pools as u32 - 1,
                    query_idx: active_pool.num_used_queries,
                };
                active_pool.num_used_queries += 2;
                assert!(active_pool.num_used_queries <= active_pool.capacity);
                return address;
            }
        }

        let mut new_pool = if let Some(reused_pool) = self.unused_pools.pop() {
            reused_pool
        } else {
            QueryPool::new(
                self.active_frame
                    .query_pools
                    .iter()
                    .map(|pool| pool.capacity)
                    .sum::<u32>()
                    .max(self.size_for_new_query_pools)
                    .min(QUERY_SET_MAX_QUERIES),
                device,
            )
        };
        new_pool.num_used_queries += 2;
        self.active_frame.query_pools.push(new_pool);

        QueryPoolQueryAddress {
            pool_idx: self.active_frame.query_pools.len() as u32 - 1,
            query_idx: 0,
        }
    }
// Reserves two query objects.
// Our query pools always have an even number of queries, so we know the next query is the next in the same pool.
Reserves two query objects.
Our query pools always have an even number of queries, so we know the next query is the next in the same pool.
Reserves two query objects . Our query pools always have an even number of queries so we know the next query is the next in the same pool .
fn allocate_query_pair(&mut self, device: &wgpu::Device) -> QueryPoolQueryAddress {
        let num_pools = self.active_frame.query_pools.len();
        if let Some(active_pool) = self.active_frame.query_pools.last_mut() {
            if active_pool.capacity > active_pool.num_used_queries {
                let address = QueryPoolQueryAddress {
                    pool_idx: num_pools as u32 - 1,
                    query_idx: active_pool.num_used_queries,
                };
                active_pool.num_used_queries += 2;
                assert!(active_pool.num_used_queries <= active_pool.capacity);
                return address;
            }
        }
        let mut new_pool = if let Some(reused_pool) = self.unused_pools.pop() {
            reused_pool
        } else {
            QueryPool::new(
                self.active_frame
                    .query_pools
                    .iter()
                    .map(|pool| pool.capacity)
                    .sum::<u32>()
                    .max(self.size_for_new_query_pools)
                    .min(QUERY_SET_MAX_QUERIES),
                device,
            )
        };
        new_pool.num_used_queries += 2;
        self.active_frame.query_pools.push(new_pool);
        QueryPoolQueryAddress {
            pool_idx: self.active_frame.query_pools.len() as u32 - 1,
            query_idx: 0,
        }
    }
fn allocate_query_pair ( & mut self , device : & wgpu :: Device ) -> QueryPoolQueryAddress { let num_pools = self . active_frame . query_pools . len ( ) ; if let Some ( active_pool ) = self . active_frame . query_pools . last_mut ( ) { if active_pool . capacity > active_pool . num_used_queries { let address = QueryPoolQueryAddress { pool_idx : num_pools as u32 - 1 , query_idx : active_pool . num_used_queries , } ; active_pool . num_used_queries += 2 ; assert ! ( active_pool num_used_queries active_pool capacity ) ; return address ; } } let mut new_pool = if let Some ( reused_pool ) = self . unused_pools . pop ( ) { reused_pool } else { QueryPool :: new ( self . active_frame . query_pools . iter ( ) . map ( | pool | pool . capacity ) . sum :: < u32 > ( ) . max ( self . size_for_new_query_pools ) . min ( QUERY_SET_MAX_QUERIES ) , device , ) } ; new_pool . num_used_queries += 2 ; self . active_frame . query_pools . push ( new_pool ) ; QueryPoolQueryAddress { pool_idx : self . active_frame . query_pools . len ( ) as u32 - 1 , query_idx : 0 , } }
Reserves two query objects.
Reserves two query objects .
&mut self
device
&wgpu::Device
&mut self
device
&wgpu::Device