Skip to content

Max number for dynamic resources #406

@shaoboyan

Description

@shaoboyan

Current spec support dynamic resources. The number of dynamic resources needs to be limited because they may consume special resources , which are not unlimit in native backends, to achieve performance improvement through dynamic offsets.

Here are current state in Metal, Vulkan and D3D12 :

Metal

In metal, resources can achieve dynamic offsets through SetVertexBufferOffset in vertex shader, SetFragmentBufferOffset in fragment shader and SetBufferOffset in compute shader.

No specific limitation found in Metal for applying these API to buffers.

D3D12

In D3D12, resources can achieve dynamic offsets and gain performance improvement through root descriptor.

Each root descriptor takes 2 DWORDs in root signature, and the maximum size of a root signature is 64 DWORDs.

In current spec, the maxBindGroup in WebGPU is 4 which means that they will take 4 DWORDs in root signature(if they're root descriptor heaps). So the max number of dynamic resources cannot exceed 30.

Vulkan

Vulkan has dynamic resources types. It has dynamic uniform buffer and dynamic storage buffer to achieve dynamic offsets.

The min-max numbers of dynamic uniform buffer and dynamic storage buffer that can be set are 8 and 4 (Vulkan spec Table 30).

Proposal

According to above information, Vulkan is the one of all three native backends that has specific max number limitation for dynamic uniform buffer and dynamic storage buffer. The total number of dynamic resources cannot exceed 12 in Vulkan backend. This limitation is compatible with D3D12, which requests number of dynamic resources cannot exceed 30 and Metal, which has no specific limitation.

So WebGPU can defines two max numbers for whole pipeline :

  • maxUniformBuffersDynamic is 8
  • maxStorageBuffersDynamic is 4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions