Skip to content

Commit

Permalink
device: Replace query_count parameter in get_query_pool_results w…
Browse files Browse the repository at this point in the history
…ith `data.len()` (#644)

A slice is designed to be a cheap view into a continuous segment of
memory and easily recreated with a different offset and size.  This can
be used to our advantage to let the user set exactly how many items they
want to request, while ensuring all returned slots are filled on success
or otherwise return `NOT_READY` if not enough query results could be
copied to user memory (or block if the `WAIT` flag is set).

This also opens the door to accepting `MaybeUninit` in the future and
returning the initialized slice in the `VkResult::Ok(here)` case.
  • Loading branch information
MarijnS95 authored Jul 29, 2022
1 parent 9cb6d38 commit c66db26
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ash/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2016,21 +2016,15 @@ impl Device {
&self,
query_pool: vk::QueryPool,
first_query: u32,
query_count: u32,
data: &mut [T],
flags: vk::QueryResultFlags,
) -> VkResult<()> {
let data_length = query_count as usize;
assert!(
data_length <= data.len(),
"query_count was higher than the length of the slice"
);
let data_size = mem::size_of::<T>() * data_length;
let data_size = mem::size_of_val(data);
(self.device_fn_1_0.get_query_pool_results)(
self.handle(),
query_pool,
first_query,
query_count,
data.len() as u32,
data_size,
data.as_mut_ptr() as *mut _,
mem::size_of::<T>() as _,
Expand Down

0 comments on commit c66db26

Please sign in to comment.