docs(debt): measure the image store DST_SEL rule on RDNA2 #18595

Merged
angrysandhill merged 1 commit from upstream-pr/18595 into main 2026-11-12 13:00:40 +00:00
angrysandhill commented 2026-11-11 22:31:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by angrysandhill on 2026-11-11T22:31:00Z.


What

A measurement; no code changes. The StoreTexel debt entry recorded one hardware data point: with DST_SEL X,Y,Z,W, gfx1035 writes channel 1 of a two-channel format from the W slot (#944; #8282 saw the same on gfx1010). This replaces it with the rule measured on RDNA2 (gfx1031) over every DST_SEL tuple and DMASK, and adds a second entry for one- and four-channel formats.

The recompiler fills each texel channel from the lowest data slot whose DST_SEL names it. The hardware does not invert the swizzle that way. It picks the channels by a fixed rule per channel count, reading absent DMASK components as 0:

  • Two-channel formats read DST_SEL X, Y and Z only. "Channel" means X, Y, Z or W; "constant" means 0 or 1.

    DST_SEL X DST_SEL Y DST_SEL Z stored (channel 0, channel 1)
    X channel constant (x, y)
    X constant any (x, w)
    X channel channel (x, w)
    not X channel constant (y, x)
    not X any channel (w, x)
    not X constant constant (x, w)

    So X,Y,Z,W stores (x, w) where the recompiler stores (x, y). X,Y,0,1, Y,X,0,1 and X,X,X,Y agree with the recompiler.

  • One-channel formats store x when DST_SEL X is X, and w otherwise.

  • Four-channel formats:

    • DST_SEL Y is Y: each channel gets what its own DST_SEL names (a data component, or the constant 0 or 1).
    • Otherwise: the DST_SEL are read in reverse channel order with the data reversed (X reads w, Y reads z). So X,0,0,1 stores (1, 0, 0, w), and Y,Z,X,W stores (x, w, y, z).
    • Agree with the recompiler: X,Y,Z,W and Z,Y,X,W.
    • Constants are stored as the format's 0 and 1 (0xff, 0xffff, 0x3c00, 0x3f800000, 1).
  • 32_32_32_UINT: a store to a linear T# writes nothing.

Not fixed here: a fix needs the format's channel count at the store, which ImageResource, the image specialization constants and image table accesses don't carry. That is a separate change.

Tested

Setup: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), Windows 10 22H2. Hardware oracle through HIP, wave32, IEEE 0, DX10_CLAMP 1, f32 and f16 denormals kept, round to nearest even, FP16_OVFL 0.

Method:

  • Descriptor: a linear (SW_MODE 0) one-row 2D T# (TYPE 9, width 2048), built in SGPRs over the oracle's extra bytes, which are filled with 0xcd.
  • Stores: lane 0 alone runs image_store ... dim:SQ_RSRC_IMG_2D unorm glc, one texel per DST_SEL tuple and DMASK, with s_mov_b32 changing T# word 3 between stores.
  • Data: (0x11, 0x22, 0x33, 0x44); (2.0, 3.0, 4.0, 5.0) for FLOAT; (0.1, 0.2, 0.3, 0.4) for UNORM and SNORM.
  • Read-back: after s_waitcnt_vscnt, buffer_gl0_inv and buffer_gl1_inv, every lane reads 64 bytes back with glc dlc global loads.
  • Coverage: all 1,296 DST_SEL tuples over {0, 1, X, Y, Z, W} × all 15 DMASKs, so 19,440 stores per format.

Formats:

  • Two-channel: 8_8 and 16_16 UNORM, SNORM, UINT and SINT; 16_16 FLOAT; 32_32 UINT, SINT and FLOAT.
  • One-channel: 8_UNORM, 8_SINT, 16_UNORM, 16_SINT, 16_FLOAT, 32_SINT, 32_FLOAT.
  • Four-channel: 8_8_8_8 UNORM, UINT and SINT; 16_16_16_16 UNORM, SINT and FLOAT; 32_32_32_32_FLOAT.
  • Three-channel: 32_32_32_UINT.

Result: the rules above predict all 505,440 stores in the 26 formats, and no texel kept a fill byte. In 32_32_32_UINT every texel kept its fill bytes.

The recompiler's side:

  • Through the probe: the same probe through HW_ORACLE_RUNTIME=vulkan writes nothing, because the runner doesn't back a descriptor built in SGPRs at run time.
  • Through agc_driver_image_store_sint instead: with its SwizzleOf changed locally to return X,Y,Z,W for the two-channel formats, the test still passes on this card. Its expected values take channel 1 from the Y slot. So the recompiler stores (x, y) where gfx1031 stores (x, w). That change is not part of this PR.
  • Which "agrees with the recompiler" cells were run: X,Y,0,1 on two channels and X,Y,Z,W on four, which that test already uses on main. The other agreeing cells are read from StoreTexel's code: Y,X,0,1 and X,X,X,Y on two channels, Z,Y,X,W on four, and one-channel DST_SEL with X=X.

Checks:

  • tools/check_conventions.py: passed. Both entries are under 1,000 characters.
  • git diff --check: clean.

Overlap:

  • #10652: adds an entry right after the old StoreTexel line, so the two conflict textually; the resolution keeps both.
  • #17623: adds a signed packed images entry next to it; the same kind of conflict, and the resolution keeps both.
  • #14212: reformats every entry of the file.
  • Other PRs: no other open PR edits this entry.

