GPUTexture:sampleCount 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

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

sampleCountGPUTexture 接口的一个只读属性,表示 GPUTexture 的样本数。

此属性通过传入 GPUDevice.createTexture() 调用的描述符对象中的 sampleCount 属性进行设置。如果省略,则默认为 1。

一个数字。可能的值为:

  • 1
  • 4,表示多重采样纹理。

示例

js
// …

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

console.log(depthTexture.sampleCount); // 1

规范

规范
WebGPU
# dom-gputexture-samplecount

浏览器兼容性

另见