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

Manually merged
github merged 2 commits from gh-pr/2484/head into gh-pr/2484/base 2026-11-27 00:56:00 +00:00
Owner

@⁠ChazY11 on GitHub · 2026-11-25 18:07 UTC · original
ChazY11:startup/getpc-refusal → main · +91 −0 · 5 files · 2 commits · merged 2026-11-25 18:53 UTC

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.

**@⁠ChazY11** on GitHub · 2026-11-25 18:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2484) `ChazY11:startup/getpc-refusal` → `main` · +91 −0 · 5 files · 2 commits · merged 2026-11-25 18:53 UTC 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.
Refs #2463 (third item: `s_getpc_b64` refused in a pixel stage).

The refusal for `s_getpc_b64` came from the dispatcher fallthrough, which raises `Unsupported(base)` with the bare
mnemonic. For a captured request that reads as "the translator has no handler for this instruction", when the
reason is specific: RDNA 2 GETPC returns the address of its successor, i.e. the shader's load address plus a known
byte offset, which is not an integer this model can emit. `calculated_pc_proof()` elides the pair, but only for a
program that also calculates a branch target; reaching the fallthrough means no such proof exists.

    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

Same form a captured request carries — `s_getpc_b64 s[a:b]`, one operand, 4-byte encoding — refused in both a pixel
and a compute stage, with and without the `s_add_u32`/`s_addc_u32` pair that turns it into a pointer, and with the
pair used directly as a descriptor.

`tests/startup_gfx2hlsl_getpc_refusal_check.py` pins the text for six forms (3 forms x 2 stages), the "longer than
the mnemonic" property, and a control that a program whose `s_setpc_b64` target is proven does not reach this
refusal (the GETPC is elided and emits no line).

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

The guard removed -> exit 1, restored -> exit 0. All 63 `tests/startup_gfx2hlsl_*_check.py` exit 0, including
`startup_gfx2hlsl_calculated_target_check.py`, which pins an exhaustive refusal list containing a bare
`s_setpc_b64` — the message is narrowed to `s_getpc_b64` so that list is unchanged.

Not done, and stated rather than implied: this does not lower the instruction. Whether the pair can be lowered for
a program without `s_setpc_b64` needs the captured requests to see what consumes it; without them the refusal is the
honest outcome and the message now says why.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:55:59 +00:00
github manually merged commit e2b0a3737f into gh-pr/2484/base 2026-11-27 00:56:00 +00:00
Author
Owner

@⁠ChazY11 on GitHub · 2026-11-25 18:10 UTC · original

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.

**@⁠ChazY11** on GitHub · 2026-11-25 18:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2484#issuecomment-7170532311) 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 18:40 UTC · original · reviewed

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.

**@⁠tedin7** on GitHub · 2026-11-25 18:40 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2484#pullrequestreview-6063051991) · **reviewed** 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 18:52 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-25 18:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2484#issuecomment-7171520989) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.