GPUInternalError
注意:此功能在 Web Workers 中可用。
GPUInternalError 介面是 WebGPU API 的一部分,用於描述應用程式錯誤。當操作因系統或實現特定的原因而失敗,即使所有驗證要求都已滿足時,會丟擲此錯誤。
它代表了 GPUDevice.popErrorScope 和 uncapturederror 事件所暴露的錯誤型別之一。
內部錯誤發生於 WebGPU 實現內部,且該錯誤未被驗證捕獲,也未明確識別為記憶體不足錯誤。這通常意味著您程式碼執行的操作以一種難以透過 WebGPU 的 支援的限制 來表達的方式觸及了系統限制。相同的操作在不同的裝置上可能會成功。這些錯誤通常僅在建立管線(pipeline creation)時丟擲,尤其是在著色器(shader)對於裝置而言過於複雜時。
建構函式
GPUInternalError()-
建立一個新的
GPUInternalError物件例項。
例項屬性
message 屬性繼承自其父級 GPUError。
message實驗性 只讀-
一個字串,提供一個人類可讀的訊息,解釋了錯誤發生的原因。
示例
以下示例使用錯誤作用域來捕獲疑似驗證錯誤,並將其記錄到控制檯。
js
device.pushErrorScope("internal");
let module = device.createShaderModule({
code: shader, // REALLY complex shader
});
device.popErrorScope().then((error) => {
if (error) {
// error is a GPUInternalError object instance
module = null;
console.error(`An error occurred while creating shader: ${error.message}`);
}
});
規範
| 規範 |
|---|
| WebGPU # gpuinternalerror |
瀏覽器相容性
載入中…