rdna2spirv: index records the --fma mode the shader was translated under (OLD-5267) #181

Manually merged
github merged 1 commit from gh-pr/181/head into gh-pr/181/base 2026-11-26 08:47:52 +00:00
Owner

@⁠ItsMrDubey on GitHub · 2026-11-24 02:37 UTC · original
ItsMrDubey:fma-index-options → main · +17 −1 · 2 files · 1 commits · merged 2026-11-24 03:28 UTC

Claimed in the coordination issue as: OLD-5267 (#14)

What and why

old #5267: shader_meta filled the index's fma field (glsl, khr or exact) from the module globals FMA_KHR / FMA_EXACT at indexing time. If a caller translated a shader and changed the option before indexing it, the field showed the later option and not the one the code was emitted under. test_fma_exact.translate is one such caller: it restores the globals right after translating. A --fma khr module could then be indexed as glsl while still listing shaderFmaFloat32, and check.py trusts the recorded mode over everything else (TEST-1147).

Fix: Gen stores the mode in effect when translation starts (fma_mode), and shader_meta writes that value. The rdna2spirv.py command line behaves as before, because it sets the option once before any translation.

Tested

Windows 11, Python 3.11.9, no GPU needed.

  • Before, on origin/main: a v_fma_f32 listing translated under khr or exact, then indexed after the option was reset to glsl, was recorded as glsl.
  • New test_index_records_the_mode_of_the_translation in tests/semantic/test_fma_khr.py covers khr→glsl, exact→glsl, glsl→khr and glsl→exact. On origin/main all 4 subtests fail. With the fix, python -I -m unittest discover -s tests/semantic -p test_fma_khr.py passes 10 tests (1 skipped: no SPIRV-Tools).
  • python -I scripts/run_semantic_tests.py tests/semantic: 463 files and 6076 tests. 4 files fail: test_exec_computed, test_image_atomics_guard, test_sopc_validation and test_unary_f16_validation. They fail the same way on unmodified origin/main (2, 47, 1 and 15 failures).
  • python -I tests/test_shader_checks.py passes. python -m pytest tests/test_translate.py tests/test_mesh_compute.py passes, with most tests skipped because there is no llvm-mc.
  • python -I scripts/check_no_game_data.py on both changed files: clean.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule, so nothing to add to the contract table of docs/design.md (index metadata only; the emitted SPIR-V is unchanged).
**@⁠ItsMrDubey** on GitHub · 2026-11-24 02:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/181) `ItsMrDubey:fma-index-options` → `main` · +17 −1 · 2 files · 1 commits · merged 2026-11-24 03:28 UTC Claimed in the coordination issue as: OLD-5267 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why old #5267: `shader_meta` filled the index's `fma` field (`glsl`, `khr` or `exact`) from the module globals `FMA_KHR` / `FMA_EXACT` at indexing time. If a caller translated a shader and changed the option before indexing it, the field showed the later option and not the one the code was emitted under. `test_fma_exact.translate` is one such caller: it restores the globals right after translating. A `--fma khr` module could then be indexed as `glsl` while still listing `shaderFmaFloat32`, and `check.py` trusts the recorded mode over everything else (TEST-1147). Fix: `Gen` stores the mode in effect when translation starts (`fma_mode`), and `shader_meta` writes that value. The `rdna2spirv.py` command line behaves as before, because it sets the option once before any translation. ### Tested Windows 11, Python 3.11.9, no GPU needed. - Before, on `origin/main`: a `v_fma_f32` listing translated under `khr` or `exact`, then indexed after the option was reset to `glsl`, was recorded as `glsl`. - New `test_index_records_the_mode_of_the_translation` in `tests/semantic/test_fma_khr.py` covers khr→glsl, exact→glsl, glsl→khr and glsl→exact. On `origin/main` all 4 subtests fail. With the fix, `python -I -m unittest discover -s tests/semantic -p test_fma_khr.py` passes 10 tests (1 skipped: no SPIRV-Tools). - `python -I scripts/run_semantic_tests.py tests/semantic`: 463 files and 6076 tests. 4 files fail: `test_exec_computed`, `test_image_atomics_guard`, `test_sopc_validation` and `test_unary_f16_validation`. They fail the same way on unmodified `origin/main` (2, 47, 1 and 15 failures). - `python -I tests/test_shader_checks.py` passes. `python -m pytest tests/test_translate.py tests/test_mesh_compute.py` passes, with most tests skipped because there is no llvm-mc. - `python -I scripts/check_no_game_data.py` on both changed files: clean. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] No new translator rule, so nothing to add to the contract table of `docs/design.md` (index metadata only; the emitted SPIR-V is unchanged).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:47:50 +00:00
github manually merged commit e328a59e34 into gh-pr/181/base 2026-11-26 08:47:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.