test: cover a descriptor key from a root parameter #1760

Merged
ChazY11 merged 1 commit from upstream-pr/1767 into main 2026-11-24 20:40:44 +00:00
ChazY11 commented 2026-11-24 18:15:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T18:15:46Z.


What

Stage.descriptor in tools/startup/gfx2hlsl.py has two shapes of answer:

if s and s[0] == 'desc':
    return s[1], (None if s[2] is None else s[2] + 4 * s[3])   # table entry: byte offset
if s and s[0] == 'ptr':
    return s[1], None                                          # root parameter: no offset

The fixture only builds the table case (subs = {8: ('ptr', ('table', 0))}), so the second branch was
unreachable for every check. Replacing it with return 'bogus', 12 left all seven gfx2hlsl checks green:

startup_translator_check.py            green
startup_inline_sampler_check.py        green
startup_flat_param_check.py            green
startup_gfx2hlsl_capture_check.py      green
startup_sampler_heap_check.py          green
startup_gfx2hlsl_smem_offset_check.py  green
startup_gfx2hlsl_operand_count_check.py green

Change

One case that builds the scalar symbol state for a root parameter and asserts the key, including the None:

+def check_root_descriptor(failures):
+    stage = gfx2hlsl.Stage.__new__(gfx2hlsl.Stage)
+    stage.sym = {8: ('ptr', ('root', 2))}
+    got = stage.descriptor('s[8:11]')
+    want = (('root', 2), None)

Both halves matter: a key that reports the right source but 0 instead of None would look like the first entry of a
table, which is the confusion the desc branch was written to avoid.

Tested

out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py
with the case, branch intact          startup translator checks: 0 failed
branch returns s[1], 0                FAIL (the new case reports the mismatch)
branch returns 'bogus', 12            FAIL
reverted                             0 failed

Scope

One test file, no behaviour change. The raise Unsupported('descriptor operand %s holds %s') line at the end of the
same function is still unreached; I did not add a case for it because reaching it needs a symbol entry of a third shape
and I could not name one the translator actually produces.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588445806 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1767). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:15:46Z. --- ## What `Stage.descriptor` in `tools/startup/gfx2hlsl.py` has two shapes of answer: ```python if s and s[0] == 'desc': return s[1], (None if s[2] is None else s[2] + 4 * s[3]) # table entry: byte offset if s and s[0] == 'ptr': return s[1], None # root parameter: no offset ``` The fixture only builds the table case (`subs = {8: ('ptr', ('table', 0))}`), so the second branch was unreachable for every check. Replacing it with `return 'bogus', 12` left **all seven** `gfx2hlsl` checks green: ```text startup_translator_check.py green startup_inline_sampler_check.py green startup_flat_param_check.py green startup_gfx2hlsl_capture_check.py green startup_sampler_heap_check.py green startup_gfx2hlsl_smem_offset_check.py green startup_gfx2hlsl_operand_count_check.py green ``` ## Change One case that builds the scalar symbol state for a root parameter and asserts the key, including the `None`: ```diff +def check_root_descriptor(failures): + stage = gfx2hlsl.Stage.__new__(gfx2hlsl.Stage) + stage.sym = {8: ('ptr', ('root', 2))} + got = stage.descriptor('s[8:11]') + want = (('root', 2), None) ``` Both halves matter: a key that reports the right source but `0` instead of `None` would look like the first entry of a table, which is the confusion the `desc` branch was written to avoid. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py ``` ```text with the case, branch intact startup translator checks: 0 failed branch returns s[1], 0 FAIL (the new case reports the mismatch) branch returns 'bogus', 12 FAIL reverted 0 failed ``` ## Scope One test file, no behaviour change. The `raise Unsupported('descriptor operand %s holds %s')` line at the end of the same function is still unreached; I did not add a case for it because reaching it needs a symbol entry of a third shape and I could not name one the translator actually produces. ## Notes - AI-assisted.
ChazY11 commented 2026-11-24 19:01:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T18:16:48Z.


Correction to my own note at the end of the description: the final raise Unsupported('descriptor operand %s holds %s') in descriptor is reached. I claimed it was not, and that was wrong — replacing it with return ('x', None) makes startup_inline_sampler_check.py fail, so the inline sampler fixture already drives that branch.

Rechecked with the same seven checks:

descriptor tail raise -> return ('x', None)     startup_inline_sampler_check.py FAILS

So this PR closes the one branch that was genuinely unreached (s[0] == 'ptr'), and the message after it stays covered by a check that predates the change. No edit to the diff needed; only the last paragraph of the body was wrong.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140417443 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1767#issuecomment-7140417443). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:16:48Z. --- Correction to my own note at the end of the description: the final `raise Unsupported('descriptor operand %s holds %s')` in `descriptor` **is** reached. I claimed it was not, and that was wrong — replacing it with `return ('x', None)` makes `startup_inline_sampler_check.py` fail, so the inline sampler fixture already drives that branch. Rechecked with the same seven checks: ```text descriptor tail raise -> return ('x', None) startup_inline_sampler_check.py FAILS ``` So this PR closes the one branch that was genuinely unreached (`s[0] == 'ptr'`), and the message after it stays covered by a check that predates the change. No edit to the diff needed; only the last paragraph of the body was wrong.
tedin7 commented 2026-11-24 20:00:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:34:07Z.

