Skip to content

gpu: integrate fence-safe sampling of by-address console textures - #2214

Merged
R0Y00 merged 5 commits into
mainfrom
codex/slot70-loading-art-verified
Nov 25, 2026
Merged

R0Y00 merged 5 commits into
mainfrom
codex/slot70-loading-art-verified

Conversation

@R0Y00

@R0Y00 R0Y00 commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Refs #2015, #870. The original console-layout support landed separately in b9da095. This follow-up validates storage and typed views, checks overlapping live resources, and retries dedicated uploads after an abandoned recording or a staging failure. The shared-ring control now selects that mode explicitly.

The source-built gate records payload 0, closes and resets its command list without submitting, then draws the same bytes again. Eighteen 16 MiB submissions wait behind one fence. After it opens, the first and last payloads must survive and all eighteen submissions must retire. Reusing the 256 MiB ring must corrupt only the left half of the target. An initial fixture set the environment variable to an empty string; on Windows this selected the ring control in both runs. The ordinary run now removes the variable.

Windows 11 build 26200, NVIDIA RTX 4060 Laptop (32.0.16.1656) and WARP, Release, draw-fixture debug layer disabled. On f1b854c: 20/20 passed, no skips, including ordinary and mutation on each backend. The local offline saved-profile replay of the candidate before synchronization displayed a loading illustration, then stopped at a second-chance C++ exception after a slot-148 no-op; that subsequent stage is tracked separately in #1758. No private artifacts are included.

cmake --build --preset release --target startup_stream_consumer startup_gfx10_layout_check startup_bc64_supports_check startup_single_element_srv_check
ctest --preset release --no-tests=error --output-on-failure -R '^startup_(address_|gfx10_layout|single_element_srv|bc64_supports)'

Its3rr0rsWRLD and others added 5 commits November 24, 2026 23:17
…their address

Device slot 70 publishes a texture by address: a resource description, a view
and the address of the texels, with no resource object. It read a few shapes
from the address (the single texel, single-mip BC3/BC7 at layout 0x105 with
partial last tiles, and the 0x109 BC chains) and otherwise needed a live
resource with that description at the address. Every other description was
refused, which leaves the title's descriptor as it was and the draw sampling
nothing.

When no live resource matches, it now also reads a two-dimensional,
single-sample, sampled-only texture whose format has a known element size
(block-compressed formats in whole 4x4 blocks) and whose Layout names a
console swizzle mode 0x101, 0x102, 0x105, 0x106, 0x109 or 0x10a, in that
console layout, mip chains and array slices included (gfx10_layout.h). Views
may name a format of the same typeless family, a mip range or an array range.
The shapes slot 70 already read keep their own paths unchanged. Layout 0 and
the linear mode 0x100 without a live texture stay refused, as do
three-dimensional and cube views, multisampled textures and the XOR swizzle
modes: startup_address_srv, with its mismatched-width and interior-address
calls, runs unchanged in the default configuration.

Upload lifetime. The shared upload ring is reused without waiting for a queue,
so a queue held behind a fence could execute a recorded copy after later
uploads had passed over its source. An upload of a console-layout texture
therefore owns its upload buffer (x2w_upload::make_page). The recording keeps
a reference to the buffer and to the texture until the list is reset; each
ExecuteCommandLists of the recording takes its own references and signals a
fence behind the submit, and a later submit drops the references of the
submits whose fence has completed, as the draw sampler heaps already do. A
submit whose fence cannot be made keeps its references. The desktop texture
of a by-address texture is not released. The earlier by-address shapes keep
the ring. A repeated slot-70 call for a texture this slot published publishes
it again, which announces a write, so changed texels are uploaded again.

