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

浏览器兼容性

另见