Skip to content

make_game, vk_subgroup_info: auto-enable --bary-fallback without VK_KHR_fragment_shader_barycentric - #2192

Closed
robot00f wants to merge 2 commits into
ProjectLeonida:mainfrom
robot00f:feat/make-game-bary-fallback-no-ext
Closed

robot00f wants to merge 2 commits into
ProjectLeonida:mainfrom
robot00f:feat/make-game-bary-fallback-no-ext

Conversation

@robot00f

Copy link
Copy Markdown
Contributor

Summary

Auto-enable --bary-fallback in make_game.py (and scripts/run_gpu_tests.py) when tools/vk_subgroup_info.py selects a GPU without VK_KHR_fragment_shader_barycentric (fragmentShaderBarycentric) that supports geometryShader (such as NVIDIA Pascal / GTX 1050 Ti, Intel Gen9.5, and older GCN):

  • Previously, vk_subgroup_info.py reported per_vertex_inputs: false on Pascal (turning on --f16-interp-fallback), while barycentric_fallback only checked for driver bugs on devices that do advertise VK_KHR_fragment_shader_barycentric (Mesa ANV and AMD Windows on gfx90c), returning false on Pascal and leaving raw BaryCoordKHR pixel shaders untranslated unless --bary-fallback or LEONIDA_BARY_FALLBACK=1 was passed manually.
  • Read VkPhysicalDeviceFeatures.geometryShader (offset 32 in the existing VkPhysicalDeviceFeatures2 query) alongside VK_KHR_fragment_shader_barycentric in tools/vk_subgroup_info.py, exposing "fragment_shader_barycentric" and "geometry_shader", and set "barycentric_fallback" to true when not fragment_shader_barycentric and geometry_shader (MoltenVK has geometry_shader == false and stays false).
  • Log the missing VK_KHR_fragment_shader_barycentric reason distinctly from the Mesa ANV / AMD gfx90c driver-bug message in make_game.py, preserving LEONIDA_BARY_FALLBACK=0/1, explicit --bary-fallback, and keep_recorded_fallback on transient probe failures.
  • Update CLI help, README.md, docs/design.md, and unit tests in tests/test_vk_subgroup_info.py and tests/test_make_game_translator_flags.py.

Validation

  • Live probe on NVIDIA GeForce GTX 1050 Ti (Pascal, Windows 10 19045, driver 582.28): python -I tools/vk_subgroup_info.py now reports "fragment_shader_barycentric": false, "geometry_shader": true, "per_vertex_inputs": false, "barycentric_fallback": true, "mesh_shader": false.
  • python -I tests/test_vk_subgroup_info.py, python -I tests/test_make_game_translator_flags.py, python -I tests/test_make_game_wave64.py, test_docs_*, test_text_write_line_endings.py (all OK).
  • python -I scripts/check_no_game_data.py (clean).

Depends on: #1885
Claim: #1608 (comment)
AI-assisted: yes (Antigravity, Gemini 4 Carbon)

@Tauwni

Tauwni commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Tested f1b46166c on an Apple M3 (macOS 26.5.1) with the three Vulkan drivers there, against main a73a57e13. Test programs were built from main; this PR changes no C++.

tools/vk_subgroup_info.py:

Driver fragment_shader_barycentric geometry_shader barycentric_fallback (main → PR)
MoltenVK 1.4.2 true false false → false
KosmicKrisp (Mesa 26.3.1) false false false → false
llvmpipe (Mesa 26.3.1) false true false → true

So the PR changes nothing on MoltenVK and KosmicKrisp. It turns the fallback on for llvmpipe, which lacks VK_KHR_fragment_shader_barycentric but has geometry shaders, the same case as Pascal. On llvmpipe, scripts/run_gpu_tests.py in auto mode gives:

passed skipped failed
main 177 90 1
this PR 181 86 1

