Skip to content

Update limits correspondence - #5604

Open
teoxoy wants to merge 9 commits into
gpuweb:mainfrom
teoxoy:limits-correspondence
Open

Update limits correspondence#5604
teoxoy wants to merge 9 commits into
gpuweb:mainfrom
teoxoy:limits-correspondence

Conversation

@teoxoy

@teoxoy teoxoy commented Mar 11, 2026

Copy link
Copy Markdown
Member

No description provided.

Comment thread correspondence/index.bs
@github-actions

github-actions Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Previews, as seen when this build job started (a000b50):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

Comment thread correspondence/index.bs
Comment thread correspondence/index.bs
Comment thread correspondence/index.bs
Comment thread correspondence/index.bs
Comment on lines +242 to +244
- `Maximum scalar or vector inputs to a fragment function`
- `(Maximum number of input components to a fragment function) / 4`
<td>31 = `min(D3D12_VS_OUTPUT_REGISTER_COUNT, D3D12_PS_INPUT_REGISTER_COUNT) - 1`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Only the position builtin doesn't count towards the maxInterStageShaderVariables in the WebGPU spec. The Vulkan and D3D12 limits need to be lowered by 1. On Metal the limit is only for user defined inter-stage variables.

@kainino0x kainino0x Mar 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

D3D12 change looks right, I guess we missed updating this when we changed these builtins to be counted (when merging the two limits together in #4688).

On Metal, we had this carveout because there was a specific difference in the Metal validation layers between Apple and non-Apple GPUs. See #1962 (comment) - the validation layer used to erroneously say "on macOS" but it meant "on non-Apple GPUs" - I don't know if that's been fixed since.

When I wrote this I should have made clearer what the subtractions were for, but I think they're position and point_size and should be left as they were - IIUC even though point_size is accounted for by our spec in vertex outputs, we have to reserve it on Metal because Metal counts it toward fragment inputs too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On Metal, we had this carveout because there was a specific difference in the Metal validation layers between Apple and non-Apple GPUs. See #1962 (comment) - the validation layer used to erroneously say "on macOS" but it meant "on non-Apple GPUs" - I don't know if that's been fixed since.

I see; our CI also started running into this now:

number of shader varying components (125) exceeds limit (124). Note that on macOS the following attributes count towards the limit: [[position]], [[clip_distance]], [[point_size]], [[point_coord]], and, when read in the fragment shader, [[viewport_array_index]] & [[render_target_array_index]].

from https://bugzilla.mozilla.org/show_bug.cgi?id=1931629#c9

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Dawn seems to set maxInterStageShaderVariables to 28 on non-Apple GPUs.

limits->v1.maxInterStageShaderVariables = mtlLimits.maxFragmentInputs - 4;

I will test in our CI with 30 min(32, 124 / 4) - 1 for now (accounting just for position).

Comment thread correspondence/index.bs
Comment thread correspondence/index.bs
Comment thread correspondence/index.bs Outdated
Comment thread correspondence/index.bs
<th>`maxBindingsPerBindGroup`
<td>[#3279](https://github.com/gpuweb/gpuweb/issues/3279),
[#3864](https://github.com/gpuweb/gpuweb/issues/3864)
<td colspan=3>Limit is arbitrary to allow implementations to treat binding space as an array.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was also referring to WebGPU implementations (not just drivers) so should be written in the table in a way that it applies to all backends.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I updated the section; let me know what you think!

Comment thread correspondence/index.bs
Comment thread correspondence/index.bs
Comment thread correspondence/index.bs
Comment on lines +242 to +244
- `Maximum scalar or vector inputs to a fragment function`
- `(Maximum number of input components to a fragment function) / 4`
<td>31 = `min(D3D12_VS_OUTPUT_REGISTER_COUNT, D3D12_PS_INPUT_REGISTER_COUNT) - 1`

@kainino0x kainino0x Mar 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

D3D12 change looks right, I guess we missed updating this when we changed these builtins to be counted (when merging the two limits together in #4688).

On Metal, we had this carveout because there was a specific difference in the Metal validation layers between Apple and non-Apple GPUs. See #1962 (comment) - the validation layer used to erroneously say "on macOS" but it meant "on non-Apple GPUs" - I don't know if that's been fixed since.

When I wrote this I should have made clearer what the subtractions were for, but I think they're position and point_size and should be left as they were - IIUC even though point_size is accounted for by our spec in vertex outputs, we have to reserve it on Metal because Metal counts it toward fragment inputs too?

ErichDonGubler pushed a commit to teoxoy/wgpu that referenced this pull request Apr 11, 2026
ErichDonGubler pushed a commit to gfx-rs/wgpu that referenced this pull request Apr 11, 2026
slyedoc pushed a commit to slyedoc/wgpu that referenced this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants