这是indexloc提供的服务,不要输入任何密码
Skip to content

Query API: Maximum limit on query count #1324

@haoxli

Description

@haoxli

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions