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

GPUCommandEncoder: resolveQuerySet() method

· 52CE 我爱测

The **`resolveQuerySet()`** method of the GPUCommandEncoder interface encodes a command that resolves a GPUQuerySet, copying the results into a specified GPUBuffer.

WebGPU API

The resolveQuerySet() method of the GPUCommandEncoder interface encodes a command that resolves a GPUQuerySet, copying the results into a specified GPUBuffer.

Syntax

resolveQuerySet(querySet, firstQuery, queryCount, destination, destinationOffset)

Parameters

  • querySet
    • : A GPUQuerySet object representing the query set to be resolved.
  • firstQuery
    • : The index number of the first query value to be copied over to the buffer.
  • queryCount
    • : The number of queries to be copied over to the buffer, starting from firstQuery.
  • destination
    • : A GPUBuffer representing the buffer to copy the query values to.
  • destinationOffset
    • : A number representing the offset, in bytes, from the start of the buffer to start writing the query values at.

Return value

None (undefined).

Validation

The following criteria must be met when calling resolveQuerySet(), otherwise a GPUValidationError is generated and the GPUCommandEncoder becomes invalid:

  • The destination.buffer's GPUBuffer.usage includes the GPUBufferUsage.QUERY_RESOLVE flag.
  • firstQuery is smaller than the number of queries in querySet.
  • firstQuery + queryCount is smaller than or equal to the number of queries in querySet.
  • destinationOffset is a multiple of 256.
  • destinationOffset + 8 × queryCount is less than or equal to destination.size.

Examples

// …

const queryBuffer = device.createBuffer({
  size: 1024,
  usage: GPUBufferUsage.QUERY_RESOLVE,
});

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

// …

const commandEncoder = device.createCommandEncoder();

// Write timestamps to querySet
commandEncoder.writeTimestamp(querySet, 0);
// …
commandEncoder.writeTimestamp(querySet, 1);
// etc.

// …

commandEncoder.resolveQuerySet(
  querySet,
  0, // First query to write
  16, // Number of queries to count
  queryBuffer,
  0, // Buffer offset
);

// …

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

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

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