d3d12_xs: GetResourceAllocationInfo answers streamed textures with their console size (RT-ALLOC-INFO-CONSOLE) #971

Closed
DadaCap wants to merge 4 commits from upstream-pr/971 into main
DadaCap commented 2026-11-24 16:04:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-24T16:04:22Z.


Depends on: #461

Claim: RT-ALLOC-INFO-CONSOLE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136979744). Only the last commit is this pull request; the rest is #461.

The retail title sizes its streamed textures with device slot 25, GetResourceAllocationInfo, with layout 0, and computes offsets and lengths inside its texture archives from the answers. The runtime forwarded the call, so it answered with the PC GPU's sizes and the title asked DirectStorage for a part of a compressed chunk. It asserts on that: the int3 at game_scarlett_master.exe+0x4ffd879 (1.0.2.1) right after the start screen, also seen on an RTX 5070 (https://github.com/ubiquitarianism/leonida/issues/14, DesertGamer).

Two of the textures it asserted on: 128x4 R16G16B16A16_UNORM, answered 2 pages of 4 KiB where the archive's chunk is 4; 128x128 BC1 with 6 mips, answered 4 where the chunk is 3. #461's layout gives 4 and 3 in the 4 KiB mode XGSuggestSwizzleMode picks for both.

Slot 25 now answers from #461's layout when every description is a texture with a swizzle mode (0x100 | mode) or layout 0, and not a render or depth target. Anything else keeps the PC answer for the whole list. It goes through a pointer, so the proxy does not link the xg_xs shim.

Not covered: slot 108 (GetResourceAllocationInfo2, #219), which needs the same two lines once it lands; arrays, 3D and targets are not measured on the title.

Tested

  • xs_proxy_mock_test: exit 0 (new: one and two textures, the alignment between them, and five lists that keep the PC answer). xg_xs_test: 0 failures (new: the sizes above). Windows 11, MSVC.
  • Retail package, in my prototype stack (not on this branch alone; RTX 5080, driver 621.24, Windows 11): with the rule for slots 25 and 108 the assert is gone and in a 240 s run no DirectStorage request failed; without it 24 and more did.
  • No game data.

AI-assisted (Claude Code, Opus 5.5).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475779072 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-24T16:04:22Z. --- Depends on: #461 Claim: RT-ALLOC-INFO-CONSOLE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136979744). Only the last commit is this pull request; the rest is #461. The retail title sizes its streamed textures with device slot 25, `GetResourceAllocationInfo`, with layout 0, and computes offsets and lengths inside its texture archives from the answers. The runtime forwarded the call, so it answered with the PC GPU's sizes and the title asked DirectStorage for a part of a compressed chunk. It asserts on that: the int3 at `game_scarlett_master.exe+0x4ffd879` (1.0.2.1) right after the start screen, also seen on an RTX 5070 (https://github.com/ubiquitarianism/leonida/issues/14, DesertGamer). Two of the textures it asserted on: 128x4 R16G16B16A16_UNORM, answered 2 pages of 4 KiB where the archive's chunk is 4; 128x128 BC1 with 6 mips, answered 4 where the chunk is 3. #461's layout gives 4 and 3 in the 4 KiB mode `XGSuggestSwizzleMode` picks for both. Slot 25 now answers from #461's layout when every description is a texture with a swizzle mode (`0x100 | mode`) or layout 0, and not a render or depth target. Anything else keeps the PC answer for the whole list. It goes through a pointer, so the proxy does not link the xg_xs shim. Not covered: slot 108 (`GetResourceAllocationInfo2`, #219), which needs the same two lines once it lands; arrays, 3D and targets are not measured on the title. ### Tested - `xs_proxy_mock_test`: exit 0 (new: one and two textures, the alignment between them, and five lists that keep the PC answer). `xg_xs_test`: 0 failures (new: the sizes above). Windows 11, MSVC. - Retail package, in my prototype stack (not on this branch alone; RTX 5080, driver 621.24, Windows 11): with the rule for slots 25 and 108 the assert is gone and in a 240 s run no DirectStorage request failed; without it 24 and more did. - No game data. AI-assisted (Claude Code, Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tiguan26 commented 2026-11-24 21:37:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-24T21:37:53Z.


Checked 9f89522 merged into current main (4a50caf): it merges cleanly. Cross-built with clang-cl 19 + xwin (MSVC CRT / SDK 10.0.26100) and run under Wine 11.22 on llvmpipe. No game files, so this checks the shim and the tests, not the retail assert.

  • xs_proxy_mock and xg_xs pass, with the new cases: one and two textures and the alignment between them, the five lists that keep the PC answer, and the two measured sizes.
  • console_texture_sizes() reads right to me. Each texture is placed at its own alignment and the total is rounded to the largest, as D3D12 lays out a multi-description query. One buffer, render or depth target, or layout outside 0/0x100 | mode anywhere in the list keeps the PC answer for the whole list.
  • Wiring: xg_xs.cpp and d3d12_xs_device.cpp are both direct sources of gta6rt, not a static library, so g_texture_size_set can't be dropped and the hook is set in the real process. The mock test sets rt::xg::texture_size_fn itself, though, so nothing checks that the initializer runs. A one-line rt::xg::texture_size_fn != nullptr in xg_xs_test (which links xg_xs.cpp) would cover it.

One question, not a blocker: the console answer brings the console's alignment (4 KiB for the mode XGSuggestSwizzleMode picks here), while the Vulkan device's CreatePlacedResource refuses a texture whose heap offset is not a multiple of its own PC alignment (heap_offset % alloc.Alignment, 64 KiB for most textures that are not small resources). If the title places these streamed textures through the PC-style CreatePlacedResource at offsets computed from the console answer, larger textures would be refused there. If it places them through CreatePlacedResourceX (slot 133, by VA), as the archive offsets suggest, this doesn't come up. Your 240 s run with no failed DirectStorage requests suggests the latter.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145184747 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971#issuecomment-7145184747). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-24T21:37:53Z. --- Checked 9f89522 merged into current `main` (4a50caf): it merges cleanly. Cross-built with clang-cl 19 + xwin (MSVC CRT / SDK 10.0.26100) and run under Wine 11.22 on llvmpipe. No game files, so this checks the shim and the tests, not the retail assert. - `xs_proxy_mock` and `xg_xs` pass, with the new cases: one and two textures and the alignment between them, the five lists that keep the PC answer, and the two measured sizes. - `console_texture_sizes()` reads right to me. Each texture is placed at its own alignment and the total is rounded to the largest, as D3D12 lays out a multi-description query. One buffer, render or depth target, or layout outside `0`/`0x100 | mode` anywhere in the list keeps the PC answer for the whole list. - Wiring: `xg_xs.cpp` and `d3d12_xs_device.cpp` are both direct sources of `gta6rt`, not a static library, so `g_texture_size_set` can't be dropped and the hook is set in the real process. The mock test sets `rt::xg::texture_size_fn` itself, though, so nothing checks that the initializer runs. A one-line `rt::xg::texture_size_fn != nullptr` in `xg_xs_test` (which links `xg_xs.cpp`) would cover it. One question, not a blocker: the console answer brings the console's alignment (4 KiB for the mode `XGSuggestSwizzleMode` picks here), while the Vulkan device's `CreatePlacedResource` refuses a texture whose heap offset is not a multiple of its own PC alignment (`heap_offset % alloc.Alignment`, 64 KiB for most textures that are not small resources). If the title places these streamed textures through the PC-style `CreatePlacedResource` at offsets computed from the console answer, larger textures would be refused there. If it places them through `CreatePlacedResourceX` (slot 133, by VA), as the archive offsets suggest, this doesn't come up. Your 240 s run with no failed DirectStorage requests suggests the latter. AI-assisted (Claude).
DadaCap commented 2026-11-24 21:53:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-24T21:53:41Z.


@tiguan26 thank you for the check, and for cross-building it.

  • The initializer: xg_xs_test already has that line, check(rt::xg::texture_size_fn != nullptr, "the shim offers its sizes"); (runtime/test/xg_xs_test.cpp:279 on this head), before the four size cases that call through the pointer. It links xg_xs.cpp, so it fails if g_texture_size_set does not run.
  • Your question: on the retail title the streamed textures do not come through the PC-style CreatePlacedResource. In my runs they are described by address: slot 133 (CreatePlacedResourceX, by VA) and, far more often, the raw views of device slots 70/71 (a resource description plus a GPU address, no resource object), about 58,000 texture descriptions in a 240 s run that reaches the world phase, with no failed DirectStorage request. So the console alignment never meets the heap_offset % alloc.Alignment check there. Not checked: whether the PC slot is ever called for a texture at all; I only know it is not what the streaming uses.

Measured on Windows 11, RTX 5080 (NVIDIA 621.24), with a local stack on top of main; counts only, no game data. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145529328 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971#issuecomment-7145529328). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-24T21:53:41Z. --- @tiguan26 thank you for the check, and for cross-building it. - The initializer: `xg_xs_test` already has that line, `check(rt::xg::texture_size_fn != nullptr, "the shim offers its sizes");` (`runtime/test/xg_xs_test.cpp:279` on this head), before the four size cases that call through the pointer. It links `xg_xs.cpp`, so it fails if `g_texture_size_set` does not run. - Your question: on the retail title the streamed textures do not come through the PC-style `CreatePlacedResource`. In my runs they are described by address: slot 133 (`CreatePlacedResourceX`, by VA) and, far more often, the raw views of device slots 70/71 (a resource description plus a GPU address, no resource object), about 58,000 texture descriptions in a 240 s run that reaches the world phase, with no failed DirectStorage request. So the console alignment never meets the `heap_offset % alloc.Alignment` check there. Not checked: whether the PC slot is ever called for a texture at all; I only know it is not what the streaming uses. Measured on Windows 11, RTX 5080 (NVIDIA 621.24), with a local stack on top of main; counts only, no game data. AI-assisted (Claude Code).
tiguan26 commented 2026-11-24 22:08:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-24T22:08:49Z.


@DadaCap you're right, line 279 already checks it and I missed it (I only read the mock test's diff). Thanks also for the slot 70/71 and 133 counts: that settles the alignment question for the streaming path.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145863630 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971#issuecomment-7145863630). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-24T22:08:49Z. --- @DadaCap you're right, line 279 already checks it and I missed it (I only read the mock test's diff). Thanks also for the slot 70/71 and 133 counts: that settles the alignment question for the streaming path.
tiguan26 commented 2026-11-24 22:38:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-24T22:38:04Z.

Review: APPROVED


Approving 9f89522 (the RT-ALLOC-INFO-CONSOLE commit; #461 underneath as the PR says). My checks are in the comment above: merged cleanly into main 4a50caf, cross-built with clang-cl 19 + xwin, xs_proxy_mock and xg_xs pass under Wine 11.22, and the multi-description layout reads right. My two points are answered: the initializer is checked at xg_xs_test.cpp:279, and the streamed textures go through slots 70/71/133 by address, not the PC-style CreatePlacedResource, so the console alignment never meets that check.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6048506821 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971#pullrequestreview-6048506821). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-24T22:38:04Z. **Review:** APPROVED --- Approving 9f89522 (the RT-ALLOC-INFO-CONSOLE commit; #461 underneath as the PR says). My checks are in the comment above: merged cleanly into main 4a50caf, cross-built with clang-cl 19 + xwin, `xs_proxy_mock` and `xg_xs` pass under Wine 11.22, and the multi-description layout reads right. My two points are answered: the initializer is checked at `xg_xs_test.cpp:279`, and the streamed textures go through slots 70/71/133 by address, not the PC-style `CreatePlacedResource`, so the console alignment never meets that check. AI-assisted (Claude).
DadaCap commented 2026-11-24 23:04:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-24T23:04:53Z.


Merged current main (698b650ed and later, with #375) into the branch; no force-push.

One conflict, in proxy_get_resource_allocation_info: main now cleans the descriptions in a copy and gives the console sizes of render targets to console-form calls only. The streamed-texture sizes of this PR follow the same rule: console_texture_sizes is asked first, for a call in the console form (the return buffer first), and a PC-form caller keeps the PC device's answer. The retail title calls slot 25 in the console form, so its sizes are unchanged.

xs_proxy_mock_test changed with it: the texture cases call slot 25 in the console form, a PC-form call of the same description is checked to get the mock device's answer, and the "anything else" cases check that the PC device is asked (main's mock answers a size computed from the description now, and adds its console render-target sizes after, so the old marker value is gone).

On the merged head, Windows 11, VS 18 RelWithDebInfo: xs_proxy_mock_test PASS, xg_xs_test 111 checks, 0 failures. Not run: the whole ctest set, GPU tests (this change has none).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7146990132 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971#issuecomment-7146990132). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-24T23:04:53Z. --- Merged current `main` (`698b650ed` and later, with #375) into the branch; no force-push. One conflict, in `proxy_get_resource_allocation_info`: main now cleans the descriptions in a copy and gives the console sizes of render targets to console-form calls only. The streamed-texture sizes of this PR follow the same rule: `console_texture_sizes` is asked first, for a call in the console form (the return buffer first), and a PC-form caller keeps the PC device's answer. The retail title calls slot 25 in the console form, so its sizes are unchanged. `xs_proxy_mock_test` changed with it: the texture cases call slot 25 in the console form, a PC-form call of the same description is checked to get the mock device's answer, and the "anything else" cases check that the PC device is asked (main's mock answers a size computed from the description now, and adds its console render-target sizes after, so the old marker value is gone). On the merged head, Windows 11, VS 18 RelWithDebInfo: `xs_proxy_mock_test` PASS, `xg_xs_test` 111 checks, 0 failures. Not run: the whole `ctest` set, GPU tests (this change has none). AI-assisted (Claude Code).
DadaCap commented 2026-11-25 02:42:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-25T02:42:35Z.


Closing this one as well: main has the rule since #984, on its own texture layout code.

  • runtime/shims/d3d12_xs_alloc_size.h on main has console_texture_layout(): a texture nothing renders or stores to gets XG's size and alignment (xg_xs_layout.h), and slots 25 and 56 use it through console_placement. Its comment gives the same reason this pull request was written for (the title reads exactly that many bytes through DirectStorage and stops at game+0x4ffd879 when the size is the PC's).
  • This branch brings a second layout model (console_texture_layout.h, 610 lines) and a second xg_xs.cpp for the same answer, and conflicts with main's in 4 files. Nothing in it is missing on main.

@tiguan26 thank you for the review; the points you raised went into the branch before this. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7151076586 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/971#issuecomment-7151076586). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-25T02:42:35Z. --- Closing this one as well: `main` has the rule since #984, on its own texture layout code. - `runtime/shims/d3d12_xs_alloc_size.h` on `main` has `console_texture_layout()`: a texture nothing renders or stores to gets XG's size and alignment (`xg_xs_layout.h`), and slots 25 and 56 use it through `console_placement`. Its comment gives the same reason this pull request was written for (the title reads exactly that many bytes through DirectStorage and stops at `game+0x4ffd879` when the size is the PC's). - This branch brings a second layout model (`console_texture_layout.h`, 610 lines) and a second `xg_xs.cpp` for the same answer, and conflicts with `main`'s in 4 files. Nothing in it is missing on `main`. @tiguan26 thank you for the review; the points you raised went into the branch before this. AI-assisted (Claude Code).

Pull request closed

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
ProjectLeonida/mandy!971
No description provided.