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

WebGPURenderer: Introduce waitForGPU #29686

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ class Renderer {

}

async waitForGPUWorkDone() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to shorten the name a bit? E.g. waitForGPU()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't mind but then I feel like we miss the concept of completion of task, such as waitForGPUCompletion, or waitForGPUIdle.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, waitForGPUWorkDone() is similar to the WebGPU api.

FWIW, other options are waitForGPUResolve(), waitForGPUToResolve(), or waitForGPUToFullyResolve().

Copy link
Collaborator

Choose a reason for hiding this comment

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

My first thought was whether we could shorten the name too... I just think it's understanding that we're waiting for the GPU to finish tasks or be available?

renderer.compute(veryHeavyComputeProgram)
await renderer.waitForGPU() // Ensures the CPU waits for the GPU to complete its operations
await renderer.backend.resolveTimestampAsync( veryHeavyComputeProgram, 'compute' );

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's go for waitForGPU() then!


await this.backend.waitForGPUWorkDone();

}

setMRT( mrt ) {

this._mrt = mrt;
Expand Down
5 changes: 5 additions & 0 deletions src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class WebGLBackend extends Backend {

}

async waitForGPUWorkDone() {

await this.utils._clientWaitAsync();

}

initTimestampQuery( renderContext ) {

Expand Down
6 changes: 6 additions & 0 deletions src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,12 @@ class WebGPUBackend extends Backend {

}

async waitForGPUWorkDone() {

await this.device.queue.onSubmittedWorkDone();

}

// render object

draw( renderObject, info ) {
Expand Down