Skip to content

TEST-1306: run_gpu_tests: ms_tri_bary draws a --mesh-compute mesh shader through a --bary-fallback pixel shader - #5613

Open
flapwarp wants to merge 2 commits into
ItsNotRexed:mainfrom
flapwarp:test-1184-mesh-compute-bary
Open

flapwarp wants to merge 2 commits into
ItsNotRexed:mainfrom
flapwarp:test-1184-mesh-compute-bary

Conversation

@flapwarp

Copy link
Copy Markdown

Item: TEST-1306 (claim, narrowed from TEST-1184, which stays blocked on #1712/#4309/#4408).

A GPU with neither VK_EXT_mesh_shader nor fragment barycentrics (NVIDIA Pascal) needs both fallbacks in one draw, and no test ran them together. ms_tri_bary draws ms_tri through ps_bary; under LEONIDA_MESH_COMPUTE=1 LEONIDA_BARY_FALLBACK=1 the generated vertex shader feeds ps_bary's pass-through geometry shader. It's judged with the existing check_bary. The bary fallback on a native mesh stage skips (VUID-VkGraphicsPipelineCreateInfo-pStages-02095).

Tested: GTX 1050 Ti (NVIDIA 580.196.07, Linux): 4096/4096, max error 0 with both fallbacks; the other three flag combinations skip with their reason. llvmpipe (Mesa 25.0.7): passes with both fallbacks. The run_gpu_tests/docs unit tests pass.
Not run here: the native path (mesh stage + VK_KHR_fragment_shader_barycentric), which runs by default on Turing and newer; a check on any RTX 20-series or newer would cover it.

No game files. AI-assisted.

@Kev-Ball

Copy link
Copy Markdown

The requested native mesh + native fragment barycentric path passes on RTX 3080 Ti, NVIDIA 620.73.04, CachyOS Linux. I ran scripts/run_gpu_tests.py --filter ms_tri --require-pass for each flag pair with a separate work directory and the NVIDIA ICD selected. Tested the tree shared by 3b895a80 and current head 4c85562c.

LEONIDA_MESH_COMPUTE LEONIDA_BARY_FALLBACK ms_tri_bary
0 0 4,096 / 4,096 exact
1 0 4,096 / 4,096 exact
1 1 4,096 / 4,096 exact
0 1 Expected skip: geometry shader cannot follow native mesh

I also compared each successful RGBA32F readback byte for byte with an independent 64×64 reference computed directly from pixel coordinates: (u,v,u/2,v/2), with u=(x+0.5)/64 and v=(y+0.5)/64. All three frames matched in every component, maximum absolute error zero. The companion ms_tri draw passed in all four runs. Synthetic fixtures, LLVM 23.1.5. AI-assisted.

@SirKingg

Copy link
Copy Markdown
Contributor

Independent Windows RTX check of exact head 4c85562ce4205b650003fe39e5486f18fa92f960: RTX 4070 Ti, NVIDIA 610.88, Windows build 26300, LLVM 23.1.6, Vulkan validation layer 1.4.363. Synthetic fixtures only.

Ran python -I scripts\run_gpu_tests.py --llvm-mc <AMDGPU llvm-mc.exe> --build runtime\build --work <separate-dir> --filter ms_tri --require-pass with LEONIDA_W64_EMULATE=1 and the RTX selected. Each run translated 2/2 shaders and passed spirv-val; companion ms_tri passed in all four.

Mesh compute Bary fallback ms_tri_bary
0 0 PASS 4096/4096 (native mesh + native barycentrics)
1 0 PASS 4096/4096 (compute mesh + native barycentrics)
1 1 PASS 4096/4096 (compute mesh + geometry bary fallback)
0 1 SKIP: geometry stage cannot follow native mesh; the invalid pipeline was not created (VUID-VkGraphicsPipelineCreateInfo-pStages-02095)

Replayed each of the three supported draws directly through vk_harness with VK_LAYER_KHRONOS_validation enabled, confirmed the layer was loaded, and checked the full output: no validation errors or VUIDs observed. Each replay readback passed check_bary and matched an independent (u,v,u/2,v/2) pixel-coordinate reference exactly (maximum absolute error 0). As a safe negative control, changing one component in a copy of each readback made check_bary reject it; no invalid GPU submission was made.

This exercises translator output and the standalone Vulkan test harness, not the D3D12 runtime mesh PSO/DispatchMesh path. Wave64 is emulated on this subgroup-32 GPU; this is not TEST-1184's test on hardware lacking both mesh shaders and barycentrics. No game files or online game services. AI-assisted.

@mrbean56

Copy link
Copy Markdown

Read on Linux, plus the surrounding harness: the addition is coherent, but I cannot run the case it adds.

  • ms_tri_bary needs a mesh shader built from a DXBC container with signatures; runtime/test/shaders/build.py skips ms_* without one, so the new branch is untested on this machine. What I could check is the logic: the "missing ps_bary.spv" arm returns False (a failure, not a skip), which is right — a missing fixture is a broken run, not a device limitation.
  • The skip rule matches the Vulkan constraint it cites: a native mesh stage cannot be followed by a geometry shader (VUID-VkGraphicsPipelineCreateInfo-pStages-02095), so the bary fallback without --mesh-compute is a genuine skip while LEONIDA_MESH_COMPUTE=1 is the runnable case. That is the only place both fallbacks meet, so the case is worth having.
  • One suggestion: make the branch also assert the reverse (the fallback path reports SKIP with a reason mentioning --mesh-compute), so a future refactor that silently drops the case shows up as a missing SKIP rather than a pass.

No GPU for this case; no game data. AI-assisted.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 4c85562 on AMD RADV RAPHAEL_MENDOCINO (Ryzen 9 9950X3D iGPU) with LEONIDA_W64_EMULATE=1: run_gpu_tests.py --filter ms_tri gives 2/2 with "PASS ms_tri 4096/4096 pixels exact" and "PASS ms_tri_bary 4096/4096 pixels match" with LEONIDA_MESH_COMPUTE=1 and LEONIDA_BARY_FALLBACK=1 together, with LEONIDA_MESH_COMPUTE=1 alone, and with neither set. With only LEONIDA_BARY_FALLBACK=1, ms_tri passes and ms_tri_bary prints "SKIP (--bary-fallback's geometry shader can't follow a native mesh stage; set LEONIDA_MESH_COMPUTE=1)". tests/test_run_gpu_tests*.py runs 61 tests OK and tests/test_docs_*.py runs 30 tests OK. This device has native mesh shaders and barycentrics, so the fallback paths were forced by the flags.

AI-assisted.

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested 4c85562c, merged onto main 561b65a8. Setup: Apple M4, macOS 27.2, MoltenVK 1.4.2, AppleClang, Python 3.15.2 / 3.12.16. The PR has no C++, so I reused main's runtime build (ctest 62/62).

The M4 has native fragment barycentrics but neither VK_EXT_mesh_shader nor geometry shaders. That covers a pair not run here before: mesh-as-compute with native barycentrics, on a non-NVIDIA driver.

run_gpu_tests.py --filter ms_tri for each flag pair, all with LEONIDA_W64_EMULATE=1:

LEONIDA_MESH_COMPUTE LEONIDA_BARY_FALLBACK ms_tri ms_tri_bary
0 0 skip (no VK_EXT_mesh_shader) skip (no VK_EXT_mesh_shader)
0 1 skip (no VK_EXT_mesh_shader) skip (the PR's "can't follow a native mesh stage" reason)
1 0 4096/4096 exact 4096/4096 match
1 1 4096/4096 exact skip (unsupported: no geometryShader)

main gives the same ms_tri result in all four. The pair with both fallbacks skips cleanly on a device without geometry shaders instead of failing.

  • Full suite, default flags: 165/233 passed, 60 skipped. main gives 165/232 passed, 59 skipped. The only per-test change is the new ms_tri_bary skip.
  • Mutation: with ps_flat.spv drawn in place of ps_bary.spv, ms_tri_bary fails. MoltenVK rejects the pipeline at vkCreateGraphicsPipelines (-3), so the case can't pass by default. This doesn't exercise check_bary on wrong pixels; I didn't build that negative.
  • Unit and docs checks: tests/test_run_gpu_tests.py is OK on 3.15.2 and 3.12.16. The ten tests/test_docs_*.py pass and git diff --check is clean.

Verdict: pass. Optionally, the docs paragraph's "Passes on …" list could add "Apple M4 / MoltenVK 1.4.2 with LEONIDA_MESH_COMPUTE=1 and native barycentrics".

AI-assisted.

@flapwarp

Copy link
Copy Markdown
Author

@mrbean56 thanks: added in d9d7281. tests/test_run_gpu_tests_mesh_bary.py runs mesh_bary_case with the test program stubbed: the bary fallback on a native mesh stage must skip with a reason naming LEONIDA_MESH_COMPUTE=1, a missing ps_bary.spv/bary_gs.spv must fail, and the two fallbacks must hand vk_harness the generated VS and the geometry shader. Dropping the skip branch makes it fail. Thanks also @Kev-Ball, @SirKingg and @gertify for the runs on Ampere, Ada and RDNA3.5.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested d9d7281 on AMD RADV RAPHAEL_MENDOCINO (Ryzen 9 9950X3D iGPU), subgroup 32..64: with LEONIDA_MESH_COMPUTE=1 and LEONIDA_BARY_FALLBACK=1, run_gpu_tests.py --filter ms_tri gives 2/2, "PASS ms_tri 4096/4096 pixels exact" and "PASS ms_tri_bary 4096/4096 pixels match", and the log shows "bary fallback GS: ps_bary.bary_gs.spv" and "mesh compute VS: ms_tri.mesh_vs.spv". With only LEONIDA_BARY_FALLBACK=1, ms_tri_bary prints "SKIP (--bary-fallback's geometry shader can't follow a native mesh stage; set LEONIDA_MESH_COMPUTE=1)". With no flags, and with only LEONIDA_MESH_COMPUTE=1, ms_tri_bary passes 4096/4096 on the native path with no generated shader lines, so those two combinations do not skip on this device. With LEONIDA_VK_DEVICE=NoSuchDevice both rows fail with "no Vulkan physical device matches". tests/test_run_gpu_tests_mesh_bary.py runs 6 tests OK.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested d9d7281 merged with main 561b65a on Linux (WSL2) Python 3.12.16: pass (GPU-free unit test only)

tests/test_run_gpu_tests_mesh_bary.py: 6 run, 6 passed, 0 failed. Neighbouring tests/test_run_gpu_.py (mandelbrot, pixel_checks, readback_size, tests, tests_paths, wavemask) all exit 0. tests/test_docs_.py: 11 files OK.

Negative control: restoring scripts/run_gpu_tests.py from upstream/main (keeping the PR's test) gives errors in the new tests (module 'run_gpu_tests' has no attribute 'mesh_bary_case'); with the PR's script they pass.

Read the diff: DRAWN_WITH["ms_tri"] = "ps_bary.asm" only makes ps_bary get built next to ms_tri (with_draw_shaders), it does not change how the existing ms_tri row is drawn; the bary-fallback-without-mesh-compute skip, the missing-fixture failures and the VKH_GS wiring match the tests. I did not run the actual ms_tri_bary draw (no Pascal GPU here, and I did not run the suite on a device), so the GTX 1050 Ti / llvmpipe results in the PR body are not independently confirmed.

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested d9d7281a on Windows 11 build 26300 with an NVIDIA GeForce GTX 1060 6GB, driver 582.78 (Pascal, subgroup 32..32), Vulkan SDK 1.4.363 headers, llvm-mc from .leonida\llvm-mc, MSVC 19.44 vk_harness.exe. This is the Windows + NVIDIA Pascal data point the PR body listed as not yet run.

python -I scripts/run_gpu_tests.py --filter ms_tri with LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1 LEONIDA_BARY_FALLBACK=1:

bary fallback GS: ps_bary.bary_gs.spv
mesh compute VS: ms_tri.mesh_vs.spv
PASS  ms_tri       4096/4096 pixels exact
PASS  ms_tri_bary  4096/4096 pixels match
2/2 passed

With LEONIDA_MESH_COMPUTE=0 and bary fallback on, both skip with the documented reasons (no VK_EXT_mesh_shader; "geometry shader can't follow a native mesh stage; set LEONIDA_MESH_COMPUTE=1"), 0 failures.

Counts only, synthetic fixtures, no game files. AI-assisted (OpenCode). Result also posted in #166.

… a --bary-fallback pixel shader

A GPU with neither VK_EXT_mesh_shader nor fragment barycentrics (NVIDIA Pascal) needs both fallbacks in one
draw, and no test ran them together. ms_tri_bary draws ms_tri through ps_bary: ms_tri exports
attr0 = (0,0), (2,0), (0,2) on the vs_ids triangle, so ps_bary's raw barycentrics must again equal its
interpolated attr0.xy / 2 on every pixel (check_bary). Under LEONIDA_MESH_COMPUTE=1 and
LEONIDA_BARY_FALLBACK=1 the vertex shader tools/mesh_compute_vs.py generates feeds the pass-through geometry
shader tools/bary_fallback_gs.py builds for ps_bary. A native mesh stage can't be followed by a geometry
shader (VUID-VkGraphicsPipelineCreateInfo-pStages-02095), so the bary fallback without --mesh-compute skips.

The case runs with ms_tri (--filter ms_tri); DRAWN_WITH builds ps_bary next to it.

Tested: GTX 1050 Ti (NVIDIA 580.196.07, Linux), both fallbacks: 4096/4096 pixels, max error 0; the other
three flag combinations skip with their reason. llvmpipe (Mesa 25.0.7): passes with both fallbacks, skips
with the bary fallback on its native mesh stage.
Calls run_gpu_tests.mesh_bary_case with the test program stubbed: the bary fallback on a native mesh stage
skips with a reason naming LEONIDA_MESH_COMPUTE, a missing ps_bary.spv or bary_gs.spv fails instead of
skipping, both fallbacks hand vk_harness the generated vertex shader and ps_bary's geometry shader, and
without the bary fallback no geometry shader is added. Dropping the skip branch makes the test fail.
Suggested in review by mrbean56.
@flapwarp
flapwarp force-pushed the test-1184-mesh-compute-bary branch from d9d7281 to 3df118b Compare November 23, 2026 14:12
@flapwarp

Copy link
Copy Markdown
Author

Rebased onto main after #5900 (head 3df118b0, checked against 8c8c1de1); the one conflict was DRAWN_WITH (#5900's UINT_MIP_TEST next to ms_tri). GTX 1050 Ti: ms_tri_bary 4096/4096 with both fallbacks, the documented skips without --mesh-compute; the run_gpu_tests unit tests pass.

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Re-verified at the current head 3df118b0 (my earlier result was on the old d9d7281a). Tested on Windows 11 build 26300, NVIDIA GeForce GTX 1060 6GB, driver 582.78 (Pascal, subgroup 32..32), MSVC 19.44 vk_harness.exe, local llvm-mc, Vulkan SDK 1.4.363 headers:

  • python -I tests/test_run_gpu_tests_mesh_bary.py: 6/6 OK.
  • LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1 LEONIDA_BARY_FALLBACK=1, run_gpu_tests.py --filter ms_tri:
    bary fallback GS: ps_bary.bary_gs.spv
    mesh compute VS: ms_tri.mesh_vs.spv
    PASS  ms_tri       4096/4096 pixels exact
    PASS  ms_tri_bary  4096/4096 pixels match
    2/2 passed
    
  • Negative control (LEONIDA_MESH_COMPUTE=0): both SKIP with the documented reasons (no VK_EXT_mesh_shader; "geometry shader can't follow a native mesh stage; set LEONIDA_MESH_COMPUTE=1"), 0 failures.

This is the Windows + NVIDIA Pascal data point the rebase needed; no change in behaviour from the old head. Counts only, synthetic fixtures, no game files. AI-assisted (OpenCode). Also updating #166.

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.

8 participants