GPUTexture: dimension 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 dimension của giao diện GPUTexture đại diện cho kích thước của tập hợp texel cho mỗi subresource của GPUTexture.

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

Giá trị

Một giá trị liệt kê. Các giá trị có thể là:

  • "1d": Kết cấu một chiều với một kích thước duy nhất là chiều rộng.
  • "2d": Kết cấu hai chiều với chiều rộng và chiều cao, có thể có thêm các lớp. Chỉ kết cấu "2d" mới có thể có mipmap, multisampling, dùng định dạng nén hoặc depth/stencil, và được dùng làm render attachment.
  • "3d": Kết cấu ba chiều với chiều rộng, chiều cao và chiều sâu.

Ví dụ

js
// …

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

console.log(depthTexture.dimension); // "2d"

Thông số kỹ thuật

Specification
WebGPU
# dom-gputexture-dimension

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

Xem thêm