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

Merged
ItsMrDubey merged 1 commit from upstream-pr/181 into main 2026-11-24 03:28:09 +00:00
ItsMrDubey commented 2026-11-24 02:37:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ItsMrDubey on 2026-11-24T02:37:06Z.


Claimed in the coordination issue as: OLD-5267 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964)

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).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465029597 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/181). Originally posted by [ItsMrDubey](https://github.com/ItsMrDubey) on 2026-11-24T02:37:06Z. --- Claimed in the coordination issue as: OLD-5267 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964) ### 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!181
No description provided.