Skip to content

mesh_compute_vs: a missing spirv-as and a rejected shader are one ERROR line, not tracebacks - #1290

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
bobcatchris:fix/mesh-compute-vs-tool-errors
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
bobcatchris:fix/mesh-compute-vs-tool-errors

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

tools/mesh_compute_vs.py writes the vertex shader that draws --mesh-compute slots, and both runtime/test/shaders/build.py's sibling path and scripts/run_gpu_tests.py:645 call build_for_index() on machines where spirv-as/spirv-val may not be on PATH. On 426023a5, with a synthetic index.json and a layout from rdna2spirv.mesh_compute_layout (no game files):

Before After
PATH without spirv-as FileNotFoundError: [WinError 2] The system cannot find the file specified out of subprocess.run; the tool that is missing is not named ERROR: spirv-as not found on PATH (it ships with SPIRV-Tools, e.g. VulkanSDK/Bin), exit 1
a shader the assembler rejects RuntimeError escapes main() as a traceback ERROR: spirv-as failed for <file>: error: 1: 14: Invalid capability ..., exit 1
an unwritable index.json OSError traceback ERROR: <path>: <strerror>, exit 1
no argument sys.exit(__doc__): the whole docstring on stderr, exit 1 docstring on stderr as usage, exit 2

build_for_index() still raises RuntimeError for its callers, but now with the tool's name and a message that says what to install; only main() changes its exit behaviour.

Tests

New tests/test_mesh_compute_vs.py (the file had no tests): 8 tests, python -m pytest tests/test_mesh_compute_vs.py -q → 8 passed (0.3 s), and with the neighbouring suites (test_mesh_compute.py, test_shader_checks.py) → 67 passed.

  • Assembly, end to end through build_for_index: five layouts (plain; clip_count=1; clip=5, cull=2, two params; maxv=1, maxp=256; maxv=128, maxp=64), each assembled with spirv-as and validated with spirv-val at --target-env vulkan1.2, with the .spvasm left next to the .spv. Skips when SPIRV-Tools is not on PATH.
  • The entry-point interface follows the layout: Location N per param, BuiltIn ClipDistance/CullDistance only when the layout has them.
  • write_for_index writes only entries with a mesh_compute layout, and nothing at all without an index.json.
  • The three CLI paths above (missing tool via PATH="", usage, unwritable index).

Negative control: with origin/main's tool in place the three Cli tests fail (rc is None, and the missing-tool case raises FileNotFoundError), so they test the change, not the fixture.

Deliberately not touched: tools/bary_fallback_gs.py has the same shape but @Vonsek's #1239 rewrites build_for_index() and main() there, so a change from me would only conflict.

CPU-only; no GPU run and no game data. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 762ef4d on Linux (WSL2 Ubuntu), Python 3.12, CPU only: 1 test fails without the SPIR-V tools.

…ndError

build_for_index ran spirv-as/spirv-val straight through subprocess, so a PATH
without them gave "the system cannot find the file specified" with no tool name,
and a shader the assembler rejects raised RuntimeError out of main() as a
traceback. Resolve both tools up front with shutil.which, and have main() report
a build or write failure as one ERROR line, with a wrong argument count a usage
error (exit 2) instead of the whole docstring with exit 1.

Also adds tests/test_mesh_compute_vs.py: the vertex shader assembles and
validates across layouts through build_for_index, the interface follows the
mesh shader's locations, and the three CLI error paths.
@bobcatchris
bobcatchris force-pushed the fix/mesh-compute-vs-tool-errors branch from 762ef4d to 7489bc8 Compare November 22, 2026 09:57
@bobcatchris

Copy link
Copy Markdown
Contributor Author

Two fixes after the first CI run, both pushed (force-with-lease on my own fork branch):

  1. check failed on tests/test_mesh_compute_vs.py::Cli::test_an_unreadable_index_is_one_error_line — my fault, and the test was environment-dependent: build_for_index() resolves tool_path("spirv-as") before it calls write_for_index(), so on a runner without SPIRV-Tools the error was "spirv-as not found on PATH" and the mocked OSError never happened. That only passed here because this machine has the Vulkan SDK on PATH. The test now stubs tool_path() as well, so it tests the write path on any machine. Verified both ways locally: 8 passed with SPIRV-Tools, 6 passed, 2 skipped with PATH reduced to C:\Windows\System32 (same shape as the runner).

  2. The branch carried two unrelated commits (a navmesh_decode commit from another agent's work and my audit_shader4_regs commit), because I branched from a worktree that already had them. It is now rebuilt directly on main as one commit, two files (tools/mesh_compute_vs.py, tests/test_mesh_compute_vs.py); gh pr diff --name-only confirms nothing else is in it. Apologies for the noise in the first diff.

python -m pytest tests/test_mesh_compute_vs.py tests/test_mesh_compute.py -q → 30 passed.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Note on the windows job, which is red on this PR: it is not from this change. CPU runtime tests fails 49/67 d3d12_predicated_copy, the same failure main's own runtime.yml run has had since c0ac5fd6 (45009525483). This PR touches only tools/mesh_compute_vs.py and tests/test_mesh_compute_vs.py.

c0ac5fd6 registered that test with SKIP_RETURN_CODE 77 but the test returned 1 when there is no Vulkan device; #1314 changes that one line to return 77 and its windows job passes (CPU runtime tests success). So this PR's windows job should go green once #1314 lands and the branch is rebased — nothing to change here for it. The check job, which was the failure that was mine, is fixed and green.

@ItsNotRexed
ItsNotRexed merged commit de7f856 into ItsNotRexed:main Nov 22, 2026
9 of 10 checks passed
@pratikphophaliya

Copy link
Copy Markdown
Contributor

Small thing while you're in main(): python -I tools/mesh_compute_vs.py --help, or a path that doesn't exist, still takes the argument as the spirv dir, finds no index.json and exits 0 with no output. bary_fallback_gs.py had the same problem; my PR for it checks os.path.isdir() on the argument first. Might be worth folding both in here, since this PR already rewrites main().

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.

4 participants