Skip to content

startup: publish single-element 2D and 3D textures by address in device slot 70 - #2157

Merged
R0Y00 merged 9 commits into
R0Y00:mainfrom
NiiRoZz:startup/memory-srv-single-element
Nov 25, 2026
Merged

R0Y00 merged 9 commits into
R0Y00:mainfrom
NiiRoZz:startup/memory-srv-single-element

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Change

Device slot 70 (the memory SRV call) now publishes a 1×1 2D or 1×1×1 3D texture by address, without a resource object. Until now such views were refused with unsupported_description, and the destination descriptor kept stale bytes. The only texel is read from offset 0 of guest memory, so no detiling is needed.

Accepted:

  • shape: one mip, one sample;
  • alignment: default or 64 KiB;
  • format: a plain colour format whose element is one texel of 1 to 16 bytes;
  • view: names the whole texture with the default mapping;
  • layout: UNKNOWN and linear (0x100), plus the GFX10 swizzle modes AMD addrlib defines without pipe/bank XOR (0x101, 0x102, 0x105, 0x106, 0x109, 0x10A).

Still refused:

  • reserved layouts (0x103, 0x104, 0x107, 0x108, 0x10B) and XOR layouts (0x110 and up);
  • larger shapes, mip chains, arrays and multisampling;
  • other alignments;
  • BC, planar, depth and packed console formats;
  • R8_UNORM, which keeps its placed-texture path;
  • render-target, depth or UAV flags.

A view over a live render-target, depth or UAV resource that covers the address (its base, or inside its known allocation size) is refused with a new reason, gpu_written_resource. It is listed in tools/startup/triage_run.py.

The translated draw uploads the texel through the existing footprint path. It rehashes the texel (at most 16 bytes) on every bind, so a write between two draws in the same frame is seen.

Code touched:

  • New src/startup_stubs/single_element_srv.h (acceptance and element size).
  • src/startup_stubs/d3d12_memory_srv.inl: acceptance, size and an early publish block.
  • src/startup_stubs/d3d12_draw.inl, upload_texture only: the single flag in the uploadable check, three !single guards, and the recheck line.

Verification

Code under test:

Environment: Windows 11 build 26300, debug layer off. Hardware is NVIDIA GeForce RTX 5090 (driver 32.0.16.2135); WARP is 10.0.26100.10068. Adapter names come from the consumer's output.

cmake --build --preset release
ctest --preset release --no-tests=error -R '^(startup_tools_lint|startup_triage_run|startup_memory_srv|startup_address_|startup_single_element|startup_image_3d)'

Result at bf652854: 20 passed, 0 failed, 0 skipped.

  • Without a device (10): startup_single_element_srv (50 descriptions), startup_single_element_srv_xor_control (WILL_FAIL), 5 startup_memory_srv*, startup_image_3d_controls, startup_triage_run, startup_tools_lint.
  • WARP (5) and RTX 5090 (5), each: startup_address_single_element, startup_address_srv, startup_address_buffer_srv, startup_address_bc_view, startup_image_3d.

Result at acdc50e8: ctest --preset release --no-tests=error -R '^startup_address_single_element_(warp|hardware)$' gives 2 passed, 0 failed, 0 skipped.

Read-back pixels. startup_address_single_element_{warp,hardware} draws 8 columns per dimension (2D and 3D) and reads back the target. All 32 RGBA pixels per dimension match on both adapters. The columns are:

  • RGBA8 at layouts 0 and 0x105;
  • the first texel rewritten and published again;
  • the texel rewritten without a new publication, in the same frame;
  • B8G8R8A8;
  • R16G16B16A16_FLOAT;
  • the same view again;
  • 64 KiB alignment.

Descriptor unchanged on refusal. The same test makes fifteen refused calls before column 3:

  • 2x1, two mips, two slices, four samples;
  • layout 0x115, layout 0x10B, 4 MiB alignment;
  • BC1, R8, a UAV flag;
  • the other view dimension, a two-mip view, a zero address;
  • a flagless view at the base of a placed UAV texture, and one 256 bytes into a placed UAV buffer.

After each refused call the consumer compares the destination descriptor's 32 bytes and exits with 60 plus the call's position if they changed. Column 3 must then still read the previously published texel. Each refused call names memory holding a different texel, so any call wrongly accepted changes the image.

Negative controls, each rebuilt and run on WARP, each failing:

  • runtime change reverted: column 0 reads 00000000;
  • accepting 2x1: the consumer exits 61 (descriptor changed);
  • accepting two mips or layout 0x115: column 3 reads deadbeef;
  • per-bind rehash dropped: column 3 reads 5aa53cff, the previous texel;
  • GPU-written check on the base only: column 3 reads deadbeef.

Evidence and follow-up

Fixtures. All inputs are source-built: literal texel bytes in tests/startup_address_srv.cpp. The device-free check is tests/startup_single_element_srv_check.cpp. The reproduction command is in docs/experiments.md, section "Single-element 2D and 3D textures published by address".

Assumptions.

  • For layouts UNKNOWN and 0x100, offset 0 is exact.
  • For the six swizzle modes it is inferred from the pinned AMD addrlib source (Mesa 25.1.0, 5c142e46), not run: a single mip sits at offset 0 (Gfx10Lib::ComputeSurfaceInfoMacroTiled), and the coordinate pattern of a non-XOR mode is zero at the origin.

Local run of a console executable (a run of the title's executable, not a fixture; counts only):

  • The 3 refusals of 1x1 views seen on the base no longer occur.
  • All 9 checked first-run screens match the base.
  • From the first interactive screen on, frame means equal the base to within 0.1 per channel.
  • The checked opening video frame is full colour; the lookup texel published is white.
  • No crash, no new assert.

Limits.

  • The GPU-written check runs at publication. A GPU-writable resource created at the address later is not detected. Checking at bind would mean scanning every resource per draw, and would still not give the GPU's data; binding that resource is a separate change.
  • A resource whose allocation size is unknown (non-buffer, size 0) covers only its base address.
  • Published address-only views are never evicted. This predates this change and is shared with the BC address views.
  • Expect a textual conflict with open PR startup: general GFX10 texture tiling and detiling runtime #1469 (general GFX10 tiling runtime) in upload_texture and d3d12_memory_srv.inl. That PR handles 2D tiled textures and does not cover this slice.

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).

🤖 Generated with Claude Code

NiiRoZz and others added 8 commits November 24, 2026 21:21
…ce slot 70

A 1x1 2D or 1x1x1 3D texture with one mip, one sample and a plain colour format keeps its only
texel at offset 0 for layout UNKNOWN, linear and the swizzle modes without pipe/bank XOR, so the
memory SRV call publishes it like the address-only tiled views and the draw uploads that texel
through the footprint path, with the same change detection. XOR layouts, larger shapes, mip chains,
arrays, multisampling, block-compressed formats, R8 (placed path) and GPU-written flags stay refused.

startup_single_element_srv checks the descriptions without a device (an XOR-layout mutation is the
negative control); startup_address_single_element_{warp,hardware} draws eight columns per dimension,
including a texel rewritten and published again and ten refused descriptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…resource lookup

A live render-target, depth or UAV resource at the view's address is written on the desktop side,
so a flagless single-element view there must not read title memory; it keeps the existing lookup,
which needs the same description and otherwise refuses as before. The fixture adds that refused call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…address_srv

Keeps its CMake hunk away from the neighbouring BC address-view timeout line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Accept only the layouts AMD addrlib defines (0, 0x100, 0x101, 0x102, 0x105, 0x106, 0x109, 0x10A) and
default or 64 KiB alignment; refuse a view over a GPU-written resource that covers the address (base, or
inside a known allocation size) with its own reason, gpu_written_resource; rehash the texel on every bind.
The draw fixture points its refusals at memory holding another texel and reads a same-frame rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…U-written refusal, limits

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…riptor unchanged

The consumer compares the destination's 32 bytes after each of the fifteen refused calls and exits
with 60 plus the call's position when one changed them. Accepting 2x1 now fails with 61.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 acdc50e84a8428eaabd2bd06b301a616f4b7e249 (comment only, no approval).

Result: no P1, no P2. Two nits.

