files/en-us/web/api/gpudevice/createqueryset/index.md
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The createQuerySet() method of the
{{domxref("GPUDevice")}} interface creates a {{domxref("GPUQuerySet")}} that can be used to record the results of queries on passes, such as occlusion or timestamp queries.
createQuerySet(descriptor)
descriptor
count
label {{optional_inline}}
type
"occlusion"
occlusionQuerySet descriptor property when invoking {{domxref("GPUCommandEncoder.beginRenderPass()")}} to run a render pass."timestamp"
: Timestamp queries allow applications to write timestamps to a {{domxref("GPUQuerySet")}}. To run a timestamp query, appropriate {{domxref("GPUQuerySet")}}s must be provided inside the value of the timestampWrites descriptor property when invoking {{domxref("GPUCommandEncoder.beginRenderPass()")}} to run a render pass, or {{domxref("GPUCommandEncoder.beginComputePass()")}} to run a compute pass. Alternatively, you can run a single timestamp query at any time by invoking {{domxref("GPUCommandEncoder.writeTimeStamp()")}} with an appropriate {{domxref("GPUQuerySet")}} as a parameter.
[!NOTE] The
timestamp-queryfeature needs to be enabled to use timestamp queries.
A {{domxref("GPUQuerySet")}} object instance.
The following criteria must be met when calling createQuerySet(), otherwise a {{domxref("GPUValidationError")}} is generated and an invalid {{domxref("GPUQuerySet")}} object is returned:
count is less than or equal to 4096.The following snippet creates a {{domxref("GPUQuerySet")}} that holds 32 occlusion query results:
const querySet = device.createQuerySet({
type: "occlusion",
count: 32,
});
{{Specifications}}
{{Compat}}