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

Merged
NiiRoZz merged 9 commits from upstream-pr/2157 into main 2026-11-25 02:43:48 +00:00
NiiRoZz commented 2026-11-25 01:49:51 +00:00 (Migrated from github.com)

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


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:

  • Head acdc50e8: bf652854 merged with main at 442d289e, plus one test-only commit.
  • A later merge of main (94337881) is clean and has not been re-tested.
  • The branch merges cleanly with the head of open PR #2105 (a289585b), which changes the same file.

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 #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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6595280242 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2157). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T01:49:51Z. --- ## 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:** - Head `acdc50e8`: `bf652854` merged with `main` at `442d289e`, plus one test-only commit. - A later merge of `main` (`94337881`) is clean and has not been re-tested. - The branch merges cleanly with the head of open PR #2105 (`a289585b`), which changes the same file. **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. ```powershell 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 #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 - [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). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 03:01:11 +00:00
tedin7 commented 2026-11-25 03:01:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:08:40Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050590449 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2157#pullrequestreview-6050590449). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:08:40Z. **Review:** COMMENTED --- 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.
tedin7 commented 2026-11-25 03:01:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:39:20Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050978099 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2157#pullrequestreview-6050978099). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:39:20Z. **Review:** COMMENTED --- 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.
R0Y00 commented 2026-11-25 03:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:36:17Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150939065 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2157#issuecomment-7150939065). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T02:36:17Z. --- 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.
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!2149
No description provided.