GPUCompilationMessage: length property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc length của giao diện GPUCompilationMessage là một số đại diện cho độ dài của chuỗi con mà thông báo tương ứng.

Giá trị

Một số.

Cụ thể hơn, length là số đơn vị mã UTF-16 trong chuỗi con mã shader mà thông báo tương ứng. Nếu thông báo tương ứng với một điểm đơn thay vì một chuỗi con, length sẽ là 0.

Ví dụ

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

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

Xem trang chính GPUCompilationInfo để biết ví dụ chi tiết hơn.

Thông số kỹ thuật

Specification
WebGPU
# dom-gpucompilationmessage-length

Tương thích trình duyệt

Xem thêm