web api interface
GPUQuerySet
Secure contextAvailable in workers
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
GPUQuerySetmust be provided as the value of theocclusionQuerySetdescriptor property when invokingbeginRenderPass()to run a render pass. -
Timestamp queries allow applications to write timestamps to a
GPUQuerySet. To run a timestamp query, appropriateGPUQuerySets must be provided inside the value of thetimestampWritesdescriptor property when invokingbeginRenderPass()to run a render pass, orbeginComputePass()to run a compute pass.
[!NOTE] The
timestamp-queryfeature needs to be enabled to use timestamp queries.
A GPUQuerySet object instance is created using the createQuerySet() method.
Instance properties
countRead only- : A number specifying the number of queries managed by the
GPUQuerySet.
- : A number specifying the number of queries managed by the
label- : A string providing a label that can be used to identify the object, for example in
GPUErrormessages or console warnings.
- : A string providing a label that can be used to identify the object, for example in
typeRead only- : An enumerated value specifying the type of queries managed by the
GPUQuerySet.
- : An enumerated value specifying the type of queries managed by the
Instance methods
destroy()- : Destroys the
GPUQuerySet.
- : Destroys the
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
- The WebGPU API