Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device: Replace query_count parameter in get_query_pool_results with data.len() #644

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

MarijnS95
Copy link
Collaborator

@MarijnS95 MarijnS95 commented Jul 28, 2022

Supersedes #640

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.

Comment on lines -2028 to +2022
let data_size = mem::size_of::<T>() * data_length;
let data_size = mem::size_of_val(data);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effectively incorporates #640; not to fix a "bug" (there was no bug as far as I understood, the caller was using the wrong the type and doing it that way would still result in the wrong stride hence the wrong output for WITH_AVAILABILITY as result N+1 overwrites N), but simply because this otherwise reads mem::size_of::<T>() * data.len() which should be exactly what mem::size_of_val() returns.

…ith `data.len()`

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.
@MarijnS95 MarijnS95 merged commit c66db26 into master Jul 29, 2022
@MarijnS95 MarijnS95 deleted the remove-query-count branch July 29, 2022 15:25
MarijnS95 added a commit that referenced this pull request Feb 24, 2023
…y_pool_results()`

Commit c66db26 ("device: Replace `query_count` parameter in
`get_query_pool_results` with `data.len()` (#644)") removed this
parameter in favour of using `data.len()` to make it more obvious to use
an appropriate element type that matches the kind of request (see also
 #639) so that the stride is filled in correctly, but it was not
mentioned in the changelog yet.
MarijnS95 added a commit that referenced this pull request Feb 24, 2023
…y_pool_results()` (#710)

Commit c66db26 ("device: Replace `query_count` parameter in
`get_query_pool_results` with `data.len()` (#644)") removed this
parameter in favour of using `data.len()` to make it more obvious to use
an appropriate element type that matches the kind of request (see also
 #639) so that the stride is filled in correctly, but it was not
mentioned in the changelog yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants