GPUTexture: format 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 format của giao diện GPUTexture đại diện cho định dạng của GPUTexture.

Giá trị này được đặt thông qua thuộc tính format trong đối tượng descriptor truyền vào lời gọi GPUDevice.createTexture() ban đầu.

Giá trị

Một giá trị liệt kê. Xem phần Texture formats của thông số kỹ thuật để biết tất cả các giá trị có thể. Xem thêm Tier 1 and Tier 2 texture formats.

Ví dụ

js
// …

const depthTexture = device.createTexture({
  size: [canvas.width, canvas.height],
  format: "depth24plus",
  usage: GPUTextureUsage.RENDER_ATTACHMENT,
});

console.log(depthTexture.format); // "depth24plus"

Thông số kỹ thuật

Specification
WebGPU
# dom-gputexture-format

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

Xem thêm