Skip to content

Commit

Permalink
Correspondence Reference: Limits
Browse files Browse the repository at this point in the history
Documents how to compute limits on each platform. Hopefully will be
expanded with more API and shading language correspondence tables in the
future.

Subsumes Limits.md and APICorrespondence.md.

Fixes #3027
  • Loading branch information
kainino0x committed Jun 24, 2022
1 parent ac95488 commit 81bb6bf
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 44 deletions.
194 changes: 193 additions & 1 deletion correspondence/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,196 @@ Issue: Migrate from `APICorrespondence.md`.

# Limits # {#limits}

Issue: Migrate from `Limits.md`.
This section provides references for computing WebGPU's limit values in each of the three backend APIs.
These references inform the base values of these limits, as well as how implementations compute adapter limits.
User agents are not required to use these formulas and may expose whatever they want
(e.g. always choosing the base value of a limit, or bucketing devices as a fingerprinting protection).

<table class=data style="font-size: 90%">
<thead>
<tr>
<th>Limit
<th>Issue
<th>Vulkan
<th>Metal
<th>D3D12
<tr>
<td>
<td>
<td>[Required Limits](https://www.khronos.org/registry/vulkan/specs/1.3/html/vkspec.html#limits-required)
<td>[Feature Set Tables](https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf)
<td>[Constants](https://docs.microsoft.com/en-us/windows/win32/direct3d12/constants),
[Hardware Tiers](https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-support),
[Root Signature Limits](https://docs.microsoft.com/en-us/windows/win32/direct3d12/root-signature-limits)
</thead>
<tr>
<th class=issue>need a max buffer size limit
<td>[#1371](https://github.com/gpuweb/gpuweb/issues/1371)
<td>`maxMemoryAllocationSize`
<td>`MTLDevice.maxBufferLength`
<td class=issue>*No documented limit?*
<tr>
<th>`maxTextureDimension1D`
<td>[#1327](https://github.com/gpuweb/gpuweb/issues/1327)
<td>`maxImageDimension1D`
<td>`Maximum 1D texture width`
<td>16384 = `D3D12_REQ_TEXTURE1D_U_DIMENSION`
<tr>
<th>`maxTextureDimension2D`
<td>[#1327](https://github.com/gpuweb/gpuweb/issues/1327)
<td>`min(maxImageDimension2D, maxImageDimensionCube)`
<td>min(`Maximum 2D texture width and height`, `Maximum cube map texture width and height`)
<td>16384 = `min(D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, D3D12_REQ_TEXTURECUBE_DIMENSION)`
<tr>
<th>`maxTextureDimension3D`
<td>[#1327](https://github.com/gpuweb/gpuweb/issues/1327)
<td>`maxImageDimension3D`
<td>`Maximum 3D texture width, height, and depth`
<td>2048 = `D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION`
<tr>
<th>`maxTextureArrayLayers`
<td>[#1327](https://github.com/gpuweb/gpuweb/issues/1327)
<td>`maxImageArrayLayers`
<td>`Maximum number of layers per 1D texture array, 2D texture array, or 3D texture`
<td>2048 = `D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION`
<tr>
<th>`maxBindGroups`
<td>[#47](https://github.com/gpuweb/gpuweb/issues/47)
<td>`maxBoundDescriptorSets`
<td class=issue>It's complicated.
<td rowspan=3>*Strategy-dependent.* Allocate the `D3D12_MAX_ROOT_COST`, minus reserved slots, across these three limits.
<tr>
<th>`maxDynamicUniformBuffersPerPipelineLayout`
<td>[#406](https://github.com/gpuweb/gpuweb/issues/406)
<td>`maxDescriptorSetUniformBuffersDynamic`
<td>When not using argument buffers: `maxUniformBuffersPerShaderStage`

Issue: When using argument buffers: ?
<tr>
<th>`maxDynamicStorageBuffersPerPipelineLayout`
<td>[#406](https://github.com/gpuweb/gpuweb/issues/406)
<td>`maxDescriptorSetStorageBuffersDynamic`
<td>When not using argument buffers, `maxStorageBuffersPerShaderStage`

Issue: When using argument buffers: ?
<tr>
<th>`maxSamplersPerShaderStage`
<td>[#409](https://github.com/gpuweb/gpuweb/issues/409)
<td>`maxPerStageDescriptorSamplers`
<td>`Maximum number of entries in the sampler state argument table, per graphics or kernel function`
<td>`Maximum number of Samplers in all descriptor tables per shader stage`
<tr>
<th>`maxSampledTexturesPerShaderStage`
<td>[#409](https://github.com/gpuweb/gpuweb/issues/409)
<td>`maxPerStageDescriptorSampledImages`
<td rowspan=2>*Strategy-dependent.* Allocate `Maximum number of entries in the texture argument table, per graphics or kernel function` across these two limits.
<td>`Maximum number of Shader Resource Views in all descriptor tables per shader stage`
<tr>
<th>`maxStorageTexturesPerShaderStage`
<td>[#409](https://github.com/gpuweb/gpuweb/issues/409)
<td>`maxPerStageDescriptorStorageImages`
<td rowspan=2>*Strategy-dependent.* Allocate `Maximum number of Unordered Access Views in all descriptor tables across all stages` across these two limits.
<tr>
<th>`maxStorageBuffersPerShaderStage`
<td>[#409](https://github.com/gpuweb/gpuweb/issues/409)
<td>`maxPerStageDescriptorStorageBuffers`
<td rowspan=3>*Strategy-dependent.* Allocate `Maximum number of entries in the buffer argument table, per graphics or kernel function` across these three limits.
<tr>
<th>`maxUniformBuffersPerShaderStage`
<td>[#409](https://github.com/gpuweb/gpuweb/issues/409)
<td>`maxPerStageDescriptorUniformBuffers`
<td>`Maximum number of Constant Buffer Views in all descriptor tables per shader stage`
<tr>
<th>`maxVertexBuffers`
<td>[#693](https://github.com/gpuweb/gpuweb/issues/693)
<td>`maxVertexInputBindings`
<td>16
<tr>
<th>`maxUniformBufferBindingSize`
<td>[#803](https://github.com/gpuweb/gpuweb/issues/803)
<td>`maxUniformBufferRange`
<td>*No documented limit.* Use `maxBufferSize`.
<td>65536 = `D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * sizeof(float4)`
<tr>
<th>`maxStorageBufferBindingSize`
<td>[#1163](https://github.com/gpuweb/gpuweb/issues/1163)
<td>`maxStorageBufferRange`
<td>*No documented limit.* Use `maxBufferSize`.
<td class=issue>*No documented limit.* Use `UINT32_MAX`?
<tr>
<th>`minUniformBufferOffsetAlignment`
<td>[#1863](https://github.com/gpuweb/gpuweb/issues/1863)
<td>`minUniformBufferOffsetAlignment`
<td>`Minimum constant buffer offset alignment`
<td>256 = `D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT`
<tr>
<th>`minStorageBufferOffsetAlignment`
<td>[#1863](https://github.com/gpuweb/gpuweb/issues/1863)
<td>`minStorageBufferOffsetAlignment`
<td>*No documented limit.* Use 32, which is the lowest allowed value.
<td>16 = `D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT`
<tr>
<th>`maxVertexAttributes`
<td>[#693](https://github.com/gpuweb/gpuweb/issues/693)
<td>`maxVertexInputAttributes`
<td>*No limit.* Use `maxVertexBuffers * Maximum number of vertex attributes, per vertex descriptor`
<td>32 = `D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT`
<tr>
<th>`maxVertexBufferArrayStride`
<td>[#693](https://github.com/gpuweb/gpuweb/issues/693)
<td>`maxVertexInputBindingStride`
<td>*No documented limit?*
<td>2048 B = `D3D12_SO_BUFFER_MAX_STRIDE_IN_BYTES`
<tr>
<th>`maxInterStageShaderComponents`
<td>[#1962](https://github.com/gpuweb/gpuweb/issues/1962)
<td>`min(maxVertexOutputComponents, maxFragmentInputComponents)`
<td>`Maximum number of input components to a fragment function, declared with the stage_in qualifier`, subtract 4 for non-Apple GPUs
<td>120 = `maxInterStageShaderVariables * 4`
<tr>
<th>`maxInterStageShaderVariables`
<td>[#1962](https://github.com/gpuweb/gpuweb/issues/1962)
<td>`min(maxVertexOutputComponents // 4, maxFragmentInputComponents // 4)`
<td>`Maximum number of inputs (scalars or vectors) to a fragment function, declared with the stage_in qualifier`, subtract 2 for non-Apple GPUs
<td>30 = `min(D3D12_VS_OUTPUT_REGISTER_COUNT - 1, D3D12_PS_INPUT_REGISTER_COUNT - 2)`
<tr>
<th>`maxColorAttachments`
<td>[#2820](https://github.com/gpuweb/gpuweb/issues/2820)
<td>`maxFragmentOutputAttachments`
<td>`Maximum number of color render targets per render
pass descriptor`
<td>8 = `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT`
<tr>
<th>`maxComputeWorkgroupStorageSize`
<td>[#1863](https://github.com/gpuweb/gpuweb/issues/1863)
<td>`maxComputeSharedMemorySize`
<td>`Maximum total threadgroup memory allocation`
<td>32 KiB
<tr>
<th>`maxComputeInvocationsPerWorkgroup`
<td>[#1863](https://github.com/gpuweb/gpuweb/issues/1863)
<td>`min(maxComputeWorkGroupInvocations, product(maxComputeWorkGroupSize[0..2]))`
<td rowspan=4>`Maximum threads per threadgroup` (but actually `maxTotalThreadsPerThreadgroup` for a given pipeline)
<td>1024 = `D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP`
<tr>
<th>`maxComputeWorkgroupSizeX`
<td>[#1898](https://github.com/gpuweb/gpuweb/issues/1898)
<td>`min(maxComputeWorkGroupSize[0], maxComputeWorkGroupInvocations)`
<td>1024 = `D3D12_CS_THREAD_GROUP_MAX_X`
<tr>
<th>`maxComputeWorkgroupSizeY`
<td>[#1898](https://github.com/gpuweb/gpuweb/issues/1898)
<td>`min(maxComputeWorkGroupSize[1], maxComputeWorkGroupInvocations)`
<td>1024 = `D3D12_CS_THREAD_GROUP_MAX_Y`
<tr>
<th>`maxComputeWorkgroupSizeZ`
<td>[#1898](https://github.com/gpuweb/gpuweb/issues/1898)
<td>`min(maxComputeWorkGroupSize[2], maxComputeWorkGroupInvocations)`
<td>64 = `D3D12_CS_THREAD_GROUP_MAX_Z`
<tr>
<th>`maxComputeWorkgroupsPerDimension`
<td>[#1863](https://github.com/gpuweb/gpuweb/issues/1863)
<td>`min(maxComputeWorkGroupCount[0..2])`
<td class=issue> *No documented limit?*
<td>65535 = `D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION`
</table>
43 changes: 0 additions & 43 deletions design/Limits.md

This file was deleted.

2 changes: 2 additions & 0 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,8 @@ Issue: Do we need to have a max per-pixel render target size?
{{GPUSupportedLimits}} exposes the [=limits=] supported by an adapter or device.
See {{GPUAdapter/limits|GPUAdapter.limits}} and {{GPUDevice/limits|GPUDevice.limits}}.

<!-- When adding limits here, add them to the Correspondence Reference as well. -->

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUSupportedLimits {
Expand Down

0 comments on commit 81bb6bf

Please sign in to comment.