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

瀏覽器相容性

另見