startup: name why s_getpc_b64 is refused instead of reporting the mnemonic alone #2476

Merged
ChazY11 merged 2 commits from upstream-pr/2484 into main 2026-11-25 18:53:31 +00:00
ChazY11 commented 2026-11-25 18:07:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:07:35Z.


Refs #2463 — third item (s_getpc_b64 refused in a pixel stage), the one the census lists as "not investigated;
the first step is to name the exact form and what consumes the pair". This is that step, plus the message the
naming makes possible.

What the pair is, from the tree

s_getpc_b64 s[a:b] (one operand, 4-byte encoding) returns the address of its successor. The project already
documents exactly what consumes it — calculated_pc_proof(), whose docstring says:

RDNA 2 GETPC returns the address of its successor. A low-word ADD_U32 and a high-word ADDC_U32 with its matching
sign extension add one signed byte displacement, including any carry across the (unknown) loaded PC's low word. A
completed pair is therefore the shader's load address plus a known byte offset, not an integer value that can be
emitted to HLSL.

So the pair is a load address plus a known offset. It is elided when the program also computes a branch target
(s_setpc_b64), which is what makes calculated_pc_proof() run at all — if not any(name == 's_setpc_b64' ...): return {}. A program with GETPC and no SETPC reaches the dispatcher fallthrough, which raised Unsupported(base)
with the bare mnemonic.

What changed

One named refusal, no behaviour change for any accepted program:

before: s_getpc_b64  ->  s_getpc_b64
after:  s_getpc_b64  ->  s_getpc_b64: the shader load address is only elided for a program that also calculates a
                          branch target

Measured for six forms — the instruction alone, with the s_add_u32/s_addc_u32 pair that makes it a pointer, and
with the pair used directly as a descriptor, each in a pixel and a compute stage. Narrowed to s_getpc_b64 on
purpose: s_setpc_b64 keeps its bare text because tests/startup_gfx2hlsl_calculated_target_check.py pins an
exhaustive refusal list containing it, and changing that message would have meant editing someone else's assertion.

Verification

python out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_getpc_refusal_check.py
getpc refusal checks: 0 failed
PASS

guard removed -> exit 1 ; restored -> exit 0

63/63 tests/startup_gfx2hlsl_*_check.py exit 0, including startup_gfx2hlsl_calculated_target_check.py

Registered in CMakeLists.txt (startup_gfx2hlsl_getpc_refusal), the Linux Run Python checks list, and AGENTS.md.

What this does not do

It does not lower the instruction. Whether the pair can be lowered for a program without s_setpc_b64 depends on
what consumes it in the captured requests, which I cannot see; if the value ends up as a pointer into the shader's
own image, the model has nothing to bind it to and the refusal is the honest outcome — now with a reason the census
can group separately from "no handler exists".

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6610690015 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2484). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T18:07:35Z. --- Refs #2463 — third item (`s_getpc_b64` refused in a pixel stage), the one the census lists as "not investigated; the first step is to name the exact form and what consumes the pair". This is that step, plus the message the naming makes possible. ## What the pair is, from the tree `s_getpc_b64 s[a:b]` (one operand, 4-byte encoding) returns the address of its successor. The project already documents exactly what consumes it — `calculated_pc_proof()`, whose docstring says: > RDNA 2 GETPC returns the address of its successor. A low-word ADD_U32 and a high-word ADDC_U32 with its matching > sign extension add one signed byte displacement, including any carry across the (unknown) loaded PC's low word. A > completed pair is therefore the shader's load address plus a known byte offset, not an integer value that can be > emitted to HLSL. So the pair is a **load address plus a known offset**. It is elided when the program also computes a branch target (`s_setpc_b64`), which is what makes `calculated_pc_proof()` run at all — `if not any(name == 's_setpc_b64' ...): return {}`. A program with GETPC and no SETPC reaches the dispatcher fallthrough, which raised `Unsupported(base)` with the bare mnemonic. ## What changed One named refusal, no behaviour change for any accepted program: ```text before: s_getpc_b64 -> s_getpc_b64 after: s_getpc_b64 -> s_getpc_b64: the shader load address is only elided for a program that also calculates a branch target ``` Measured for six forms — the instruction alone, with the `s_add_u32`/`s_addc_u32` pair that makes it a pointer, and with the pair used directly as a descriptor, each in a pixel and a compute stage. Narrowed to `s_getpc_b64` on purpose: `s_setpc_b64` keeps its bare text because `tests/startup_gfx2hlsl_calculated_target_check.py` pins an exhaustive refusal list containing it, and changing that message would have meant editing someone else's assertion. ## Verification ```text python out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_getpc_refusal_check.py getpc refusal checks: 0 failed PASS guard removed -> exit 1 ; restored -> exit 0 63/63 tests/startup_gfx2hlsl_*_check.py exit 0, including startup_gfx2hlsl_calculated_target_check.py ``` Registered in `CMakeLists.txt` (`startup_gfx2hlsl_getpc_refusal`), the Linux `Run Python checks` list, and `AGENTS.md`. ## What this does not do It does not lower the instruction. Whether the pair can be lowered for a program without `s_setpc_b64` depends on what consumes it in the captured requests, which I cannot see; if the value ends up as a pointer into the shader's own image, the model has nothing to bind it to and the refusal is the honest outcome — now with a reason the census can group separately from "no handler exists". AI-assisted.
upstream-sync closed this pull request 2026-11-25 19:04:00 +00:00
tedin7 commented 2026-11-25 19:04:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:40:35Z.

