web api instance method
GPUDevice: createQuerySet() method
Secure contextAvailable in workers
The createQuerySet() method of the
GPUDevice interface creates a GPUQuerySet that can be used to record the results of queries on passes, such as occlusion or timestamp queries.
Syntax
createQuerySet(descriptor)
Parameters
descriptor- : An object containing the following properties:
count- : A number specifying the number of queries to be managed by the resulting
GPUQuerySet.
- : A number specifying the number of queries to be managed by the resulting
labelOptional- : 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
type- : An enumerated value specifying the type of queries to be managed by the resulting
GPUQuerySet. Possible values are:"occlusion"- : Occlusion queries are available on render passes to query the number of fragment samples that 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.
- : Occlusion queries are available on render passes to query the number of fragment samples that 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
"timestamp"-
: 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. Alternatively, you can run a single timestamp query at any time by invokingwriteTimeStamp()with an appropriateGPUQuerySetas a parameter.[!NOTE] The
timestamp-queryfeature needs to be enabled to use timestamp queries.
-
- : An enumerated value specifying the type of queries to be managed by the resulting
- : An object containing the following properties:
Return value
A GPUQuerySet object instance.
Validation
The following criteria must be met when calling createQuerySet(), otherwise a GPUValidationError is generated and an invalid GPUQuerySet object is returned:
countis less than or equal to 4096.
Examples
The following snippet creates a GPUQuerySet that holds 32 occlusion query results:
const querySet = device.createQuerySet({
type: "occlusion",
count: 32,
});
Specifications
Browser compatibility
See also
- The WebGPU API