Skip to content

subgroup_size: reject zero workgroup dimensions in subgroup_workgroup_fits - #8762

Closed
CourtyardGames wants to merge 1 commit into
ProjectLeonida:mainfrom
CourtyardGames:fix/subgroup-workgroup-zero-dim
Closed

CourtyardGames wants to merge 1 commit into
ProjectLeonida:mainfrom
CourtyardGames:fix/subgroup-workgroup-zero-dim

Conversation

@CourtyardGames

Copy link
Copy Markdown

Claimed in the coordination issue as: #8504 (comment)

What and why

subgroup_workgroup_fits() (runtime/src/subgroup_size.h) returned true whenever any workgroup dimension in local_size was 0:

  • local_size[2] == 0 short-circuited to return true, even when max_invocations == 0.
  • local_size[0] == 0 or local_size[1] == 0 computed xy == 0, so 0 <= max_invocations / local_size[2] also returned true.

Because SPIR-V LocalSize requires every workgroup dimension to be at least 1, a 0 in any component of entry.local_size represents a malformed/unknown index entry that cannot be proved to satisfy VUID-VkPipelineShaderStageCreateInfo-pNext-02756 (LocalSize.x * LocalSize.y * LocalSize.z <= requiredSubgroupSize * maxComputeWorkgroupSubgroups). For {64, 0, 1} and {64, 1, 0}, decide_subgroup_size() previously returned SubgroupOutcome::required and even enabled VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT.

This makes subgroup_workgroup_fits() reject any zero workgroup dimension (!local_size[0] || !local_size[1] || !local_size[2]), and expands runtime/test/subgroup_size_test.cpp to check {0, 1, 1}, {64, 0, 1}, {64, 1, 0}, and {0, 0, 0} for both compute (cs) and mesh (ms) stages as well as max_invocations == 0.

Tested

  • Windows x64, MSVC 19.51.36260.0 (RelWithDebInfo, Ninja); CPU-only (no GPU or game files needed).
  • Verified the updated subgroup_size_test fails on unpatched main (line 181: !subgroup_workgroup_fits(bad_local, 1024)).
  • After the fix: built subgroup_size_test and vk_pipeline_check, ran ctest --test-dir runtime/build -R "^subgroup_size$" --output-on-failure (passed) and python -I scripts/check_no_game_data.py runtime/src/subgroup_size.h runtime/test/subgroup_size_test.cpp (exit 0).

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — runtime subgroup-size guard fix, not a shader-translator rule.)

@Grimkaaah Grimkaaah 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.

Independent Linux CPU review (ac52f42b)

What changed: subgroup_workgroup_fits rejects zero workgroup dimensions; C++ test updated.

Checked: Diff review of header + test (runtime not built here). Small, focused guard.

Looks correct; no game files.

@lohant27-netizen

Copy link
Copy Markdown

Tested ac52f42b0 on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8777, #8763, #8762, #8754, #8711 and #8695 (no conflicts): pass.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified head ac52f42b0 merged onto main (867d922f0) on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo):

  • python -I scripts/check_no_game_data.py on both changed files: clean (exit 0)
  • cmake --build runtime/build --target subgroup_size_test --parallel: built cleanly
  • ctest --test-dir runtime/build -R subgroup_size --output-on-failure -V: 1/1 passed (subgroup size decision: AMD-like, NVIDIA-like, old RADV, limits, create-info chain and query OK)

AI-assisted.

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.

5 participants