A console-layout description is held in the two cases a partial-tile BC view
is held for (#2105): when the latest XG stand-in copy announced for the
address wrote desktop-footprint rows (a texture already published there then
samples the null view, as a partial-tile view does), and when the layout runs
past the size the XG stand-in reports for the description, which the title
may not own.

The address equations, block dimensions and mip-tail rules follow AMD addrlib
as Mesa carries it under src/amd/addrlib, at the revision tools/fetch_addrlib.py
pins (Mesa 25.1.0, commit 5c142e46f3f6e752ed745fd48912ebb8fad67145; MIT):
src/gfx10/gfx10SwizzlePattern.h, src/core/addrlib2.cpp and
src/gfx10/gfx10addrlib.cpp. The rules are restated; no addrlib code is included.
The header and both fixtures name the files and their notice.

Diagnostics: one "slot70 texture kind" line per new kind of call, and a line
when retained uploads are released.

Tests:
- startup_gfx10_layout: the equations against the addrlib rows, agreement with
  bc7_4k_s.h, bc64_chain.h and tile64_plan.h, round trips, accepted
  descriptions and views; a display-order control that must fail.
- startup_address_console_{warp,hardware}: seven textures drawn from bytes
  built by an independent oracle, every pixel compared; then the two held
  descriptions, which must log their reason and draw the null view, and a
  published texture whose address is announced as XG rows before the draw,
  which must draw the null view.
- startup_address_console_gate_{warp,hardware}: the queue waits on a fence the
  fixture holds while eighteen lists are recorded and submitted on one list
  object, each after a new 16 MiB payload was written at the same address.
  Nothing may complete before the fence is signalled; afterwards the target
  must hold the first payload on the left and the last on the right, and the
  log must report eighteen retained submits released.
- startup_address_console_gate_ring_{warp,hardware}: the same draws with
  X2W_TEST_ADDRESS_UPLOAD_RING=1 (fixtures only), which fills the textures from
  the 256 MiB ring; the first payload must be lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
Adds the accepted descriptions, views, limits, the upload lifetime rule, the
held cases and the log lines to docs/startup-runtime.md, with a note on which
address-equation rows have a second source in the tree and which are checked
against the addrlib rows alone, and the fixtures with their reproduction
commands to docs/experiments.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head f1b854c72d8018442b3ee639cc63f05545713c43 (comment only).

Status notes

  • GitHub reports this PR as MERGEABLE against current main, and a local git merge-tree --write-tree origin/main HEAD gave a clean tree, so I could not reproduce a conflict. If a conflict shows up on your side, please rebase onto main before Ready.
  • CI checks were still pending when I looked (Linux Python checks, Windows build/test, gfx1013 fixtures).
  • Title is neutral, and I saw nothing in the diff that breaks the clean-room rule.

What I checked

  • The tighter console_address_texture / address_view_fits rules in address_texture.h. They are a clear improvement: depth formats are refused, a typed UNORM store no longer accepts an sRGB view, the component mapping is validated, ResourceMinLODClamp must be 0, and a plain 2D view needs DepthOrArraySize == 1.
  • The new per-list upload bookkeeping in d3d12_draw.inl: a discarded list resets done/pending_list, a retired list sets done only if the cached revision matches, and the bad_alloc path pins the buffer and texture instead of freeing them early. The logic reads correctly.

Findings

  • P1: none.
  • P2: none.
  • nit: struct AddressUpload in d3d12_draw.inl now has u64 revision; with no default initializer, while its neighbours are initialized. Writing u64 revision = 0; would make a partial aggregate init safe.
  • nit: in retire_address_uploads the first loop (revision/done update) runs outside the new try, and the second loop looks the lists up again. Folding them into one pass would be easier to follow. This is not a bug.
  • nit: the bad_alloc pin path is a deliberate leak with a log line. It would be good to have a test that forces it, if that is cheap. I did not find one.

Commands executed locally

  • python3 tests/docs_links_check.py -> Self-test passed. Checked 18 Markdown files and 409 links.
  • python3 tests/bidi_controls_check.py -> no bidirectional controls in 1493 files.
  • git diff --check origin/main...HEAD -> clean.
  • python3 tests/startup_address_console_check.py -> prints usage only on Linux (it needs the Windows backend), so it gave no signal.
  • x86_64-w64-mingw32-g++ -std=c++17 -Isrc -static tests/startup_gfx10_layout_check.cpp then run under wine -> startup_gfx10_layout: PASS (30 equations, ... 19 address descriptions, 21 views).
  • Mutation: I removed r.DepthOrArraySize == 1 && from the Texture2D branch of address_view_fits. The layout check failed with FAIL address view: non-array view of an array, so the test kills it. I reverted the change with git checkout -- ..

Not verified

  • No Win2025 WARP run. This change touches the D3D12 upload and fence lifetime paths, so the gate/gate-ring fixtures in startup_address_console_check.py are what really prove it. They need a real Windows run before Ready.

AI-assisted; commands listed were executed locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants