-
Notifications
You must be signed in to change notification settings - Fork 345
Description
Currently we restrict the maximum query count to 8192 for all types of query set in WebGPU Spec, there are two reasons for the limitation to 8192 (discussed in #1072):
1) When resolving sparse queries in a query set, we need to traverse the available array (same size with the query count of the query set) to calculate the intervals of queries used in command encoder, then resolve them separately. If we create the query set with a large query count (for example UINT32_MAX/32), it will take time to do the calculation.
2) For occlusion query, the maximum size of visibilityResultBuffer (used as occlusion query set) is 256KB on Metal, to fit the restriction, we decided to limit the maximum size of query set to 64KB. Because the size of a occlusion query result is 8-bytes, the maximum query count is 64 * 1024 / 8.
For other types of query set, there is no limit statement on the maximum size in D3D12/Vulkan/Metal specifications.
I test some values on my local machine, and get different results for each backend and query type.
| Query Type | Max count on D3D12 | Max count on Vulkan | Max count on Metal |
|---|---|---|---|
| Pipeline Statistics | UINT32_MAX/17 | UINT32_MAX | UINT32_MAX / (sizeof(MTLCounterResultStatistic) * 2) |
| Timestamp | UINT32_MAX/17 | UINT32_MAX | UINT32_MAX / (sizeof(MTLCounterResultTimestamp) * 2) |
If exceed the max count, out of memory error is thrown.
Do we need to add another maximum count limit larger than 8192 for pipeline statistics and timestamp queries, or keep them consistent with occlusion query?