GeezerVison is showing developer.mozilla.org — GPUCommandEncoder: resolveQuerySet() method - Web APIs | MDN
GPUCommandEncoder: resolveQuerySet() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
js
resolveQuerySet(querySet, firstQuery, queryCount, destination, destinationOffset)
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.
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.
js
// …
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
);
// …