Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correspondence Reference: Limits #3088

Merged
merged 7 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 194 additions & 2 deletions correspondence/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Boilerplate: repository-issue-tracking yes

<style>
code {
background: #f2f2f2;
background: rgba(186, 186, 186, 30%);
padding: 0 3px;
border-radius: 4px;
}
Expand All @@ -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?*
kainino0x marked this conversation as resolved.
Show resolved Hide resolved
<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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rowspan, when paired with two offset rowspans in the Metal column, is a little awkward to visually to parse in the preview. I don't really have a suggestion for resolving it, but felt like it was worth pointing out anyway.

Screen Shot 2022-06-30 at 3 24 38 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to do these as footnotes, no rowspans, put "[1]"/"[2]"/"[3]" in each cell and then put the text at the bottom.

<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](https://docs.microsoft.com/en-ca/windows/win32/api/d3d12/ns-d3d12-d3d12_input_element_desc)
<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>32 = `max(32, D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT (16))`
<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>`min(maxColorAttachments, 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](https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#18.6.6%20Inter-Thread%20Data%20Sharing)
<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 @@ -1484,6 +1484,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