ps_bary, ps_persp_bary, ps_scc_mask32 and ps_uniform_branch go from SKIP ("reads BaryCoordKHR and the device has no ...") to PASS through the generated *.bary_gs.spv. The one failure is cs_imgatomic_ext on both, which #1518 fixes. tests/test_vk_subgroup_info.py, test_make_game_translator_flags.py, test_make_game_argparse.py and test_make_game_wave64.py all pass.

AI-assisted (Claude Code). No game data.

@robot00f
robot00f marked this pull request as ready for review November 26, 2026 23:27
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
@robot00f
robot00f force-pushed the feat/make-game-bary-fallback-no-ext branch 2 times, most recently from 3b9e130 to 0c0007a Compare November 27, 2026 14:57
…T_mesh_shader

make_game.py previously turned on --mesh-compute automatically only on
Intel's Windows Vulkan driver (BUILD-2202, runtime_gpu_mesh_draws_crash).
On GPUs without VK_EXT_mesh_shader / meshShader (such as NVIDIA Pascal,
AMD RDNA1/GCN, older Intel iGPUs, and MoltenVK), make_game.py left
--mesh-compute off unless passed on the command line, translating native
MeshEXT modules that the target GPU cannot create or execute.

- Query VK_EXT_mesh_shader and VkPhysicalDeviceMeshShaderFeaturesEXT.meshShader
  (offset 20, after taskShader) in tools/vk_subgroup_info.py across both
  Vulkan 1.2 and Vulkan 1.3 devices (reusing the cached Vulkan 1.2 extension
  set and deferring Vulkan 1.3 extension enumeration to the winning device),
  exposing "mesh_shader" in the JSON output.
- Add runtime_gpu_mesh_shader() in make_game.py and auto-enable
  --mesh-compute during the shaders stage when mesh_shader is False
  (unless --native-mesh is passed), preserving a recorded --mesh-compute
  setting via keep_recorded_fallback when the probe cannot answer.
- Update CLI help, README.md, docs/design.md, and unit tests in
  tests/test_vk_subgroup_info.py and tests/test_make_game_translator_flags.py.

Claim: ProjectLeonida#14 (comment)
AI-assisted: yes (Antigravity, Gemini 4 Carbon)
…HR_fragment_shader_barycentric

tools/vk_subgroup_info.py previously returned barycentric_fallback=true only
for drivers that advertise native barycentrics with a known BaryCoordKHR bug
(Mesa ANV and AMD Windows on gfx90c). On GPUs that lack
VK_KHR_fragment_shader_barycentric altogether while supporting geometryShader
(such as NVIDIA Pascal / GTX 1050 Ti, Intel Gen9.5, and older GCN),
per_vertex_inputs=false turned on --f16-interp-fallback in make_game.py, while
barycentric_fallback remained false and left raw BaryCoordKHR pixel shaders
untranslated unless --bary-fallback or LEONIDA_BARY_FALLBACK=1 was passed
manually.

- Read VkPhysicalDeviceFeatures.geometryShader (offset 32 in
  VkPhysicalDeviceFeatures2) alongside VK_KHR_fragment_shader_barycentric in
  tools/vk_subgroup_info.py, exposing "fragment_shader_barycentric" and
  "geometry_shader" and setting "barycentric_fallback" to true when
  not fragment_shader_barycentric and geometry_shader (keeping MoltenVK false,
  as Metal has no geometryShader).
- Distinguish missing VK_KHR_fragment_shader_barycentric from the Mesa ANV /
  AMD gfx90c driver-bug log message in make_game.py while keeping
  LEONIDA_BARY_FALLBACK=0/1 and --bary-fallback precedence unchanged across
  make_game.py and scripts/run_gpu_tests.py.
- Update CLI help, README.md, docs/design.md, and unit tests in
  tests/test_vk_subgroup_info.py and tests/test_make_game_translator_flags.py.

