Skip to content

spirv-val: Check local size dimensions instead of their product - #7071

Open
KainanP wants to merge 1 commit into
KhronosGroup:mainfrom
KainanP:localsize-product-overflow
Open

KainanP wants to merge 1 commit into
KhronosGroup:mainfrom
KainanP:localsize-product-overflow

Conversation

@KainanP

@KainanP KainanP commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #6319.

The "must not have a product of zero" checks multiplied the three workgroup dimensions and compared the result with 0. The product can wrap to 0 when no dimension is 0:

  • LocalSize: the operands are 32-bit, and operand_x * operand_y * operand_z was computed in 32 bits before it was stored in a uint64_t. LocalSize 1048576 1048576 1048576 (2^60) gave the error from the issue.
  • LocalSizeId and the WorkgroupSize built-in multiply in 64 bits, which wraps for larger values, e.g. three constants of 4194304 (2^66).

The checks now test whether any dimension is 0. For LocalSize the product is computed in 64 bits; it is still used by the DerivativeGroupLinearKHR multiple-of-4 check, which stays correct if the 64-bit product wraps (4 divides 2^64).

Tests: GLComputeLargeLocalSize, GLComputeLargeLocalSizeId and GLComputeLargeWorkgroupSize in val_modes_test.cpp. All three fail on main with the "product of zero" error and pass with the change. With the change, test_val_fghijklmnop (22108 tests) and test_val_abcde (7896, including the built-in tests) pass on Linux (GCC 13, Debug).

This PR was written with Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

Fixes KhronosGroup#6319.

The "must not have a product of zero" checks multiplied the three
workgroup dimensions and compared the result with 0, but the product can
wrap to 0 when no dimension is 0. For `LocalSize` the 32-bit operands
were multiplied in 32 bits before being stored in a `uint64_t`, so
`LocalSize 1048576 1048576 1048576` (2^60) was rejected. `LocalSizeId`
and the `WorkgroupSize` built-in multiply in 64 bits, which wraps for
three dimensions of 4194304 (2^66).

The checks now test each dimension. The `LocalSize` product, still used
by the `DerivativeGroupLinearKHR` multiple-of-4 check, is computed in 64
bits; that check stays correct if the product wraps, since 4 divides
2^64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

[spirv-val] Incorrect error message on local size

1 participant