Review: COMMENTED


Review of head 6df68b1882b1 (comment only, no merge or approval).

What I checked:

  • The change is small and additive: one new branch in tools/startup/gfx2hlsl.py that raises a named Unsupported for s_getpc_b64 when no calculated-target proof exists. Accepted programs are unchanged, because the branch sits just before the old bare raise Unsupported(base).
  • The reason text matches the repo's own calculated_pc_proof() docstring (load address plus a known byte offset, elided only when s_setpc_b64 is also present).
  • The new test has a negative control: a proven calculated target does not reach the named refusal and emits no line for the elided GETPC.
  • Mutation: renaming the base == 's_getpc_b64' condition made the new check report 8 failed. Restored, it reports 0 failed.
  • The sibling test startup_gfx2hlsl_calculated_target_check.py still passes. s_setpc_b64 correctly keeps its bare text, as the PR body explains.
  • The test is registered in CMakeLists.txt, the AGENTS.md list and the Linux Run Python checks step of .github/workflows/windows.yml. That workflow change is one added line in an existing list.
  • No other open or merged PR covers this refusal message (searched s_getpc_b64). #2238 and #2189 cover the proven-target lowering, not this message.
  • Scope: this does not claim to advance game startup, and it does not lower any instruction.

Commands run locally:

  • python3 -B tests/startup_gfx2hlsl_getpc_refusal_check.py -> 0 failed, PASS
  • python3 -B tests/startup_gfx2hlsl_calculated_target_check.py -> pass
  • python3 tests/docs_links_check.py -> 19 files, 468 links ok
  • python3 tests/bidi_controls_check.py -> ok
  • git diff --check origin/main...HEAD -> clean
  • mutation of the new branch -> new test fails; restored with git checkout -- .

Not checked:

  • No Windows run from me. The PR body quotes a Windows run, but it names no head SHA and I found no result comment on 6df68b1882b1.
  • CI on this head was still PENDING when I looked. The workflow change adds one test to an existing list, so the PR's own CI run on this head is the proof that the step passes.

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063051991 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2484#pullrequestreview-6063051991). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:40:35Z. **Review:** COMMENTED --- Review of head 6df68b1882b1 (comment only, no merge or approval). What I checked: - The change is small and additive: one new branch in `tools/startup/gfx2hlsl.py` that raises a named `Unsupported` for `s_getpc_b64` when no calculated-target proof exists. Accepted programs are unchanged, because the branch sits just before the old bare `raise Unsupported(base)`. - The reason text matches the repo's own `calculated_pc_proof()` docstring (load address plus a known byte offset, elided only when `s_setpc_b64` is also present). - The new test has a negative control: a proven calculated target does not reach the named refusal and emits no line for the elided GETPC. - Mutation: renaming the `base == 's_getpc_b64'` condition made the new check report 8 failed. Restored, it reports 0 failed. - The sibling test `startup_gfx2hlsl_calculated_target_check.py` still passes. `s_setpc_b64` correctly keeps its bare text, as the PR body explains. - The test is registered in `CMakeLists.txt`, the `AGENTS.md` list and the Linux `Run Python checks` step of `.github/workflows/windows.yml`. That workflow change is one added line in an existing list. - No other open or merged PR covers this refusal message (searched `s_getpc_b64`). #2238 and #2189 cover the proven-target lowering, not this message. - Scope: this does not claim to advance game startup, and it does not lower any instruction. Commands run locally: - `python3 -B tests/startup_gfx2hlsl_getpc_refusal_check.py` -> 0 failed, PASS - `python3 -B tests/startup_gfx2hlsl_calculated_target_check.py` -> pass - `python3 tests/docs_links_check.py` -> 19 files, 468 links ok - `python3 tests/bidi_controls_check.py` -> ok - `git diff --check origin/main...HEAD` -> clean - mutation of the new branch -> new test fails; restored with `git checkout -- .` Not checked: - No Windows run from me. The PR body quotes a Windows run, but it names no head SHA and I found no result comment on 6df68b1882b1. - CI on this head was still PENDING when I looked. The workflow change adds one test to an existing list, so the PR's own CI run on this head is the proof that the step passes. No blocking findings. AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-25 19:04:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:10:03Z.


Two verifications on the rebased head 93208699, so nothing here needs re-running to review:

1. Registration is live, not just present in the diff.

cmake --preset dev
ctest --preset dev -N -R 'getpc_refusal'
    Test #625: startup_gfx2hlsl_getpc_refusal

2. The new refusal text survives the census normaliser, so it groups separately from the bare mnemonic —
which is the whole point of the change:

normalize_refusal('s_getpc_b64: the shader load address is only elided for a program that also calculates a branch target')
  -> unchanged (no numbers to redact)
  -> != 's_getpc_b64'

Also, for anyone reading the diff: the guard is narrowed to s_getpc_b64 on purpose. startup_gfx2hlsl_calculated_target_check.py
pins an exhaustive refusal list that includes a bare s_setpc_b64, and I would rather leave that assertion untouched
than retune someone else's expected text. If you want s_setpc_b64 named the same way, it is a one-line follow-up plus
that list's entry.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7170532311 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2484#issuecomment-7170532311). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T18:10:03Z. --- Two verifications on the rebased head `93208699`, so nothing here needs re-running to review: **1. Registration is live, not just present in the diff.** ```text cmake --preset dev ctest --preset dev -N -R 'getpc_refusal' Test #625: startup_gfx2hlsl_getpc_refusal ``` **2. The new refusal text survives the census normaliser, so it groups separately from the bare mnemonic** — which is the whole point of the change: ```text normalize_refusal('s_getpc_b64: the shader load address is only elided for a program that also calculates a branch target') -> unchanged (no numbers to redact) -> != 's_getpc_b64' ``` Also, for anyone reading the diff: the guard is narrowed to `s_getpc_b64` on purpose. `startup_gfx2hlsl_calculated_target_check.py` pins an exhaustive refusal list that includes a bare `s_setpc_b64`, and I would rather leave that assertion untouched than retune someone else's expected text. If you want `s_setpc_b64` named the same way, it is a one-line follow-up plus that list's entry. AI-assisted.
R0Y00 commented 2026-11-25 19:04:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T18:52:31Z.


I reproduced a false positive in the proposed GETPC control: its target was outside the decoded program, and any refusal other than the new GETPC message satisfied the test. e2b0a373 now reuses the existing assembled calculated-jump fixture and requires the exact CFG and arithmetic result. The pixel and compute refusal checks and the proven control pass locally at this head. Fresh CI is running.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171520989 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2484#issuecomment-7171520989). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T18:52:31Z. --- I reproduced a false positive in the proposed GETPC control: its target was outside the decoded program, and any refusal other than the new GETPC message satisfied the test. `e2b0a373` now reuses the existing assembled calculated-jump fixture and requires the exact CFG and arithmetic result. The pixel and compute refusal checks and the proven control pass locally at this head. Fresh CI is running.
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!2476
No description provided.