Skip to content

Add test for out-of-bounds subgroupShuffle - #4726

Merged
sudonatalie merged 4 commits into
gpuweb:mainfrom
sudonatalie:test-oob-subgroup-shuffle
Nov 12, 2026
Merged

sudonatalie merged 4 commits into
gpuweb:mainfrom
sudonatalie:test-oob-subgroup-shuffle

Conversation

@sudonatalie

Copy link
Copy Markdown
Contributor

Add a compute test to verify that providing an OOB land ID safely clamps or wraps the read to within the workgroup.


Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)
  • Test have be tested with compatibility mode validation enabled and behave as expected. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located.
  • Test descriptions are accurate and complete.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Tests avoid over-parameterization (see case count report).

When landing this PR, be sure to make any necessary issue status updates.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Results for build job (at 81aa9a3):

+webgpu:shader,execution,expression,call,builtin,subgroupShuffle:shuffle,out_of_bounds:* - 8 cases, 8 subcases (~1/case)
-TOTAL: 290190 cases, 2381705 subcases
+TOTAL: 290198 cases, 2381713 subcases

@alan-baker alan-baker left a comment

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.

WGSL says:

An indeterminate value is returned if id does not select an active invocation.

So it feels too strong to require the result to be from within the subgroup. It would be valid for an implementation to pick an arbitrary value and return that (e.g. 0 or all ones). The best I could imagine would be:

  • Setup 3 three buffers
    • First and last have some random sentinel value
    • Middle is filled with predictable values like your iterating 0xDEAD values
  • Every invocation reads from the middle buffer (some consecutive range maybe offset from start)
  • Test that no return is a outside is a value (in any buffer) outside the range read in the middle buffer
    • Since all the values are unlikely to picked by an implementation this likely works (and allows things like 0)

Thoughts? You may also want variants of this test where you filter some invocations via an if statement and test the value from inactive invocations.

@sudonatalie

Copy link
Copy Markdown
Contributor Author

I like that approach, tried a version of it in the next patch.

I'll consider inactive invocations in a follow up and keep this one narrow to address coverage for potentially security impacting OOB reads (context is: https://crbug.com/549237171). I'm not sure if it's what you meant, but my reading of the spec is that if the inactive lane within the subgroup did return some stale old data, that would be within spec.

Add a compute test to verify that providing an OOB land ID safely clamps
or wraps the read to within the workgroup.
@sudonatalie
sudonatalie force-pushed the test-oob-subgroup-shuffle branch from 051b58a to 81aa9a3 Compare November 12, 2026 14:55
@sudonatalie
sudonatalie enabled auto-merge (squash) November 12, 2026 14:57
@sudonatalie
sudonatalie merged commit e18f9fb into gpuweb:main Nov 12, 2026
1 check passed
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