What I checked

  • git diff --stat origin/main...HEAD: 12 files, +451/-7. Title and body are neutral. Mergeable, not draft.
  • CI on this head: Linux Python checks pass, gfx1013 fixtures pass, "Build and test on Windows" passes (3m42s). The /O2 job and the chart job were skipped.
  • python3 tests/docs_links_check.py: self-test passed, 18 files, 391 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1407 files, no bidi controls.
  • git diff --check origin/main...HEAD: clean (rc=0).
  • Read single_element_srv.h, the d3d12_memory_srv.inl hunks (gpu_written_at, publish_tiled_texture, the slot 70 branch) and the upload_texture hunks in d3d12_draw.inl.

Logic

  • The accepted layouts (0x100, 0x101, 0x102, 0x105, 0x106, 0x109, 0x10A, plus UNKNOWN) put the only texel at offset 0. Reserved and XOR layouts are refused. This matches the stated addrlib reasoning.
  • The !single guards in upload_texture keep the BC/tiled plan checks and the surface size unchanged for existing paths. single_element_bytes returns 0 for BC, so the old paths are not affected.
  • recheck = single || ... rehashes at most 16 bytes per bind. The cost is fine and the "write between two draws" case is covered by column 3 of the consumer test.
  • The refused calls leave the destination descriptor unchanged, and the consumer checks this.

Not run locally

  • The C++ test, the consumer test and the XOR negative control need the Windows D3D12 headers and WARP. This host has only g++ and no d3d12.h. I relied on the Windows CI job for them. I did not run a Win2025 job or a mutation of the new logic.

Nits (not blocking)

  • d3d12_memory_srv.inl, gpu_written_at: a GPU-written texture whose allocation size is unknown (info.bytes == 0) is only matched at its exact base. An address inside it is not caught. The PR body already says so. A one-line comment next to the bytes fallback would help the next reader.
  • single_element_srv.h, format switch: it duplicates a part of the FETCH_FORMATS and FETCH_DXGI knowledge. A short comment saying why these formats were chosen (same bytes on desktop) would keep the sibling tables easier to keep in step.

AI-assisted; commands listed were executed locally.

@R0Y00

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

I tightened the publication-time check to test the full texel range against live GPU-written backing, even if the texel starts before the resource. In the new control two bytes lie on each side of a UAV buffer base. The descriptor stays unchanged. All six Windows Release tests passed on the candidate, including the existing address SRV and single-element WARP and RTX 4060 Laptop draws and the XOR refusal.

@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 84c66897860d9aef3b2d879e89b773099905577b (comment only, no approval).

Result: no P1, no P2.

What I checked

  • git diff --stat origin/main...HEAD: 12 files, +453/-7. Title and body are neutral, mergeable, not draft.
  • CI on this head: Linux Python checks, gfx1013 fixtures and "Build and test on Windows" all pass (the /O2 and chart jobs are skipped).
  • python3 tests/docs_links_check.py: self-test passed, 18 files, 391 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1407 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • python3 tests/startup_triage_run_check.py: 0 failed.
  • tests/startup_single_element_srv_check.cpp built with mingw and run under wine: 50 cases, 12 accepted, 38 refused, 0 mismatches. The --mutate xor negative control returns 1 as intended.
  • The .py draw test needs the Windows consumer and a D3D12 device, so I did not run it. I did not run a Windows WARP job either.

Mutations (reverted with git checkout -- .)

  • Added 0x115 (XOR layout) to the accepted layouts in single_element_srv.h: killed ("4 KiB S with XOR 0x115", 1 mismatch).
  • Replaced the r.MipLevels != 1 check with false: killed ("zero mips" and one more case, 2 mismatches).

Code read

  • single_element_bytes and supports_single_element_srv: the accepted layout set, flags, formats and whole-texture view checks match the description. The only texel is at offset 0 in every accepted layout.
  • gpu_written_overlap: both overlap branches (address at or below the base, address inside the known size) are right. A resource of unknown size only counts at its base, as the comment says.
  • upload_texture: the single path skips the tiled plan and size checks and reuses the footprint upload. The rehash on every bind is fine for at most 16 bytes.

Nit

  • d3d12_draw.inl single is derived from tiled_address_srv plus single_element_bytes(desc). A comment saying that a 1x1 BC or R8 texture can never take this branch would help the next reader. No change needed for merge.

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