Depends on: ProjectLeonida#1885
Claim: ProjectLeonida#1608 (comment)
AI-assisted: yes (Antigravity, Gemini 4 Carbon)
@robot00f
robot00f force-pushed the feat/make-game-bary-fallback-no-ext branch from 0c0007a to d260b81 Compare November 27, 2026 15:00
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
@qhukz13

qhukz13 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Tested on the GPU this PR names: GeForce GTX 1050 Ti 4 GB (Pascal), NVIDIA 582.66, Windows 10 19045 (profile S). Head d260b81d4 merged onto main 34e33d3dd (README.md and run_gpu_tests.py auto-merged), test programs built from main; scripts/run_gpu_tests.py in auto mode (no LEONIDA_* variables).

MEASURED:

  • tools/vk_subgroup_info.py: main reports per_vertex_inputs: false, barycentric_fallback: false; this PR adds mesh_shader: false, fragment_shader_barycentric: false, geometry_shader: true and reports barycentric_fallback: true.
  • Auto mode, main: 202/269 passed, 65 skipped; ps_bary, ps_persp_bary, ps_scc_mask32, ps_uniform_branch SKIP ("reads BaryCoordKHR and the device has no VK_KHR_fragment_shader_barycentric").
  • Auto mode, this PR: 206/269 passed, 61 skipped; the runner builds bary fallback GS for those four and all four PASS (ps_bary 4096/4096 pixels, ps_persp_bary perspective-correct on every covered pixel, ps_scc_mask32 and ps_uniform_branch 4096 px). No test went from pass to fail.
  • The two failures are the same on both sides and on every mode we ran, so not from this PR: cs_imgatomic_ext (6 of 64 sint words) and cs_texture_uav (no formatless storage access for format 98).

One small thing, READ IN CODE / MEASURED in the log: ps_ij_computed still SKIPs with "computed I/J pairs need PerVertexKHR inputs: no --bary-fallback / --f16-interp-fallback", while the translator line in the same run says "computed I/J pair under --bary-fallback: no PerVertexKHR inputs". The skip is right (computed pairs under the fallback are refused, #120), only the reason names the flags as if neither were on.

AI-assisted (Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
@MoonEyes

Copy link
Copy Markdown
Collaborator

Hi @robot00f, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/design.md), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

@TheGeogeo

Copy link
Copy Markdown
Contributor

Checked d260b81d4 against main ef3299584 on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.

  • Conflicts:
    • README.md: rewritten on main by a9e247cd6 and 8bb93e89d (2026-11-28).
    • make_game.py: b26e43491 and 2af23b9ac (2026-11-24) changed the same lines.
    • tools/vk_subgroup_info.py and docs/design.md: edits next to this PR's.
  • Still needed (STALE, needs a rebase). main's barycentric_fallback() (tools/vk_subgroup_info.py:209) still only lists drivers with broken barycentrics (Mesa ANV, AMD gfx90c, an old Raphael driver). It does not turn the fallback on for a device without VK_KHR_fragment_shader_barycentric.

AI-assisted (Claude Code).

@KelboLive

Copy link
Copy Markdown

Independent check on Windows (not the author), at d260b81d4.

  • test_make_game_argparse.py: 38 tests OK
  • test_make_game_translator_flags.py: 38 tests OK
  • test_make_game_wave64.py: 45 tests OK
  • test_vk_subgroup_info.py: 57 tests OK

Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10.

AI-assisted: yes (opencode).

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR cannot merge in its current state:

  • Stacked on unmerged base #1885: #1885 must land first, then this branch needs to be rebased onto main.
  • Merge conflicts with main (README.md, docs/design.md, make_game.py) and failing CI (windows, linux-gpu-tools, macos, macos-python, check).

Once #1885 lands, please rebase onto current main and obtain a green CI run.

(AI-assisted review.)

@aslan2142

Copy link
Copy Markdown
Collaborator

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

@aslan2142 aslan2142 closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants