shader: specify raw MUBUF binding contract #717

Manually merged
github merged 1 commit from gh-pr/717/head into gh-pr/717/base 2026-11-26 22:14:03 +00:00
Owner

@⁠lambirou on GitHub · 2026-11-22 22:19 UTC · original
lambirou:shader/gfx1013-raw-mubuf-contract → main · +211 −0 · 2 files · 1 commits · merged 2026-11-22 23:02 UTC

Change

Refs #319.

Document a bounded first contract for lowering one raw buffer_load_dword with
offen in pixel_aot. The proposal keeps the pixel path on ps_6_0 and adds a
visible, bounded space1 descriptor table for the title range table and alias
buffers.

It records the four SGPR words that form a gfx1013 V# with separate masks.
DW0 carries address[31:0], DW1[15:0] carries address[47:32], DW1[29:16] is
the 14-bit byte stride and DW1[31:30] holds the cache-swizzle flags. The
address uses DW0 and DW1[15:0] only, with the descriptor layout cited from the
AMD RDNA 2 instruction-set reference. The first case remains stride zero, no
idxen, zero scalar offset and OOB_SELECT=3. The proposed whole-DWORD bound is:

offen + soffset + 4 <= NUM_RECORDS

The document includes first-word, last-word, complete out-of-range and aligned
partial-tail draws. The aligned partial tail uses NUM_RECORDS = 14 at offset 12
and stays separate from the rejected non-aligned offsets 13 to 15. A guest
bound miss returns zero. A title address inside the guest bound but outside
every published range must surface as a separately observable host binding
failure, not as a successful zero read. An address-extraction control varies
the DW1 stride or flag bits without changing DW1[15:0], so the two descriptors
must produce the same 48-bit base.

Negative controls cover dropped guest bounds, byte/DWORD scaling, the two base
words, a wholesale DW1 shift, the wrong bounds mode, a host mapping miss counted
as zero, an unaligned partial tail, range crossing and unproven descriptor
provenance.

Issue #319 remains open. Its single reply is a contributor preference, not a
maintainer decision. This patch deliberately adds no vector-memory lowering.

Verification

The local commit is 5bf70ce310, rebased onto
origin/main 6f48648e. GitHub still reports the branch as mergeable after main
advanced to 787ace7.

python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

Both checks passed. docs_links_check.py checked 11 Markdown files and 135
links. The bidirectional-control scan checked 601 tracked files.

The Leonida reference at 4eb6155d reports a 732-case hardware measurement on
gfx1036. It includes soffset in mode-3 raw bounds, but does not establish the
gfx1013 rule.

Evidence and follow-up

The proposal asks the maintainer to confirm four points:

  1. the ps_6_0 binding and the visible alias/range bound;
  2. the failure channel for an address that cannot be placed by TitleLookup.
    It must be distinct from a guest bound miss and must not count zero as data;
  3. the initial restriction to mode 3, stride zero, no idxen and zero soffset;
  4. the gfx1013 raw-bounds rule, since the available measurement is gfx1036.

AI-assisted: yes.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • The proposed fixture includes failure cases.
  • I updated the relevant experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.
**@⁠lambirou** on GitHub · 2026-11-22 22:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/717) `lambirou:shader/gfx1013-raw-mubuf-contract` → `main` · +211 −0 · 2 files · 1 commits · merged 2026-11-22 23:02 UTC ## Change Refs #319. Document a bounded first contract for lowering one raw buffer_load_dword with offen in pixel_aot. The proposal keeps the pixel path on ps_6_0 and adds a visible, bounded space1 descriptor table for the title range table and alias buffers. It records the four SGPR words that form a gfx1013 V# with separate masks. DW0 carries address[31:0], DW1[15:0] carries address[47:32], DW1[29:16] is the 14-bit byte stride and DW1[31:30] holds the cache-swizzle flags. The address uses DW0 and DW1[15:0] only, with the descriptor layout cited from the AMD RDNA 2 instruction-set reference. The first case remains stride zero, no idxen, zero scalar offset and OOB_SELECT=3. The proposed whole-DWORD bound is: ~~~text offen + soffset + 4 <= NUM_RECORDS ~~~ The document includes first-word, last-word, complete out-of-range and aligned partial-tail draws. The aligned partial tail uses NUM_RECORDS = 14 at offset 12 and stays separate from the rejected non-aligned offsets 13 to 15. A guest bound miss returns zero. A title address inside the guest bound but outside every published range must surface as a separately observable host binding failure, not as a successful zero read. An address-extraction control varies the DW1 stride or flag bits without changing DW1[15:0], so the two descriptors must produce the same 48-bit base. Negative controls cover dropped guest bounds, byte/DWORD scaling, the two base words, a wholesale DW1 shift, the wrong bounds mode, a host mapping miss counted as zero, an unaligned partial tail, range crossing and unproven descriptor provenance. Issue #319 remains open. Its single reply is a contributor preference, not a maintainer decision. This patch deliberately adds no vector-memory lowering. ## Verification The local commit is 5bf70ce31045e6ca0e1208099ee894edf8054cf8, rebased onto origin/main 6f48648e. GitHub still reports the branch as mergeable after main advanced to 787ace7. ~~~text python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ~~~ Both checks passed. docs_links_check.py checked 11 Markdown files and 135 links. The bidirectional-control scan checked 601 tracked files. The Leonida reference at 4eb6155d reports a 732-case hardware measurement on gfx1036. It includes soffset in mode-3 raw bounds, but does not establish the gfx1013 rule. ## Evidence and follow-up The proposal asks the maintainer to confirm four points: 1. the ps_6_0 binding and the visible alias/range bound; 2. the failure channel for an address that cannot be placed by TitleLookup. It must be distinct from a guest bound miss and must not count zero as data; 3. the initial restriction to mode 3, stride zero, no idxen and zero soffset; 4. the gfx1013 raw-bounds rule, since the available measurement is gfx1036. AI-assisted: yes. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] The proposed fixture includes failure cases. - [x] I updated the relevant experiment documentation. - [x] I did not include game files, dumps, distribution links or secrets.
Document a bounded first buffer_load_dword case for issue #319 with separate DW0/DW1 address masks, a 14-bit stride field, V# provenance, OOB_SELECT 3 bounds and a separately observable host binding failure. The binding and gfx1013 bounds questions remain awaiting maintainer decisions.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:14:01 +00:00
github manually merged commit 5bf70ce310 into gh-pr/717/base 2026-11-26 22:14:03 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 22:36 UTC · original

Please fix an ambiguity in the proposed V# layout before this serves as an implementation contract. Word 1 cannot be copied wholesale into the high half of a 64-bit address while bits [29:16] of that word also carry stride. Name the address and flag masks separately, cite the encoding, and give a control that changes descriptor bits without changing the address. Keep a guest bounds miss distinct from a missing host title-range mapping. The latter should produce a separately observable binding failure in the fixture rather than count a zero result as a successful read. Please also separate aligned partial-bound controls (for example, an aligned offset with fewer than four bytes left in NUM_RECORDS) from rejected non-aligned inputs. The gfx1036 measurements help select the tests, while the gfx1013 behavior remains an open question.

**@⁠R0Y00** on GitHub · 2026-11-22 22:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/717#issuecomment-7086939513) Please fix an ambiguity in the proposed V# layout before this serves as an implementation contract. Word 1 cannot be copied wholesale into the high half of a 64-bit address while bits [29:16] of that word also carry stride. Name the address and flag masks separately, cite the encoding, and give a control that changes descriptor bits without changing the address. Keep a guest bounds miss distinct from a missing host title-range mapping. The latter should produce a separately observable binding failure in the fixture rather than count a zero result as a successful read. Please also separate aligned partial-bound controls (for example, an aligned offset with fewer than four bytes left in NUM_RECORDS) from rejected non-aligned inputs. The gfx1036 measurements help select the tests, while the gfx1013 behavior remains an open question.
Author
Owner

@⁠lambirou on GitHub · 2026-11-22 22:53 UTC · original

I rewrote the V# section and the test plan.

  • The address is now formed from DW0[31:0] and DW1[15:0] only. The document
    names DW1[29:16] as the 14-bit stride and DW1[31:30] as cache-swizzle flags,
    cites the RDNA 2 Buffer Resource Descriptor layout, and adds a control that
    varies those bits without changing the 48-bit base.
  • A guest bound miss still returns zero. An in-bound title address with no
    published range is now specified as a separately observable host binding
    failure, not a successful zero read.
  • The aligned partial tail (NUM_RECORDS = 14, offset 12) is a distinct case
    from the rejected unaligned offsets 13 to 15.
  • The gfx1036 measurements remain the basis for selecting cases, and the
    gfx1013 rule is still called out as open.

The branch is at 5bf70ce31045e6ca0e1208099ee894edf8054cf8 and remains
mergeable against current main. docs_links_check.py and
bidi_controls_check.py pass.

**@⁠lambirou** on GitHub · 2026-11-22 22:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/717#issuecomment-7087152053) I rewrote the V# section and the test plan. - The address is now formed from DW0[31:0] and DW1[15:0] only. The document names DW1[29:16] as the 14-bit stride and DW1[31:30] as cache-swizzle flags, cites the RDNA 2 Buffer Resource Descriptor layout, and adds a control that varies those bits without changing the 48-bit base. - A guest bound miss still returns zero. An in-bound title address with no published range is now specified as a separately observable host binding failure, not a successful zero read. - The aligned partial tail (`NUM_RECORDS = 14`, offset 12) is a distinct case from the rejected unaligned offsets 13 to 15. - The gfx1036 measurements remain the basis for selecting cases, and the gfx1013 rule is still called out as open. The branch is at `5bf70ce31045e6ca0e1208099ee894edf8054cf8` and remains mergeable against current main. `docs_links_check.py` and `bidi_controls_check.py` pass.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 23:02 UTC · original · reviewed

Re-reviewed 5bf70ce as a design-only document. The three requested changes are present. V_BASE_HI_MASK=0x0000ffff now keeps DW1[29:16] stride and DW1[31:30] flags out of the address, with a same-address/different-descriptor-bits control. The test plan requires a separately observable host range failure even when the guest V# bound passes. NUM_RECORDS=14 at aligned offset 12 is a separate partial-tail case, and offsets 13–15 are excluded as unaligned. The proposal explicitly leaves hardware validation on gfx1013 and the final binding decisions open. Both Windows and Linux checks passed at this SHA. My docs-review requests are satisfied.

**@⁠R0Y00** on GitHub · 2026-11-22 23:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/717#pullrequestreview-6014996790) · **reviewed** Re-reviewed `5bf70ce` as a design-only document. The three requested changes are present. `V_BASE_HI_MASK=0x0000ffff` now keeps DW1[29:16] stride and DW1[31:30] flags out of the address, with a same-address/different-descriptor-bits control. The test plan requires a separately observable host range failure even when the guest V# bound passes. NUM_RECORDS=14 at aligned offset 12 is a separate partial-tail case, and offsets 13–15 are excluded as unaligned. The proposal explicitly leaves hardware validation on gfx1013 and the final binding decisions open. Both Windows and Linux checks passed at this SHA. My docs-review requests are satisfied.
This discussion has been locked. Commenting is limited to contributors.
No description provided.