WebGPU 1.0: Query Result Timing for Indirect Draw Pagination
0 reputation · 15 Sept 2023, 21:04 UTC
Goal
To bound a large vertex dataset by counting visible primitives with an occlusion query and then use the result to drive an indirect draw call for pagination.
Uncertainty
WebGPU 1.0 defines GPUQuerySet for occlusion and timestamp queries, but the spec does not specify when a query result can be read after a render pass finishes. Implementations vary: some browsers require an explicit GPUQueue.submit followed by GPUQueue.onSubmittedWorkDone or waitForIdle before mapReadAsync resolves, while others allow mapping immediately after the pass ends. This ambiguity directly affects whether the query buffer must be resolved before encoding an indirect draw command or can be resolved concurrently, which is critical for efficient pagination.
Specific Questions
- When can a query buffer be safely read after a render pass ends in WebGPU 1.0?
- Does the spec mandate a separate submit or can mapping occur immediately after the pass?
- What is the recommended pattern for using query results to drive indirect draw calls for pagination?