GPUCommandEncoder: writeTimestamp() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{non-standard_header}}{{AvailableInWorkers}}

The **writeTimestamp()** method of the {{domxref("GPUCommandEncoder")}} interface encodes a command that writes a timestamp into a {{domxref("GPUQuerySet")}} once the previous commands recorded into the same queued {{domxref("GPUCommandBuffer")}} have been executed by the GPU.

توجه: To use timestamp queries, the timestamp-query {{domxref("GPUSupportedFeatures", "feature", "", "nocode")}} must be enabled in the {{domxref("GPUDevice")}}.

Syntax

js-nolint
writeTimestamp(querySet, queryIndex)

Parameters

  • querySet
  • : A {{domxref("GPUQuerySet")}} object representing the query set that will store the timestamp values.
  • queryIndex
  • : A number representing the index of the query in the query set.

Return value

None ({{jsxref("undefined")}}).

Validation

The following criteria must be met when calling **writeTimestamp()**, otherwise a {{domxref("GPUValidationError")}} is generated and the {{domxref("GPUCommandEncoder")}} becomes invalid:

  • The timestamp-query {{domxref("GPUSupportedFeatures", "feature", "", "nocode")}} is enabled in the {{domxref("GPUDevice")}}.
  • The querySet {{domxref("GPUQuerySet.type")}} is "timestamp"
  • The queryIndex value is less than the {{domxref("GPUQuerySet.count")}}.

Examples

js
// …

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

// …

commandEncoder.writeTimestamp(querySet, 0);

// …

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • The WebGPU API