GPUCompilationMessage: length 屬性

可用性有限

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

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

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

GPUCompilationMessage 介面的 length 只讀屬性是一個數字,表示訊息對應的子字串的長度。

一個數字。

準確地說,length 是著色器程式碼子字串中 UTF-16 程式碼單元的數量,該子字串對應於此訊息。如果訊息對應於單個點而不是子字串,則 length 將為 0。

示例

js
const shaderModule = device.createShaderModule({
  code: shaders,
});

const shaderInfo = await shaderModule.getCompilationInfo();
const firstMessage = shaderInfo.messages[0];
console.log(firstMessage.length);

有關更詳細的示例,請參閱主要的 GPUCompilationInfo 頁面

規範

規範
WebGPU
# dom-gpucompilationmessage-length

瀏覽器相容性

另見