pixel_aot: lower vector no-op v_nop and sync scanner #559

Merged
Holastor merged 1 commit from upstream-pr/565 into main 2026-11-22 13:09:44 +00:00
Holastor commented 2026-11-22 12:46:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T12:46:34Z.


Description

This PR adds lowering for the vector no-op instruction v_nop (0x7e000000, VOP1 opcode 0x00) in tools/pixel_aot.py and marks it as supported in tools/scan_unsupported_shaders.py.

v_nop is commonly emitted in RDNA 2 shaders for lane padding and execution timing without modifying vector state or execution masks. In the standalone disassembler tools/disasm_rdna2.py, v_nop was already decoded, but pixel_aot.py lacked a matching no-op rule, causing 4,690 shaders (57.6% of scanned shaders) to report v_nop as an unsupported blocker.

Summary of Changes

  1. tools/pixel_aot.py:

    • Added no-op handling for v_nop in lower() alongside s_nop, requiring mask == "entry".
    • Placed after if exported and line != "s_endpgm": raise ValueError(...) so that any v_nop attempting to execute after color export (exp) is rejected.
    • Permitted v_nop in unreachable alignment padding within _check_two_exits().
  2. tools/scan_unsupported_shaders.py:

    • Added r"v_nop" to SUPPORTED_INSTRUCTIONS_REGEX (it was already in KNOWN_RDNA2_BASE_OPCODES).
  3. tests/pixel_aot_check.py:

    • Added v_nop to scheduling_hints() (part of the binary fixture assembled with llvm-mc -mcpu=gfx1013).
    • Extended check_scheduling_hints() to assert:
      • translate(["v_nop"] + plain) == nop
      • Negative controls: rejection of v_nop 0 (invalid operand), plain + ["v_nop"] (after s_endpgm), and plain[:-1] + ["v_nop", plain[-1]] (between exp and s_endpgm).
  4. tests/rdna2_tools_check.py:

    • Added test_gfx1013_v_nop_decode_and_lower:
      • Verifies decoding of machine code bytes 0000007e into v_nop.
      • Verifies 100% recognition by analyze_shader_instructions().
      • Verifies full HLSL shader generation through lower().
      • Negative control: asserts lower() raises ValueError if v_nop occurs after color export.
    • In test_supported_shader_instructions, asserted is_instruction_supported("v_nop") is True, while v_nop 0 and v_nop v0 are False.

Verification

Commit under test: 6c8c16d8

python -B tests/pixel_aot_check.py
# Result: 0 (all assertion checks passed)

python -B tests/rdna2_tools_check.py
# Result: Ran 42 tests in 0.741s - OK (skipped=1)

python -B tests/form_coverage_check.py
# Result: form coverage checks passed

python -B tests/shader_probe_check.py
# Result: Scanned 2/2 files (2 valid shaders) - 10 passed

python -B tests/pso_readiness_check.py
# Result: PSO census, evidence states, and native hash control passed

python -B tests/docs_links_check.py
# Result: Checked 10 Markdown files and 117 links. Self-test passed.

python -B tests/bidi_controls_check.py
# Result: Checked 530 tracked source, script and build/CI files: no bidirectional controls.

Evidence and follow-up

  • All test cases use synthetic byte streams (0000007e) or source-built fixture templates. No game dumps, proprietary assets, or binaries are included.
  • Negative controls explicitly verify that v_nop cannot take operands, cannot occur between color export and s_endpgm, and cannot occur after program termination.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

This change was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6542554253 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/565). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-22T12:46:34Z. --- ## Description This PR adds lowering for the vector no-op instruction `v_nop` (`0x7e000000`, VOP1 opcode 0x00) in `tools/pixel_aot.py` and marks it as supported in `tools/scan_unsupported_shaders.py`. `v_nop` is commonly emitted in RDNA 2 shaders for lane padding and execution timing without modifying vector state or execution masks. In the standalone disassembler `tools/disasm_rdna2.py`, `v_nop` was already decoded, but `pixel_aot.py` lacked a matching no-op rule, causing 4,690 shaders (57.6% of scanned shaders) to report `v_nop` as an unsupported blocker. ### Summary of Changes 1. **`tools/pixel_aot.py`**: - Added no-op handling for `v_nop` in `lower()` alongside `s_nop`, requiring `mask == "entry"`. - Placed after `if exported and line != "s_endpgm": raise ValueError(...)` so that any `v_nop` attempting to execute after color export (`exp`) is rejected. - Permitted `v_nop` in unreachable alignment padding within `_check_two_exits()`. 2. **`tools/scan_unsupported_shaders.py`**: - Added `r"v_nop"` to `SUPPORTED_INSTRUCTIONS_REGEX` (it was already in `KNOWN_RDNA2_BASE_OPCODES`). 3. **`tests/pixel_aot_check.py`**: - Added `v_nop` to `scheduling_hints()` (part of the binary fixture assembled with `llvm-mc -mcpu=gfx1013`). - Extended `check_scheduling_hints()` to assert: - `translate(["v_nop"] + plain) == nop` - Negative controls: rejection of `v_nop 0` (invalid operand), `plain + ["v_nop"]` (after `s_endpgm`), and `plain[:-1] + ["v_nop", plain[-1]]` (between `exp` and `s_endpgm`). 4. **`tests/rdna2_tools_check.py`**: - Added `test_gfx1013_v_nop_decode_and_lower`: - Verifies decoding of machine code bytes `0000007e` into `v_nop`. - Verifies 100% recognition by `analyze_shader_instructions()`. - Verifies full HLSL shader generation through `lower()`. - Negative control: asserts `lower()` raises `ValueError` if `v_nop` occurs after color export. - In `test_supported_shader_instructions`, asserted `is_instruction_supported("v_nop")` is True, while `v_nop 0` and `v_nop v0` are False. --- ## Verification Commit under test: `6c8c16d8` ```powershell python -B tests/pixel_aot_check.py # Result: 0 (all assertion checks passed) python -B tests/rdna2_tools_check.py # Result: Ran 42 tests in 0.741s - OK (skipped=1) python -B tests/form_coverage_check.py # Result: form coverage checks passed python -B tests/shader_probe_check.py # Result: Scanned 2/2 files (2 valid shaders) - 10 passed python -B tests/pso_readiness_check.py # Result: PSO census, evidence states, and native hash control passed python -B tests/docs_links_check.py # Result: Checked 10 Markdown files and 117 links. Self-test passed. python -B tests/bidi_controls_check.py # Result: Checked 530 tracked source, script and build/CI files: no bidirectional controls. ``` --- ## Evidence and follow-up - All test cases use synthetic byte streams (`0000007e`) or source-built fixture templates. No game dumps, proprietary assets, or binaries are included. - Negative controls explicitly verify that `v_nop` cannot take operands, cannot occur between color export and `s_endpgm`, and cannot occur after program termination. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. *This change was AI-assisted.*
upstream-sync closed this pull request 2026-11-24 06:43:42 +00:00
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
R0Y00/Xbox2Windows!559
No description provided.