Not measured: the PS5's gfx1013; tiled swizzle modes (every row used a linear T#); three-channel formats other than 32_32_32_UINT; SRGB and SCALED formats; the other image dimensions; image_store_mip and D16 stores.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (32.0.21045.16010), Windows 10 22H2
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5267747862 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18595). Originally posted by [angrysandhill](https://github.com/angrysandhill) on 2026-11-11T22:31:00Z. --- ### What A measurement; no code changes. The `StoreTexel` debt entry recorded one hardware data point: with DST_SEL X,Y,Z,W, gfx1035 writes channel 1 of a two-channel format from the W slot (#944; #8282 saw the same on gfx1010). This replaces it with the rule measured on RDNA2 (gfx1031) over every DST_SEL tuple and DMASK, and adds a second entry for one- and four-channel formats. The recompiler fills each texel channel from the lowest data slot whose DST_SEL names it. The hardware does not invert the swizzle that way. It picks the channels by a fixed rule per channel count, reading absent DMASK components as 0: - **Two-channel formats** read DST_SEL X, Y and Z only. "Channel" means X, Y, Z or W; "constant" means 0 or 1. | DST_SEL X | DST_SEL Y | DST_SEL Z | stored (channel 0, channel 1) | |---|---|---|---| | X | channel | constant | (x, y) | | X | constant | any | (x, w) | | X | channel | channel | (x, w) | | not X | channel | constant | (y, x) | | not X | any | channel | (w, x) | | not X | constant | constant | (x, w) | So X,Y,Z,W stores (x, w) where the recompiler stores (x, y). X,Y,0,1, Y,X,0,1 and X,X,X,Y agree with the recompiler. - **One-channel formats** store x when DST_SEL X is X, and w otherwise. - **Four-channel formats:** - **DST_SEL Y is Y:** each channel gets what its own DST_SEL names (a data component, or the constant 0 or 1). - **Otherwise:** the DST_SEL are read in reverse channel order with the data reversed (X reads w, Y reads z). So X,0,0,1 stores (1, 0, 0, w), and Y,Z,X,W stores (x, w, y, z). - **Agree with the recompiler:** X,Y,Z,W and Z,Y,X,W. - **Constants** are stored as the format's 0 and 1 (`0xff`, `0xffff`, `0x3c00`, `0x3f800000`, 1). - **`32_32_32_UINT`:** a store to a linear T# writes nothing. **Not fixed here:** a fix needs the format's channel count at the store, which `ImageResource`, the image specialization constants and image table accesses don't carry. That is a separate change. ### Tested **Setup:** AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), Windows 10 22H2. [Hardware oracle](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/HW_ORACLE.md) through HIP, wave32, IEEE 0, DX10_CLAMP 1, f32 and f16 denormals kept, round to nearest even, FP16_OVFL 0. **Method:** - **Descriptor:** a linear (`SW_MODE` 0) one-row 2D T# (TYPE 9, width 2048), built in SGPRs over the oracle's `extra` bytes, which are filled with `0xcd`. - **Stores:** lane 0 alone runs `image_store ... dim:SQ_RSRC_IMG_2D unorm glc`, one texel per DST_SEL tuple and DMASK, with `s_mov_b32` changing T# word 3 between stores. - **Data:** `(0x11, 0x22, 0x33, 0x44)`; `(2.0, 3.0, 4.0, 5.0)` for FLOAT; `(0.1, 0.2, 0.3, 0.4)` for UNORM and SNORM. - **Read-back:** after `s_waitcnt_vscnt`, `buffer_gl0_inv` and `buffer_gl1_inv`, every lane reads 64 bytes back with `glc dlc` global loads. - **Coverage:** all 1,296 DST_SEL tuples over {0, 1, X, Y, Z, W} × all 15 DMASKs, so 19,440 stores per format. **Formats:** - **Two-channel:** 8_8 and 16_16 UNORM, SNORM, UINT and SINT; 16_16 FLOAT; 32_32 UINT, SINT and FLOAT. - **One-channel:** 8_UNORM, 8_SINT, 16_UNORM, 16_SINT, 16_FLOAT, 32_SINT, 32_FLOAT. - **Four-channel:** 8_8_8_8 UNORM, UINT and SINT; 16_16_16_16 UNORM, SINT and FLOAT; 32_32_32_32_FLOAT. - **Three-channel:** 32_32_32_UINT. **Result:** the rules above predict all 505,440 stores in the 26 formats, and no texel kept a fill byte. In 32_32_32_UINT every texel kept its fill bytes. **The recompiler's side:** - **Through the probe:** the same probe through `HW_ORACLE_RUNTIME=vulkan` writes nothing, because the runner doesn't back a descriptor built in SGPRs at run time. - **Through `agc_driver_image_store_sint` instead:** with its `SwizzleOf` changed locally to return X,Y,Z,W for the two-channel formats, the test still passes on this card. Its expected values take channel 1 from the Y slot. So the recompiler stores (x, y) where gfx1031 stores (x, w). That change is not part of this PR. - **Which "agrees with the recompiler" cells were run:** X,Y,0,1 on two channels and X,Y,Z,W on four, which that test already uses on `main`. The other agreeing cells are read from `StoreTexel`'s code: Y,X,0,1 and X,X,X,Y on two channels, Z,Y,X,W on four, and one-channel DST_SEL with X=X. **Checks:** - **`tools/check_conventions.py`:** passed. Both entries are under 1,000 characters. - **`git diff --check`:** clean. **Overlap:** - **#10652:** adds an entry right after the old `StoreTexel` line, so the two conflict textually; the resolution keeps both. - **#17623:** adds a signed packed images entry next to it; the same kind of conflict, and the resolution keeps both. - **#14212:** reformats every entry of the file. - **Other PRs:** no other open PR edits this entry. **Not measured:** the PS5's gfx1013; tiled swizzle modes (every row used a linear T#); three-channel formats other than 32_32_32_UINT; SRGB and SCALED formats; the other image dimensions; `image_store_mip` and D16 stores. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (32.0.21045.16010), Windows 10 22H2 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
boykopovar/AnyPS5!18595
No description provided.