Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ skips a shader without `shaderSignedZeroInfNanPreserveFloat32`; needs PR #664's
on by itself on Intel's Windows Vulkan driver, whose native mesh draws crash, BUILD-2202, unless `--native-mesh`).
Each is documented in [docs/design.md](docs/design.md).

`--mesh-serial-waves` is forwarded and saved the same way. It is off by default: with wave64 emulation it runs
the waves of a mesh shader of more than 64 threads one after the other in 64 invocations instead of side by side
(docs/design.md, "Mesh shaders with their waves in series"). It changes nothing for shaders translated natively or
with `--mesh-compute`.

The build records which llvm-mc command and version produced the disassembly. Changing either, or reusing a work
folder that predates this record, reruns disassembly and translation while keeping the extracted shader inputs.

Expand Down
10 changes: 7 additions & 3 deletions make_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,8 @@ def shaders(game: str, work: str, jobs: int, emulate: bool = False, keep_emulate
"translating again")
drop(translated)
# The translation also depends on the fallback flags (--no-float-controls, --bary-fallback,
# --texel-offset-fallback, --mesh-compute), so they are kept beside it like the wave64 mode. A folder from
# before the file existed was translated without them.
# --texel-offset-fallback, --mesh-compute, --mesh-serial-waves, ...), so they are kept beside it like the wave64
# mode. A folder from before the file existed was translated without them.
flags_file = os.path.join(spirv, "translator_flags.txt")
want_flags = translator_flags_setting(fallbacks)
had_flags = read_shader_setting(flags_file)
Expand Down Expand Up @@ -1847,7 +1847,7 @@ def exe_shaders(game: str, work: str, mc_signature: str, jobs: int = 1, emulate:
FALLBACK_FLAGS = (("--no-float-controls", "no_float_controls"), ("--bary-fallback", "bary_fallback"),
("--texel-offset-fallback", "texel_offset_fallback"), ("--mesh-compute", "mesh_compute"),
("--f16-interp-fallback", "f16_interp_fallback"), ("--pc-tail-ubo", "pc_tail_ubo"),
("--compact-spirv", "compact_spirv"))
("--compact-spirv", "compact_spirv"), ("--mesh-serial-waves", "mesh_serial_waves"))


def fallback_flags(a) -> tuple[str, ...]:
Expand Down Expand Up @@ -3155,6 +3155,10 @@ def main() -> int:
help="translate mesh shaders to compute shaders writing an output buffer, for devices "
"without VK_EXT_mesh_shader; on by itself on Intel's Windows Vulkan driver, whose mesh "
"draws crash on the corpus' mesh shaders (BUILD-2202)")
ap.add_argument("--mesh-serial-waves", action="store_true",
help="with wave64 emulation, run the waves of a mesh shader of more than 64 threads one after "
"the other in 64 invocations (the translator's --mesh-serial-waves, #2435); off by "
"default, no effect on shaders translated natively or with --mesh-compute")
ap.add_argument("--native-mesh", action="store_true",
help="keep native mesh shaders on Intel's Windows Vulkan driver instead of turning on "
"--mesh-compute (for a driver that fixes BUILD-2202's crash)")
Expand Down
19 changes: 19 additions & 0 deletions tests/test_make_game_translator_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def test_each_flag_alone(self):
def test_all_flags_in_record_order(self):
self.assertEqual(make_game.fallback_flags(self.args_with(*reversed(ALL_FLAGS))), ALL_FLAGS)

def test_every_forwarded_flag_is_a_translator_option(self):
# The flags go to rdna2spirv.py verbatim: one it does not define would end every translation with a usage error.
with open(os.path.join(ROOT, "tools", "rdna2spirv.py"), encoding="utf-8") as f:
translator = f.read()
for flag, _attr in make_game.FALLBACK_FLAGS:
self.assertIn(f'ap.add_argument("{flag}"', translator, flag)


class TranslateFallbacksTest(unittest.TestCase):
"""translate() passes the fallback flags to every shard, and re-plans when they change."""
Expand Down Expand Up @@ -222,6 +229,18 @@ def test_no_flags_by_default(self):
self.assertEqual(pre, ())
self.assertEqual(sh, ())

def test_mesh_serial_waves_is_opt_in_and_forwarded(self):
# #2435's translator switch: nothing passes it unless asked, and asking forwards it like the other flags.
pre, sh = self.run_main("--mesh-serial-waves")
self.assertEqual(pre, ("--mesh-serial-waves",))
self.assertEqual(sh, pre)

def test_mesh_serial_waves_is_recorded_after_the_older_flags(self):
# Appended to FALLBACK_FLAGS, so the settings recorded for existing folders keep their spelling.
pre, _sh = self.run_main("--mesh-serial-waves", "--mesh-compute", "--no-float-controls")
self.assertEqual(pre, ("--no-float-controls", "--mesh-compute", "--mesh-serial-waves"))
self.assertEqual(make_game.translator_flags_setting(pre), "--no-float-controls --mesh-compute --mesh-serial-waves")

def test_f16_interp_fallback_follows_the_device(self):
"""On by itself where vk_subgroup_info says the GPU can't take PerVertexKHR inputs (MoltenVK), not where
it can or can't tell; asked for explicitly, it is on everywhere."""
Expand Down
Loading