GPUDeviceLostInfo
注意:此功能在 Web Workers 中可用。
GPUDeviceLostInfo 介面是 WebGPU API 的一部分,當 GPUDevice.lost Promise 解析時返回的物件。它提供了裝置丟失的原因資訊。
有關“丟失”狀態的更多資訊,請參閱 GPUDevice.lost 頁面。
例項屬性
示例
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
let device = await adapter.requestDevice(descriptor);
// Use lost to handle lost devices
device.lost.then((info) => {
console.error(`WebGPU device was lost: ${info.message}`);
device = null;
if (info.reason !== "destroyed") {
init();
}
});
// …
}
規範
| 規範 |
|---|
| WebGPU # gpudevicelostinfo |
瀏覽器相容性
載入中…