Review: COMMENTED


Reviewed head 8373ae8f649ff6669b250f4b0018d36147680040. No P1/P2 findings.

The new check_root_descriptor builds a Stage with sym = {8: ('ptr', ('root', 2))} and asserts descriptor('s[8:11]') == (('root', 2), None). This matches the ptr branch of Stage.descriptor in tools/startup/gfx2hlsl.py. The test checks both the root source and the None offset, so a root key cannot be confused with the first entry of a table. It is test-only, and the comments describe behavior without outside material.

Commands run locally on Linux in a clean worktree:

  • git diff --check origin/main...HEAD -> rc 0
  • python -B tests/bidi_controls_check.py -> rc 0
  • python -B tests/startup_translator_check.py -> rc 0 (0 failed)

Mutations in tools/startup/gfx2hlsl.py (each reverted with git checkout -- .):

  1. descriptor returns (s[1], 0) instead of (s[1], None) for ptr -> the check FAILS (rc 1: got (('root', 2), 0)).
  2. descriptor returns (('table', 0), None) for ptr -> the check FAILS (rc 1).

Windows 2025 will be verified before any merge, once the overlap with the other PR touching tests/startup_translator_check.py is resolved. This is a review comment only, not an approval.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046008138 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1767#pullrequestreview-6046008138). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:34:07Z. **Review:** COMMENTED --- Reviewed head `8373ae8f649ff6669b250f4b0018d36147680040`. No P1/P2 findings. The new `check_root_descriptor` builds a `Stage` with `sym = {8: ('ptr', ('root', 2))}` and asserts `descriptor('s[8:11]') == (('root', 2), None)`. This matches the `ptr` branch of `Stage.descriptor` in `tools/startup/gfx2hlsl.py`. The test checks both the root source and the `None` offset, so a root key cannot be confused with the first entry of a table. It is test-only, and the comments describe behavior without outside material. Commands run locally on Linux in a clean worktree: - `git diff --check origin/main...HEAD` -> rc 0 - `python -B tests/bidi_controls_check.py` -> rc 0 - `python -B tests/startup_translator_check.py` -> rc 0 (0 failed) Mutations in `tools/startup/gfx2hlsl.py` (each reverted with `git checkout -- .`): 1. `descriptor` returns `(s[1], 0)` instead of `(s[1], None)` for `ptr` -> the check FAILS (rc 1: got `(('root', 2), 0)`). 2. `descriptor` returns `(('table', 0), None)` for `ptr` -> the check FAILS (rc 1). Windows 2025 will be verified before any merge, once the overlap with the other PR touching `tests/startup_translator_check.py` is resolved. This is a review comment only, not an approval. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 21:00:49 +00:00
tedin7 commented 2026-11-24 21:00:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:29:08Z.

Review: COMMENTED


Review of head 8373ae8f64 (tests/startup_translator_check.py only; pure-Python fast path). No P1, no P2.

Commands run locally:

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: rc=0
  • python3 tests/bidi_controls_check.py: rc=0
  • python3 tests/startup_translator_check.py: rc=0 (0 failed)

Mutations of the logic in tools/startup/gfx2hlsl.py, each reverted with git checkout:

  1. Stage.descriptor returns (source, 0) instead of (source, None) for a root parameter: check fails, rc=1.
  2. Stage.descriptor returns ('bogus', 12) for that branch: check fails, rc=1.

The new check kills both mutations. Windows 2025 runs are not applicable (tests/**/*.py only).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046860429 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1767#pullrequestreview-6046860429). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:29:08Z. **Review:** COMMENTED --- Review of head 8373ae8f649ff6669b250f4b0018d36147680040 (tests/startup_translator_check.py only; pure-Python fast path). No P1, no P2. Commands run locally: - git diff --check origin/main...HEAD: rc=0 - python3 tests/docs_links_check.py: rc=0 - python3 tests/bidi_controls_check.py: rc=0 - python3 tests/startup_translator_check.py: rc=0 (0 failed) Mutations of the logic in tools/startup/gfx2hlsl.py, each reverted with git checkout: 1. Stage.descriptor returns (source, 0) instead of (source, None) for a root parameter: check fails, rc=1. 2. Stage.descriptor returns ('bogus', 12) for that branch: check fails, rc=1. The new check kills both mutations. Windows 2025 runs are not applicable (tests/**/*.py only). AI-assisted; commands listed were executed locally.
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!1760
No description provided.