Fix issues with calling resolve_queries
multiple times per frame
#80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Turns out there were two issues!
The more glaring one was that wgpu-profiler ignored
QUERY_RESOLVE_BUFFER_ALIGNMENT
.This however only happens when calling
resolve_queries
multiple times a frame: query pools are not shared across frame (sharing across frames would make it impossible to get results of a single frame in unison and would lead to awkward stitching), so the only way to havenum_resolved_queries
be !=0 is when there's multiple resolves in a single frame.And sure enough a simple tests catches this!
Looking closer still though it doesn't make sense we ever use any offset at all since the result is right away copied into the "read buffer" which doesn't have such strict alignment criteria (merely
wgpu::COPY_BUFFER_ALIGNMENT
which is 4). This in turn reveals that HERE we always used an offset of 0 meaning that previous results were overriden 😬Unfortunately, I don't know how to reliably unit test this part of the issue :(