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

浏览器兼容性

另见