GPUDevice: queue 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

注意:此功能在 Web Workers 中可用。

GPUDevice 介面的只讀屬性 queue 返回裝置的第一個 GPUQueue

一個 GPUQueue 物件例項。

示例

基本 GPUQueue 訪問

js
async function init() {
  if (!navigator.gpu) {
    throw Error("WebGPU not supported.");
  }

  const adapter = await navigator.gpu.requestAdapter();
  if (!adapter) {
    throw Error("Couldn't request WebGPU adapter.");
  }

  // Create a GPUDevice
  const device = await adapter.requestDevice();

  // …

  // Common queue use — end current frame by passing array of
  // command buffers to queue for execution
  device.queue.submit([commandEncoder.finish()]);

  // …
}

注意:有關更多佇列示例,請參閱 GPUQueue 參考頁面。

規範

規範
WebGPU
# dom-gpudevice-queue

瀏覽器相容性

另見