createQuerySet method
A set of count queries of type — DeviceFeature.occlusionQuery,
DeviceFeature.timestampQuery or
DeviceFeature.pipelineStatisticsQuery, the feature
QueryType.feature names.
A QueryType.pipelineStatistics set reports exactly the counters
PipelineStatistic.values names at 1.0, in that order, for every 1.x
release: the per-query stride an outside backend returns is part of
the contract. A counter a later minor adds arrives as a new QueryType
with its own stride, never as a sixth value here; this member cannot
gain a parameter to select counters.
Implementation
@override
QuerySet createQuerySet(QueryType type, int count) {
switch (type) {
case QueryType.occlusion:
features.require(DeviceFeature.occlusionQuery, backend: _backend);
case QueryType.timestamp:
features.require(
DeviceFeature.timestampQuery,
backend: _backend,
reason: 'the adapter did not offer timestamp-query',
);
case QueryType.pipelineStatistics:
// TODO(webgpu): pipeline statistics — not in the WebGPU
// specification; a `"pipeline-statistics"` query type behind a
// feature would unblock it.
features.require(
DeviceFeature.pipelineStatisticsQuery,
backend: _backend,
reason: 'WebGPU has no pipeline statistics queries',
);
}
if (count < 1 || count > 4096) {
throw ArgumentError.value(count, 'count', 'WebGPU takes 1 to 4096');
}
return wrapQuerySet(
owner: this,
backend: WebGpuQueries(
_guard(
'a query set of $count',
() => _gpuDevice.createQuerySet(
GPUQuerySetDescriptor(
type: type == QueryType.occlusion ? 'occlusion' : 'timestamp',
count: count,
label: '${type.name} x$count',
),
),
),
),
type: type,
count: count,
);
}