GPUTexture:format 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

注意:此功能在 Web Workers 中可用。

GPUTexture 介面的format 只讀屬性表示 GPUTexture 的格式。

此屬性透過傳入到原始的 GPUDevice.createTexture() 呼叫中的描述符物件的 format 屬性設定。

一個列舉值。有關所有可能的值,請參閱規範中的紋理格式(Texture formats)部分。

示例

js
// …

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

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

規範

規範
WebGPU
# dom-gputexture-format

瀏覽器相容性

另見