startup: publish BC3/BC7 memory SRVs whose last tile row or column is partial #2098

Merged
NiiRoZz merged 12 commits from upstream-pr/2105 into main 2026-11-25 01:21:43 +00:00
NiiRoZz commented 2026-11-25 00:25:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T00:25:15Z.


Change

Device slot 70 publishes an address-only BC3_UNORM or BC7_UNORM view at layout 0x105 (4 KiB standard,
non-XOR) only when width and height are multiples of 64 texels. Any other size is refused as
unsupported_description, the destination descriptor keeps its previous bytes, and translated draws that
sample it bind a null texture.

A single-mip 4 KiB standard surface pads its pitch and height to whole tiles. In AMD addrlib (Mesa
5c142e46f3f6e752ed745fd48912ebb8fad67145, src/amd/addrlib/src/gfx10/gfx10addrlib.cpp),
ComputeSurfaceInfoMacroTiled aligns pitch and height to the block size, with no mip tail for one mip.
ComputeSurfaceAddrFromCoordMacroTiled takes a block's tile index as block row × tiles per padded pitch,
plus block column. Bc16Surface and the existing detile path already do the same.

What changes:

  • tiled_bc_srv now accepts any non-zero width and height in whole 4x4 blocks, which the desktop texture
    requires. Other sizes stay refused. One mip, one slice, the alignment, the flags and the view checks are
    unchanged.
  • A partial-tile view still stays refused in two cases, with its own reason in the log:
    • partial_tile_xg_rows: the XG stand-in announced a copy to the address before the first publication
      there. That copy wrote desktop-footprint rows, and the upload would read them as tiles. A copy from the
      opt-in BC7 4 KiB layout writes tiles and does not hold the view.
    • partial_tile_beyond_xg_size: the padded tiles are larger than the size the stand-in reports for the
      description (the footprint rounded to 64 KiB). Those bytes may belong to something else, and the
      readability probe cannot tell. Example: 1028x1028 pads to 1,183,744 bytes against a reported 1,179,648.
  • The first publication at an address of a partial-tile view logs one line, with no addresses. The count is
    a log bound only: at most 64 lines for published views and 8 for refused ones, and nothing depends on
    reaching it.
    It gives the size, format, layout and tiled byte count, plus how many of the first and last 4 KiB are
    non-zero, with a hash. A refused view logs its reason instead.

No change to draw_translated or upload_texture.

Refs #1140 (layout queries: this does not change the XG answers). Open PR #1469 adds a general tiler and
rewrites the same publish_tiled_texture / slot 70 statement in d3d12_memory_srv.inl, so a textual
conflict is expected whichever lands second. It does not widen the slot 70 check.

Verification

Head 681a22a2, which merges current main at 32595645. Measured at the commits named below; Release build, Windows 11 build 26300, debug layer off.

cmake --build --preset release
ctest --preset release --no-tests=error -j1 -R '^startup_(memory_srv.*|address_.*|bc7_4k_s.*|stream_.*)$'
python -B tests/docs_links_check.py

Full filter at ae287201 (merged with main at 06cdc47d): 23 tests selected, 23 passed, 0 failed, 0 skipped.

  • 8 without a GPU: memory SRV, startup_bc7_4k_s and its control, startup_stream_fetch_translate.
  • 8 on WARP (startup_stream_*_warp, startup_address_*_warp), with startup_address_bc_view_warp taking 28.8 s.
  • 7 on RTX 5090 (*_hardware), with startup_address_bc_view_hardware taking 19.9 s.

b52f56af adds two cases to the fixture and the opt-in-copy distinction. At that commit
startup_address_bc_view_warp and startup_address_bc_view_hardware passed (21.0 s and 32.1 s).

The later merge of main at 32595645 (681a22a2) was clean and was not re-tested.

docs_links_check.py: 18 files, 391 links, pass.

startup_address_bc_view ran on NVIDIA GeForce RTX 5090 (32.0.16.2135) and on WARP (10.0.26100.10068).

  • For each format, the 128x128 cases and a 100x68 case matched all 65,536 RGBA pixels.
  • In the 100x68 case the last tile column and row are partial. The padding holds distinct valid blocks,
    texels outside the texture must load as zero, and the log must report 16,384 tiled bytes.

Controls inside the test:

  • A reference built with the tile pitch of the unpadded width (one tile instead of two) differs in
    1,600 pixels for BC3 and 1,500 for BC7.
  • Exchanged tiles change the image.
  • Required refusals: 98x68 and 100x66 (not whole blocks), 1028x1028 (past the reported size), and a 100x68
    view over memory announced as an XG copy.
  • Required publications: a 256x196 view (only the height is partial; its padded size equals the reported
    64 KiB), and a 100x68 view over memory announced by the opt-in BC7 4 KiB copy, which writes real tiles.

Each of these source changes makes the test fail:

Change First failure
Restore the 64-texel check 100x68 BC3 at its first texel row
Drop the height check no refusal for 128x126
Drop the announced-copy refusal no partial_tile_xg_rows refusal
Require both dimensions to be partial (&&) no line for 256x196
Refuse at an equal size (>=) 256x196 held as partial_tile_beyond_xg_size
Ignore which copy was announced opt-in BC7 backing held as partial_tile_xg_rows
Round Bc16Surface tile rows down no 1028x1028 refusal; startup_bc7_4k_s also fails (its rows expect 4096)

The check now translates the pipeline (gfx2hlsl and FXC) once per run and draws every case from that cache.
Before, it translated once per case, and translation dominated the run time. So the four cases run in
about the time the two cases took on main, measured on the same loaded machine:

Backend main, two cases This branch, four cases
WARP 25.4 s 20.4 s
Hardware 21.6 s 24.8 s

The 90 s limit is unchanged.

Evidence and follow-up

The fixture is source-built. It uses the existing literal BC3 encoder and the BC7 block builder of
bc7_draw_check.py, placed with the repository's 4 KiB standard block order (bc7_tiles_check.py).

Assumptions:

  • The padding rule is addrlib's GFX10 rule. That the console uses the same padding is the assumption the
    existing 64-texel path already makes. The optional addrlib oracle test was not run.

  • A partial last column changes block addresses, which the wrong-pitch control covers. A partial last row
    changes only how many bytes are read, which the byte-count assertion and startup_bc7_4k_s cover.

  • Both readability probes (at publish and at upload) check that the padded range is mapped, not that the
    texture owns it. The reported-size refusal covers the case where padding runs past what the title was
    told; within the reported size, ownership is assumed.

  • Limit: the record of an XG copy is never cleared. An address that was once written with desktop rows
    keeps its partial-tile views refused, even if tiled data is later placed there. main refused all of
    these views.

In a local run of a console executable:

  • 15 partial-tile views were published and 0 were unavailable.
  • The two 512x468 views were published with non-zero content.
  • Null texture bindings on that screen fell from 5 per frame to 3.
  • Every checked screen pixel was identical to the base build.

Follow-ups, not in this PR:

  • Address-only views for one-element textures, which needs 3D upload in upload_texture.
  • Tiled formats other than BC3/BC7, mip chains and arrays: these build on #1469.
  • 3D tiling.

docs/experiments.md, "Sample address-only BC3/BC7 textures in translated draws", is updated.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code); the commands listed were run locally.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594255965 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2105). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T00:25:15Z. --- ## Change Device slot 70 publishes an address-only BC3_UNORM or BC7_UNORM view at layout 0x105 (4 KiB standard, non-XOR) only when width and height are multiples of 64 texels. Any other size is refused as `unsupported_description`, the destination descriptor keeps its previous bytes, and translated draws that sample it bind a null texture. A single-mip 4 KiB standard surface pads its pitch and height to whole tiles. In AMD addrlib (Mesa `5c142e46f3f6e752ed745fd48912ebb8fad67145`, `src/amd/addrlib/src/gfx10/gfx10addrlib.cpp`), `ComputeSurfaceInfoMacroTiled` aligns pitch and height to the block size, with no mip tail for one mip. `ComputeSurfaceAddrFromCoordMacroTiled` takes a block's tile index as block row × tiles per padded pitch, plus block column. `Bc16Surface` and the existing detile path already do the same. What changes: - `tiled_bc_srv` now accepts any non-zero width and height in whole 4x4 blocks, which the desktop texture requires. Other sizes stay refused. One mip, one slice, the alignment, the flags and the view checks are unchanged. - A partial-tile view still stays refused in two cases, with its own reason in the log: - `partial_tile_xg_rows`: the XG stand-in announced a copy to the address before the first publication there. That copy wrote desktop-footprint rows, and the upload would read them as tiles. A copy from the opt-in BC7 4 KiB layout writes tiles and does not hold the view. - `partial_tile_beyond_xg_size`: the padded tiles are larger than the size the stand-in reports for the description (the footprint rounded to 64 KiB). Those bytes may belong to something else, and the readability probe cannot tell. Example: 1028x1028 pads to 1,183,744 bytes against a reported 1,179,648. - The first publication at an address of a partial-tile view logs one line, with no addresses. The count is a log bound only: at most 64 lines for published views and 8 for refused ones, and nothing depends on reaching it. It gives the size, format, layout and tiled byte count, plus how many of the first and last 4 KiB are non-zero, with a hash. A refused view logs its reason instead. No change to `draw_translated` or `upload_texture`. Refs #1140 (layout queries: this does not change the XG answers). Open PR #1469 adds a general tiler and rewrites the same `publish_tiled_texture` / slot 70 statement in `d3d12_memory_srv.inl`, so a textual conflict is expected whichever lands second. It does not widen the slot 70 check. ## Verification Head 681a22a2, which merges current main at 32595645. Measured at the commits named below; Release build, Windows 11 build 26300, debug layer off. ```powershell cmake --build --preset release ctest --preset release --no-tests=error -j1 -R '^startup_(memory_srv.*|address_.*|bc7_4k_s.*|stream_.*)$' python -B tests/docs_links_check.py ``` Full filter at ae287201 (merged with main at 06cdc47d): 23 tests selected, 23 passed, 0 failed, 0 skipped. - 8 without a GPU: memory SRV, `startup_bc7_4k_s` and its control, `startup_stream_fetch_translate`. - 8 on WARP (`startup_stream_*_warp`, `startup_address_*_warp`), with `startup_address_bc_view_warp` taking 28.8 s. - 7 on RTX 5090 (`*_hardware`), with `startup_address_bc_view_hardware` taking 19.9 s. b52f56af adds two cases to the fixture and the opt-in-copy distinction. At that commit `startup_address_bc_view_warp` and `startup_address_bc_view_hardware` passed (21.0 s and 32.1 s). The later merge of main at 32595645 (681a22a2) was clean and was not re-tested. `docs_links_check.py`: 18 files, 391 links, pass. `startup_address_bc_view` ran on NVIDIA GeForce RTX 5090 (32.0.16.2135) and on WARP (10.0.26100.10068). - For each format, the 128x128 cases and a 100x68 case matched all 65,536 RGBA pixels. - In the 100x68 case the last tile column and row are partial. The padding holds distinct valid blocks, texels outside the texture must load as zero, and the log must report 16,384 tiled bytes. Controls inside the test: - A reference built with the tile pitch of the unpadded width (one tile instead of two) differs in 1,600 pixels for BC3 and 1,500 for BC7. - Exchanged tiles change the image. - Required refusals: 98x68 and 100x66 (not whole blocks), 1028x1028 (past the reported size), and a 100x68 view over memory announced as an XG copy. - Required publications: a 256x196 view (only the height is partial; its padded size equals the reported 64 KiB), and a 100x68 view over memory announced by the opt-in BC7 4 KiB copy, which writes real tiles. Each of these source changes makes the test fail: | Change | First failure | |---|---| | Restore the 64-texel check | 100x68 BC3 at its first texel row | | Drop the height check | no refusal for 128x126 | | Drop the announced-copy refusal | no `partial_tile_xg_rows` refusal | | Require both dimensions to be partial (`&&`) | no line for 256x196 | | Refuse at an equal size (`>=`) | 256x196 held as `partial_tile_beyond_xg_size` | | Ignore which copy was announced | opt-in BC7 backing held as `partial_tile_xg_rows` | | Round `Bc16Surface` tile rows down | no 1028x1028 refusal; `startup_bc7_4k_s` also fails (its rows expect 4096) | The check now translates the pipeline (gfx2hlsl and FXC) once per run and draws every case from that cache. Before, it translated once per case, and translation dominated the run time. So the four cases run in about the time the two cases took on `main`, measured on the same loaded machine: | Backend | `main`, two cases | This branch, four cases | |---|---|---| | WARP | 25.4 s | 20.4 s | | Hardware | 21.6 s | 24.8 s | The 90 s limit is unchanged. ## Evidence and follow-up The fixture is source-built. It uses the existing literal BC3 encoder and the BC7 block builder of `bc7_draw_check.py`, placed with the repository's 4 KiB standard block order (`bc7_tiles_check.py`). Assumptions: - The padding rule is addrlib's GFX10 rule. That the console uses the same padding is the assumption the existing 64-texel path already makes. The optional addrlib oracle test was not run. - A partial last column changes block addresses, which the wrong-pitch control covers. A partial last row changes only how many bytes are read, which the byte-count assertion and `startup_bc7_4k_s` cover. - Both readability probes (at publish and at upload) check that the padded range is mapped, not that the texture owns it. The reported-size refusal covers the case where padding runs past what the title was told; within the reported size, ownership is assumed. - Limit: the record of an XG copy is never cleared. An address that was once written with desktop rows keeps its partial-tile views refused, even if tiled data is later placed there. `main` refused all of these views. In a local run of a console executable: - 15 partial-tile views were published and 0 were unavailable. - The two 512x468 views were published with non-zero content. - Null texture bindings on that screen fell from 5 per frame to 3. - Every checked screen pixel was identical to the base build. Follow-ups, not in this PR: - Address-only views for one-element textures, which needs 3D upload in `upload_texture`. - Tiled formats other than BC3/BC7, mip chains and arrays: these build on #1469. - 3D tiling. `docs/experiments.md`, "Sample address-only BC3/BC7 textures in translated draws", is updated. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code); the commands listed were run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-11-25 01:02:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:37:27Z.


Can you add a negative case for a partial-tile address after its first valid publication, followed by a desktop-row XG copy at that address and a second slot 70 request? The present refusal is gated on !tiled_srv_addresses.count(address). The current tests cover the XG row copy before the first publication. Please either show which update path preserves the tiled backing for later copies or make the refusal track the latest write provenance, and check the second request preserves its destination descriptor on refusal.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7148706269 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2105#issuecomment-7148706269). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T00:37:27Z. --- Can you add a negative case for a partial-tile address after its first valid publication, followed by a desktop-row XG copy at that address and a second slot 70 request? The present refusal is gated on !tiled_srv_addresses.count(address). The current tests cover the XG row copy before the first publication. Please either show which update path preserves the tiled backing for later copies or make the refusal track the latest write provenance, and check the second request preserves its destination descriptor on refusal.
NiiRoZz commented 2026-11-25 01:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T01:01:20Z.


Thanks, the gap was real: the refusal only covered a row copy before the first publication, and no update path keeps the backing tiled.

As of fc958fb5, the write record stores whether the last XG copy wrote desktop rows or the opt-in tiles, and the refusal follows the latest writer. startup_address_bc_view now publishes a partial-tile view, copies rows over the address, and checks that a second slot 70 request is refused with its destination descriptor unchanged. That case fails on the previous head (the descriptor was overwritten). startup_address_bc_view passes on WARP and on the RTX 5090.

Limit, noted in the docs: a view published before the row copy still reads the address as tiles; only new requests are refused.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149125082 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2105#issuecomment-7149125082). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T01:01:20Z. --- Thanks, the gap was real: the refusal only covered a row copy before the first publication, and no update path keeps the backing tiled. As of `fc958fb5`, the write record stores whether the last XG copy wrote desktop rows or the opt-in tiles, and the refusal follows the latest writer. `startup_address_bc_view` now publishes a partial-tile view, copies rows over the address, and checks that a second slot 70 request is refused with its destination descriptor unchanged. That case fails on the previous head (the descriptor was overwritten). `startup_address_bc_view` passes on WARP and on the RTX 5090. Limit, noted in the docs: a view published before the row copy still reads the address as tiles; only new requests are refused. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 02:01:46 +00:00
R0Y00 commented 2026-11-25 02:02:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:18:14Z.


The new republication case preserves the destination descriptor. An already-bound token could still reach the tiled uploader after the last write changed to desktop rows. I added the same provenance check at sampling time, keeping descriptor bytes intact and binding a null texture while rows are current. Windows Release passed 6/6 (partial/full BC view, address buffer and XG BC-chain on WARP and RTX 4060 Laptop). Disabling only the sampling check changed panel 4 at local pixel (4,0) from zero to 0000ff07 in WARP, while the republication guard stayed active.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149410177 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2105#issuecomment-7149410177). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T01:18:14Z. --- The new republication case preserves the destination descriptor. An already-bound token could still reach the tiled uploader after the last write changed to desktop rows. I added the same provenance check at sampling time, keeping descriptor bytes intact and binding a null texture while rows are current. Windows Release passed 6/6 (partial/full BC view, address buffer and XG BC-chain on WARP and RTX 4060 Laptop). Disabling only the sampling check changed panel 4 at local pixel (4,0) from zero to 0000ff07 in WARP, while the republication guard stayed active.
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!2098
No description provided.