Commit Graph

14 Commits

Author SHA1 Message Date
912d15cc7a mesh_compute_vs: restore write mode before unlink on replace failure and publish mode (MESH-COMPUTE-VS-STAGE-CLEANUP)
Apply published_mode(spv) to temporary staged SPV before atomic replacement,
and restore write permission (0o600) before directory cleanup in exception block
when replace fails, preventing Windows PermissionError [WinError 5] and
stranded temporary files.

agent: yes
AI-assisted: yes
2026-11-29 18:24:15 +03:00
4bbeddd5ab mesh_compute_vs: reject duplicate or out-of-range pc_tail_address_dwords indices
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-25 22:59:07 +02:00
476f014a2e mesh_compute_vs: read output address from %pc_tail when pc_tail_address_dwords is set
When index.json's mesh_compute layout carries pc_tail_address_dwords (as
produced by rdna2spirv.py --mesh-compute --pc-tail-ubo), emit the vertex
shader's output-buffer address loads from the set-1 binding-0 Uniform block
%pc_tail (%PcTail) instead of a 152-byte PushConstant block, omitting
PushConstant completely so the vertex shader fits 128-byte push-constant
devices. Without pc_tail_address_dwords, the emitted SPIR-V assembly is
byte-identical to before.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-25 22:59:07 +02:00
86d24c9452 Validate mesh helper index data before replacing assembly 2026-11-22 23:46:10 +01:00
78688eab40 Merge pull request #2389 from Julio Facal
# Conflicts:
#	docs/design.md
2026-11-22 13:14:35 -05:00
64b24f69fd SHADER-378: dynamic --f16-interp-fallback packing and per-pipeline SPIR-V half linking 2026-11-22 13:57:55 -03:00
26c89d8dad fix(mesh): publish fallback vertex shaders after validation
An assembler success can still produce a module that the validator rejects. Keep that binary private until it passes so the runtime cannot see it at the final shader path.
2026-11-22 17:38:01 +01:00
8fe3641c4d Merge pull request #1507 from AlooIsTasty 2026-11-22 07:07:57 -05:00
57e426f487 mesh_compute_vs: -h/--help prints usage, a missing spirv dir is an error
`mesh_compute_vs.py --help` took `--help` as the spirv dir, found no index.json and exited 0 with no output;
a path that does not exist did the same, so a typo looked like a successful run with nothing to do.
-h/--help now print the docstring and exit 0, and a path that is not a directory is one ERROR line and
exit 1, like the tool's other errors. build_for_index / write_for_index are unchanged. Same fix as #1379
for bary_fallback_gs.py.
2026-11-22 17:12:49 +05:30
89cf18645e Merge pull request #1428 from Dominik 2026-11-22 06:38:01 -05:00
1681f3dc1e Translator: --f16-interp-fallback reads f16 halves without PerVertexKHR (SHADER-196)
MoltenVK can't compile PerVertexKHR to MSL, so ps_interp_f16_high failed at
pipeline creation on every Mac. With --f16-interp-fallback every VS/mesh param
(and the --mesh-compute VS) also exports its two f16 halves decoded to f32,
low halves at location 29 - 2N and high halves at 30 - 2N, and a PS *_f16 read
takes them as ordinary smooth inputs. A producer skips halves that would land
on its own params; a PS whose half location is also an attribute is rejected.
The index records f16_halves on both sides.

tools/vk_subgroup_info.py reports per_vertex_inputs (false without
fragmentShaderBarycentric or on MoltenVK); make_game.py and run_gpu_tests.py
turn the flag on where it is false. Without the flag all 139 GPU-test modules
are byte-identical to main's, so NVIDIA/AMD keep the exact per-vertex path.

Apple A18 Pro, macOS 26.6.2, MoltenVK 1.4.2: ps_interp_f16_high passes, all
4096 pixels bit-exact; run_gpu_tests.py 84 pass/50 skip/1 fail -> 85/50/0
native, 112/22/1 -> 113/22/0 with wave64 emulation; ms_f16_pack passes through
--mesh-compute. Semantic suite 1194 -> 1203 OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted
2026-11-22 14:32:28 +03:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
7489bc8ddc mesh_compute_vs: name the missing SPIR-V tool instead of a FileNotFoundError
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.
2026-11-22 03:56:52 -06:00
caad84c32b Translator: --mesh-compute runs mesh shaders without VK_EXT_mesh_shader
9,282 of the 26,503 shaders are mesh shaders, and a device without
VK_EXT_mesh_shader (NVIDIA Pascal, for one) can't run any of them. With
--mesh-compute each becomes a GLCompute module with the same workgroup size
and code; only the epilogue changes. After the same barrier, lane 0 writes
the vertex and primitive counts, lane i its vertex and its primitive, into
this workgroup's slot of an output buffer whose address is in push-constant
dwords 36-37 (152 bytes). The slot layout is mesh_compute_layout() and the
index records it as mesh_compute.

- tools/mesh_compute_vs.py: the vertex shader that draws the slots with a
  non-indexed draw of groups * max_primitives * 3 vertices; unused and
  culled primitives are clipped away, params keep their locations.
- vk_harness: VKH_MESH_COMPUTE (+ VKH_MESH_SLOT, VKH_MESH_PRIMS) dispatches
  the module, adds a compute->vertex barrier and draws.
- run_gpu_tests.py / check.py: LEONIDA_MESH_COMPUTE=1 (check.mesh_env).
- tests/test_mesh_compute.py; docs/design.md row "Mesh shaders as compute",
  docs/testing.md section.

GTX 1060 (Pascal) with LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1: all five
ms_* tests pass (SKIP before), zero validation messages. Mesh corpus: 9,282 of
9,282 translate and pass spirv-val with --mesh-compute --wave64-emulate, and
all 9,282 generated vertex shaders validate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms
2026-11-22 00:21:36 -08:00