GPUCompilationMessage: lineNum 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 lineNum của giao diện GPUCompilationMessage là một số đại diện cho số dòng trong mã shader mà thông báo tương ứng.

Giá trị

Một số.

Lưu ý:

  • Nếu thông báo tương ứng với một chuỗi con, lineNum tham chiếu đến số dòng mà chuỗi con bắt đầu.
  • Nếu thông báo không tương ứng với một dòng mã cụ thể, lineNum sẽ là 0.
  • Các giá trị bắt đầu từ 1, tức là giá trị 1 tham chiếu đến dòng mã đầu tiên.
  • Các dòng được phân cách bởi ký tự xuống dòng. Trong WGSL, một danh sách cụ thể các ký tự được định nghĩa là ký tự xuống dòng.

Ví dụ

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

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

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

Thông số kỹ thuật

Specification
WebGPU
# dom-gpucompilationmessage-linenum

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

Xem thêm