GPUShaderModule: label property
Khả dụng hạn chế
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 label của giao diện GPUShaderModule cung cấp một nhãn có thể được dùng để nhận dạng đối tượng, ví dụ trong thông báo GPUError hoặc cảnh báo console.
Thuộc tính này có thể được đặt bằng cách cung cấp thuộc tính label trong đối tượng descriptor được truyền vào lời gọi GPUDevice.createShaderModule() gốc, hoặc bạn có thể lấy và đặt trực tiếp trên đối tượng GPUShaderModule.
Giá trị
Một chuỗi. Nếu chưa được đặt như mô tả ở trên, nó sẽ là chuỗi rỗng.
Ví dụ
Đặt và lấy nhãn qua GPUShaderModule.label:
// …
const shaderModule = device.createShaderModule({
code: shaders,
});
shaderModule.label = "my_shader";
console.log(shaderModule.label); // "my_shader"
Đặt nhãn qua lời gọi GPUDevice.createShaderModule() gốc, sau đó lấy qua GPUShaderModule.label:
// …
const shaderModule = device.createShaderModule({
code: shaders,
label: "my_shader",
});
console.log(shaderModule.label); // "my_shader"
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| WebGPU> # dom-gpuobjectbase-label> |