大网数据广告活动
Web 标准与前端开发

GPUQuerySet

· 52CE 我爱测

The **`GPUQuerySet`** interface of the WebGPU API is used to record the results of queries on passes, such as occlusion or timestamp queries.

WebGPU API

The GPUQuerySet interface of the WebGPU API is used to record the results of queries on passes, such as occlusion or timestamp queries.

  • Occlusion queries are available on render passes to query whether any fragment samples pass all the per-fragment tests for a set of drawing commands (including scissor, sample mask, alpha to coverage, stencil, and depth tests). To run an occlusion query, an appropriate GPUQuerySet must be provided as the value of the occlusionQuerySet descriptor property when invoking GPUCommandEncoder.beginRenderPass() to run a render pass.

  • Timestamp queries allow applications to write timestamps to a GPUQuerySet. To run a timestamp query, appropriate GPUQuerySets must be provided inside the value of the timestampWrites descriptor property when invoking GPUCommandEncoder.beginRenderPass() to run a render pass, or GPUCommandEncoder.beginComputePass() to run a compute pass.

[!NOTE] The timestamp-query feature needs to be enabled to use timestamp queries.

A GPUQuerySet object instance is created using the GPUDevice.createQuerySet() method.

Instance properties

  • GPUQuerySet.count
    • : A number specifying the number of queries managed by the GPUQuerySet.
  • GPUQuerySet.label
    • : A string providing a label that can be used to identify the object, for example in GPUError messages or console warnings.
  • GPUQuerySet.type
    • : An enumerated value specifying the type of queries managed by the GPUQuerySet.

Instance methods

  • GPUQuerySet.destroy
    • : Destroys the GPUQuerySet.

Examples

The following snippet creates a GPUQuerySet that holds 32 occlusion query results, and then returns the type and count:

const querySet = device.createQuerySet({
  type: "occlusion",
  count: 32,
});

console.log(querySet.count); // 32
console.log(querySet.type); // "occlusion"

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。