-
-
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
RFC: WebGPU Occlusion queries #26335
Conversation
Other very useful update, thanks. Maybe we need to add to the example in three.js/test/e2e/puppeteer.js Line 105 in d33b929
|
|
||
let readBuffer; | ||
|
||
if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) { |
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.
Is this the correct condition?
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.
Because I think endOcclusionQuery
is also called in the draw method?
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.
This should catch the case when the last queried object being rendered is the last draw call in the pass. In the draw call. The end is inserted when a new object is seen, to allow handling of multiple draw calls per object (array cameras etc). Otherwise the endOcclusionQuery call could be at the end of the draw method.
According to the docs you can't use a querySet index in multiple beginOcclusionQuery( index ) calls in the same pass, otherwise you could just have repeated begin/end pairs around each draw() call.
examples/webgpu_occlusion.html
Outdated
|
||
generate( builder, output ) { | ||
|
||
return this.uniformNode.build( builder, output ); |
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.
I think, use construct()
instead of generate()
. I update webgpu_instance_uniform
example too. #26336
construct() {
return this.uniformNode;
}
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.
You are the expert here. I obviously copied the instance_uniform example.
What do you think about EDIT: Maybe |
Regarding object.isOccluded - maybe use 'null' to distinguish between objects that have been rendered and those culled before rendering. Regarding returning an array - that has the problem of retaining references to objects and preventing GC if not careful. renderer.isOccluded() would be better of course with a weak set. |
I think we can create a function like The method bellow would only be read once and moved to await renderContextData.readBuffer.mapAsync( GPUMapMode.READ ) |
I added the function I also added the inner function Basically it does the Occlusion Query in the current rendering and uses the data possibly in the next frame, I say possibly because this is asynchronous, I added an internal backend function |
That's because it's asynchronous and the subsequent frame wasn't updating, I updated it here. |
Occlusion query support for WebGPU
Use suggest API from #15450 comments.
Set object.occlusionTest = true to enable testing.
Object has an isOccluded flag set as expected after render pass. Note, the setting of the flag is asynchronous. Example included to demonstrate this.