WebGPURenderer: Improve performance tracking logic for better accuracy #28748
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.
Related PR: #28741
Description
This is the second part of #28741, continuing my efforts to enhance performance tracking in the new Renderer:
This PR continues to enhance the accuracy of performance tracking. It now tracks performance more accurately without negatively impacting it. This is achieved by monitoring the number of compute programs executed per animation loop and resetting values only after the total timestamp has been correctly accumulated. This involves checking the total number of calls in each cycle using two new variables: previousFrameCalls and timestampCalls.
Basically the monitoring logic has been unwired from the renderer. The await behavior in resolveTimestampAsync has been updated to a simple promise as it was stalling the app loop, altering the array buffers consumed by the programs resulting in instability.
Before this PR (for a simulation with more than 90 compute shaders per frame):
After this PR (the numbers regarding compute programs now make a lot more sense):
By the way while testing the WebGL part I noticed some odd numbers in the
webgpu_compute_particles_snow.html
example. The WebGPU part runs at around 75 fps, whereas the WebGL backend easily runs at a full 144 fps+ on dev. This is previous to that PR, this PR just highlight the issue. /cc @sunagThis contribution is funded by Utsubo