[PR #181] [MERGED] rdna2spirv: index records the --fma mode the shader was translated under (OLD-5267) #233

Closed
opened 2026-11-26 20:17:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/181
Author: @ItsMrDubey
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: fma-index-options


📝 Commits (1)

  • e328a59 rdna2spirv: the index's fma field is the mode the shader was translated under

📊 Changes

2 files changed (+17 additions, -1 deletions)

View changed files

📝 tests/semantic/test_fma_khr.py (+13 -0)
📝 tools/rdna2spirv.py (+4 -1)

📄 Description

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).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/181 **Author:** [@ItsMrDubey](https://github.com/ItsMrDubey) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `fma-index-options` --- ### 📝 Commits (1) - [`e328a59`](https://github.com/ubiquitarianism/leonida/commit/e328a59e344a6acc3a70be2e6b612c1844db6fa0) rdna2spirv: the index's fma field is the mode the shader was translated under ### 📊 Changes **2 files changed** (+17 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_fma_khr.py` (+13 -0) 📝 `tools/rdna2spirv.py` (+4 -1) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:13 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#233
No description provided.