大网数据广告活动
Web 标准与前端开发

GPUSupportedLimits

· 52CE 我爱测

The **`GPUSupportedLimits`** interface of the WebGPU API describes the limits supported by a GPUAdapter.

WebGPU API

The GPUSupportedLimits interface of the WebGPU API describes the limits supported by a GPUAdapter.

Instance properties

The following limits are represented by properties in a GPUSupportedLimits object. See the Limits section of the specification for detailed descriptions of what the limits relate to.

All properties are read-only.

Limit name Default value
maxTextureDimension1D 8192
maxTextureDimension2D 8192
maxTextureDimension3D 2048
maxTextureArrayLayers 256
maxBindGroups 4
maxBindingsPerBindGroup 640
maxDynamicUniformBuffersPerPipelineLayout 8
maxDynamicStorageBuffersPerPipelineLayout 4
maxSampledTexturesPerShaderStage 16
maxSamplersPerShaderStage 16
maxStorageBuffersInFragmentStage 8
maxStorageBuffersInVertexStage 8
maxStorageBuffersPerShaderStage 8
maxStorageTexturesInFragmentStage 4
maxStorageTexturesInVertexStage 4
maxStorageTexturesPerShaderStage 4
maxUniformBuffersPerShaderStage 12
maxUniformBufferBindingSize 65536 bytes
maxStorageBufferBindingSize 134217728 bytes (128 MB)
minUniformBufferOffsetAlignment 256 bytes
minStorageBufferOffsetAlignment 256 bytes
maxVertexBuffers 8
maxBufferSize 268435456 bytes (256 MB)
maxVertexAttributes 16
maxVertexBufferArrayStride 2048 bytes
maxInterStageShaderComponents (use maxInterStageShaderVariables instead, see deprecation notice for more info) 60
maxInterStageShaderVariables 16
maxColorAttachments 8
maxColorAttachmentBytesPerSample 32
maxComputeWorkgroupStorageSize 16384 bytes
maxComputeInvocationsPerWorkgroup 256
maxComputeWorkgroupSizeX 256
maxComputeWorkgroupSizeY 256
maxComputeWorkgroupSizeZ 64
maxComputeWorkgroupsPerDimension 65535

Description

The GPUSupportedLimits object for the current adapter is accessed via the GPUAdapter.limits property.

Instead of reporting the exact limits of each GPU, browsers typically report different tier values of different limits (to reduce the unique information available to drive-by fingerprinting). For example, the tiers of a certain limit might be 2048, 8192, and 32768. If your GPU's actual limit is 16384, the browser will still report 8192.

Given that different browsers will handle this differently and the tier values may change over time, it is hard to provide an accurate account of what limit values to expect — thorough testing is advised.

Note that when calling GPUAdapter.requestDevice() to request a GPUDevice that meets some minimum requirements ("limits"), you pass an object that has the same property names as GPUSupportedLimits.

Storage buffer and texture limits outside compatibility mode

When creating a device, requested maxStorageBuffersInFragmentStage, maxStorageBuffersInVertexStage, maxStorageTexturesInFragmentStage, and maxStorageTexturesInVertexStage limits aren't kept as separate values when WebGPU compatibility mode isn't being used. Instead, they raise the maxStorageBuffersPerShaderStage and maxStorageTexturesPerShaderStage limits if they're higher, and are then adjusted to equal them.

Examples

In the following code we query the GPUAdapter.limits value of maxBindGroups to see if it is equal to or greater than 6. Our theoretical example app ideally needs 6 bind groups, so if the returned value is >= 6, we add a maximum limit of 6 to the requiredLimits object. We then request a device with that limit requirement using GPUAdapter.requestDevice():

async function init() {
  if (!navigator.gpu) {
    throw Error("WebGPU not supported.");
  }

  const adapter = await navigator.gpu.requestAdapter();
  if (!adapter) {
    throw Error("Couldn't request WebGPU adapter.");
  }

  const requiredLimits = {};

  // App ideally needs 6 bind groups, so we'll try to request what the app needs
  if (adapter.limits.maxBindGroups >= 6) {
    requiredLimits.maxBindGroups = 6;
  }

  const device = await adapter.requestDevice({
    requiredLimits,
  });

  // …
}

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。