-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGPURenderer: Introduce TimestampQueryPool #30359
base: dev
Are you sure you want to change the base?
WebGPURenderer: Introduce TimestampQueryPool #30359
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@@ -0,0 +1,29 @@ | |||
class TimestampQueryPool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding the remaining documentation for the the ctor, properties the dispose()
method and the class itself? It would be also good to document the derived classes (at least the bits which are added to the base implementation)
*/ | ||
async resolveTimestampAsync( /*renderContext, type*/ ) { } | ||
async resolveAllTimestampsAsync( type = 'render' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you we need the *All*
term in the name? How about resolveTimestampsAsync()
?
|
||
if ( renderContextData.activeQuery !== null ) { | ||
|
||
this.gl.beginQuery( this.disjoint.TIME_ELAPSED_EXT, renderContextData.activeQuery ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice to see the timestamp related code is moved into specific modules. That makes the backends easier to maintain.
Description
Refactor of timestamp and timer query handling in WebGPU/WebGL for the WebGPURenderer.
It is now more stable and performant through the use of TimestampQueryPool, which maintains a single querySet per type (render/compute) and global buffers. This resolves multiple errors and limitations that users have previously reported.
The API now supports multiple render passes (postprocessing) through a new
resolveAllTimestampsAsync
method in theRenderer
, which resolves all timestamps appended in the loop from different render/compute calls.Another significant improvement addresses a previous limitation by separating compute and render contexts. Compute operations can now be monitored independently of render calls, as they are often isolated for tasks such as simulations and other complex calculations (with the exception of
material.geometryNode
).Example of the new API:
While testing the tool I took the opportunity to improve one of the main example that seems to be affected by excessive buffer access within the loop, resolved by using const and vars:
Before (in WebGPU velocity affects performances 8/9ms per compute):
After quick optimization tests (velocity compute program speed up by ~50%):
If that's ok this refactor will introduce breaking changes. Rather than attempting to maintain backwards compatibility, which would significantly pollute the codebase, I will document the necessary updates in the migration guide for affected components.
This contribution is funded by Utsubo