XGTextureAddressComputer #10 is GetResourceTiling (read from the cons… #192

Closed
github-bot wants to merge 1 commit from gh-pr/192/head into gh-pr/192/base
Owner

@⁠gbuyssens on GitHub · 2026-11-23 20:01 UTC · original
gbuyssens:pr/xg-resource-tiling → main · +107 −1 · 1 files · 1 commits · closed without merging

…ole library's code)

The library's vtable, disassembled: slot 10 takes ID3D12Device::GetResourceTiling's six arguments for the computer's resource – it reads *pNumSubresourceTilings, writes a D3D12_PACKED_MIP_INFO, a D3D12_TILE_SHAPE and D3D12_SUBRESOURCE_TILINGs indexed by D3D12 subresource skipping the packed levels. E_FAIL unless the swizzle mode is a 64 KiB one (8–11, 16–19, 24–27), E_NOTIMPL for 1D and 3D textures; the standard tile in elements goes by their size (256×256 for 1 byte … 64×64 for 16), reported in texels; a level's tiling is its padded size over the tile, its start tile the level's offset in 64 KiB tiles plus the slice's; the packed levels take one tile at the first one's offset. A title's texture streaming asks this for every texture it places in a tiled pool.

The guess taken from ivall/xcl#169 (GetSubresourceLayout / Offset, sniffing which arguments are pointers) answered E_INVALIDARG by luck with the real arguments (the "plane" was the low half of a pointer) and would have written 0x70 bytes over a 12-byte tile shape otherwise. Slot 11 is GetDescriptor(plane, 32-byte hardware descriptor), not modelled: a stub again.

Test: resource_tiling_of_a_64kb_texture.

**@⁠gbuyssens** on GitHub · 2026-11-23 20:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/192) `gbuyssens:pr/xg-resource-tiling` → `main` · +107 −1 · 1 files · 1 commits · closed without merging …ole library's code) The library's vtable, disassembled: slot 10 takes ID3D12Device::GetResourceTiling's six arguments for the computer's resource – it reads *pNumSubresourceTilings, writes a D3D12_PACKED_MIP_INFO, a D3D12_TILE_SHAPE and D3D12_SUBRESOURCE_TILINGs indexed by D3D12 subresource skipping the packed levels. E_FAIL unless the swizzle mode is a 64 KiB one (8–11, 16–19, 24–27), E_NOTIMPL for 1D and 3D textures; the standard tile in elements goes by their size (256×256 for 1 byte … 64×64 for 16), reported in texels; a level's tiling is its padded size over the tile, its start tile the level's offset in 64 KiB tiles plus the slice's; the packed levels take one tile at the first one's offset. A title's texture streaming asks this for every texture it places in a tiled pool. The guess taken from ivall/xcl#169 (GetSubresourceLayout / Offset, sniffing which arguments are pointers) answered E_INVALIDARG by luck with the real arguments (the "plane" was the low half of a pointer) and would have written 0x70 bytes over a 12-byte tile shape otherwise. Slot 11 is GetDescriptor(plane, 32-byte hardware descriptor), not modelled: a stub again. Test: resource_tiling_of_a_64kb_texture.
The library's vtable, disassembled: slot 10 takes ID3D12Device::GetResourceTiling's six
arguments for the computer's resource – it reads *pNumSubresourceTilings, writes a
D3D12_PACKED_MIP_INFO, a D3D12_TILE_SHAPE and D3D12_SUBRESOURCE_TILINGs indexed by D3D12
subresource skipping the packed levels. E_FAIL unless the swizzle mode is a 64 KiB one
(8–11, 16–19, 24–27), E_NOTIMPL for 1D and 3D textures; the standard tile in elements goes
by their size (256×256 for 1 byte … 64×64 for 16), reported in texels; a level's tiling is
its padded size over the tile, its start tile the level's offset in 64 KiB tiles plus the
slice's; the packed levels take one tile at the first one's offset. A title's texture
streaming asks this for every texture it places in a tiled pool.

The guess taken from ivall/xcl#169 (GetSubresourceLayout / Offset, sniffing which arguments
are pointers) answered E_INVALIDARG by luck with the real arguments (the "plane" was the low
half of a pointer) and would have written 0x70 bytes over a 12-byte tile shape otherwise.
Slot 11 is GetDescriptor(plane, 32-byte hardware descriptor), not modelled: a stub again.

Test: resource_tiling_of_a_64kb_texture.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:38 +00:00
github-bot closed this pull request 2026-11-26 04:14:38 +00:00
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-23 20:40 UTC · original

AI-assisted triage (Claude Code) of XGTextureAddressComputer slot 10 across #169, #192 and #195. Windows 11 (10.0.26200), Ryzen 9 9950X, Rust 1.99.0 MSVC, debug profile. CPU-only unit tests (no GPU is involved), synthetic textures only, no game files and no console library.

Tested heads, each one directly on main 956a476, so each PR head is the merge result:

  • #169 4283131
  • #192 50cff5d
  • #195 bf26412
  • main as the control

This builds on the #192-vs-#195 comparison in https://github.com/ivall/xcl/pull/195#issuecomment-7113115680 (3D tile depth, 4 KiB modes, packed entries) and doesn't repeat it. The new parts are #169 against the other two, arrays, and how each one compares with the documented API.

Method. One probe, compiled unchanged into all four trees. It builds a computer and calls vtable slot 10 with GetResourceTiling's six arguments, and slot 11 with #192's GetDescriptor(plane, 32-byte descriptor), the way a title calls them. Every output is pre-filled with 0xCC, and the shape and descriptor buffers have guard bytes after them.

call main #169 #192 #195
A. RGBA8 256×256, full chain, 64KB_S, all outputs E_NOTIMPL, nothing written E_INVALIDARG, nothing written S_OK, 6 tiles, 128×128×1, packed (2,7,1,0), count 2 same values, count 9 (7 packed entries (0,0,0,0xFFFFFFFF))
C. (NULL, NULL, &shape, &count, 0, tilings) E_NOTIMPL S_OK, 0x70 bytes written into the 12-byte shape (100 past it) S_OK, 12 bytes S_OK, 12 bytes
D. (&tiles, NULL, NULL, NULL, 0, NULL) E_NOTIMPL S_OK, tiles not written S_OK, 6 S_OK, 6
E. slot 11, (0, 32-byte buffer) E_NOTIMPL S_OK, 0x70 bytes written (80 past the 32) E_NOTIMPL E_NOTIMPL
vtable length 12 12 16 12

Probe result: main fails 1 check (A). #169 fails 4 (A, C, D, E). #192 and #195 fail none. The PRs' own xg tests pass on their heads: #169 subresource_layout_and_offset, #192 resource_tiling_of_a_64kb_texture, and rgba8_64kb_s_layout on all three.

#169 against the other two. #169 doesn't implement GetResourceTiling. It answers slots 10 and 11 as GetSubresourceLayout / GetSubresourceOffsetBytes, and works out which form was called by checking which arguments look like pointers.

With GetResourceTiling's real arguments, the result depends on which outputs the caller passes:

  • All six given: the "plane" is the low half of a pointer, so it returns E_INVALIDARG, as #192's description says.
  • The first two outputs NULL: plane 0 / subresource 0 is valid, so it writes a 0x70-byte XG_SUBRESOURCE_LAYOUT over a 12-byte D3D12_TILE_SHAPE.
  • Only the tile count asked for: it returns S_OK and writes nothing.
  • Slot 11 called as GetDescriptor(0, buf): it writes 0x70 bytes over the 32-byte descriptor and returns S_OK.

All of the NULL outputs above are [out, optional] in D3D12, so these are legal calls.

TheFrenchPepeAI's runs show #169 clearing the null write at +0x2215c35. This doesn't say which of #169's answers did it. It could be E_INVALIDARG from slot 10 instead of E_NOTIMPL, or S_OK (plus the overflow) from slot 11. Someone with the title should run #192 alone and see whether it also gets past +0x2215c35. If it does, #169's xg.rs part can be dropped. Its DSV-118 and mesh-pipeline parts aren't affected by this triage.

#192 and #195 agree on every 2D 64 KiB case I tried:

  • tile counts, packed info, start tiles, and arrays (slice 1 starts at tile 8 / 7 of 12);
  • first = 9;
  • the standard tile shape for all five element sizes: R8 256×256, R16 256×128, RGBA8 128×128, RG32F 128×64, RGBA32F 64×64;
  • BC1 512×256 and BC3 256×256 in texels.

That matches D3D12's standard 64 KiB 2D tile shapes. They differ only in the three places already reported.

An array with packed levels (new). RGBA8 256×256×2, full chain, room 18:

  • #195 writes 18 contiguous entries and reports count 18.
  • #192 writes at the D3D12 subresource index, at positions 0, 1, 9 and 10, and leaves the packed positions 2–8 untouched. It reports count 4.

So with #192 a caller that reads count entries from the start gets two real entries and two untouched ones. With room 4, #192 returns only slice 0's two entries, because room limits the subresource index range, not the number written. If the console library does this too, fine, but it is worth a line in the doc comment and a test. @⁠gbuyssens, could you confirm from the disassembly whether *pNumSubresourceTilings on return is the number written or the index span?

Against the documentation. The console's XGTextureAddressComputer is not publicly documented. The public reference is PC ID3D12Device::GetResourceTiling, which this slot's six arguments mirror. It says:

  • on return, *pNumSubresourceTilings is "the number that was actually retrieved … (clamped to what's available)";
  • packed-mip entries are written as zeros with StartTileIndexInOverallResource = D3D12_PACKED_TILE;
  • the first four outputs are optional.

#195 follows that on the packed entries and the count. #192 departs from it there, and says this follows the console library's code, read from its disassembly. I can't check that without the library, and #192 is the only one of the three with a stated console source. Neither PC D3D12 nor #192 has a 4 KiB "tile", and #195's 3D shape is wrong whatever the library does (see the earlier comment).

My suggestion:

  • Take #192's slot 10, and have #195 drop its own (theaustinayers already offered).
  • Drop #169's slots 10 and 11 once a retail run confirms #192 covers +0x2215c35.
  • The array/count question above is the one thing to settle in #192.

Not tested:

  • the retail title on any of the three;
  • the console library itself;
  • 1D textures, cubes, and MSAA;
  • #169's and #195's non-XG changes (#195's are covered in the comment linked above).
**@⁠Kalmarv** on GitHub · 2026-11-23 20:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/192#issuecomment-7113394778) AI-assisted triage (Claude Code) of `XGTextureAddressComputer` slot 10 across #169, #192 and #195. Windows 11 (10.0.26200), Ryzen 9 9950X, Rust 1.99.0 MSVC, debug profile. CPU-only unit tests (no GPU is involved), synthetic textures only, no game files and no console library. Tested heads, each one directly on `main` `956a476`, so each PR head is the merge result: - #169 `4283131` - #192 `50cff5d` - #195 `bf26412` - `main` as the control This builds on the #192-vs-#195 comparison in https://github.com/ivall/xcl/pull/195#issuecomment-7113115680 (3D tile depth, 4 KiB modes, packed entries) and doesn't repeat it. The new parts are #169 against the other two, arrays, and how each one compares with the documented API. **Method.** One probe, compiled unchanged into all four trees. It builds a computer and calls vtable slot 10 with `GetResourceTiling`'s six arguments, and slot 11 with #192's `GetDescriptor(plane, 32-byte descriptor)`, the way a title calls them. Every output is pre-filled with 0xCC, and the shape and descriptor buffers have guard bytes after them. | call | `main` | #169 | #192 | #195 | |---|---|---|---|---| | A. RGBA8 256×256, full chain, 64KB_S, all outputs | E_NOTIMPL, nothing written | **E_INVALIDARG, nothing written** | S_OK, 6 tiles, 128×128×1, packed (2,7,1,0), count 2 | same values, count 9 (7 packed entries `(0,0,0,0xFFFFFFFF)`) | | C. `(NULL, NULL, &shape, &count, 0, tilings)` | E_NOTIMPL | **S_OK, 0x70 bytes written into the 12-byte shape (100 past it)** | S_OK, 12 bytes | S_OK, 12 bytes | | D. `(&tiles, NULL, NULL, NULL, 0, NULL)` | E_NOTIMPL | **S_OK, `tiles` not written** | S_OK, 6 | S_OK, 6 | | E. slot 11, `(0, 32-byte buffer)` | E_NOTIMPL | **S_OK, 0x70 bytes written (80 past the 32)** | E_NOTIMPL | E_NOTIMPL | | vtable length | 12 | 12 | 16 | 12 | Probe result: `main` fails 1 check (A). #169 fails 4 (A, C, D, E). #192 and #195 fail none. The PRs' own `xg` tests pass on their heads: #169 `subresource_layout_and_offset`, #192 `resource_tiling_of_a_64kb_texture`, and `rgba8_64kb_s_layout` on all three. **#169 against the other two.** #169 doesn't implement `GetResourceTiling`. It answers slots 10 and 11 as `GetSubresourceLayout` / `GetSubresourceOffsetBytes`, and works out which form was called by checking which arguments look like pointers. With `GetResourceTiling`'s real arguments, the result depends on which outputs the caller passes: - All six given: the "plane" is the low half of a pointer, so it returns E_INVALIDARG, as #192's description says. - The first two outputs NULL: plane 0 / subresource 0 is valid, so it writes a 0x70-byte `XG_SUBRESOURCE_LAYOUT` over a 12-byte `D3D12_TILE_SHAPE`. - Only the tile count asked for: it returns S_OK and writes nothing. - Slot 11 called as `GetDescriptor(0, buf)`: it writes 0x70 bytes over the 32-byte descriptor and returns S_OK. All of the NULL outputs above are `[out, optional]` in D3D12, so these are legal calls. TheFrenchPepeAI's runs show #169 clearing the null write at `+0x2215c35`. This doesn't say which of #169's answers did it. It could be E_INVALIDARG from slot 10 instead of E_NOTIMPL, or S_OK (plus the overflow) from slot 11. Someone with the title should run #192 alone and see whether it also gets past `+0x2215c35`. If it does, #169's `xg.rs` part can be dropped. Its DSV-118 and mesh-pipeline parts aren't affected by this triage. **#192 and #195 agree** on every 2D 64 KiB case I tried: - tile counts, packed info, start tiles, and arrays (slice 1 starts at tile 8 / 7 of 12); - `first = 9`; - the standard tile shape for all five element sizes: R8 256×256, R16 256×128, RGBA8 128×128, RG32F 128×64, RGBA32F 64×64; - BC1 512×256 and BC3 256×256 in texels. That matches D3D12's standard 64 KiB 2D tile shapes. They differ only in the three places already reported. **An array with packed levels (new).** RGBA8 256×256×2, full chain, room 18: - #195 writes 18 contiguous entries and reports `count` 18. - #192 writes at the D3D12 subresource index, at positions 0, 1, 9 and 10, and leaves the packed positions 2–8 untouched. It reports `count` 4. So with #192 a caller that reads `count` entries from the start gets two real entries and two untouched ones. With room 4, #192 returns only slice 0's two entries, because room limits the subresource index range, not the number written. If the console library does this too, fine, but it is worth a line in the doc comment and a test. @⁠gbuyssens, could you confirm from the disassembly whether `*pNumSubresourceTilings` on return is the number written or the index span? **Against the documentation.** The console's `XGTextureAddressComputer` is not publicly documented. The public reference is PC `ID3D12Device::GetResourceTiling`, which this slot's six arguments mirror. It says: - on return, `*pNumSubresourceTilings` is "the number that was actually retrieved … (clamped to what's available)"; - packed-mip entries are written as zeros with `StartTileIndexInOverallResource = D3D12_PACKED_TILE`; - the first four outputs are optional. #195 follows that on the packed entries and the count. #192 departs from it there, and says this follows the console library's code, read from its disassembly. I can't check that without the library, and #192 is the only one of the three with a stated console source. Neither PC D3D12 nor #192 has a 4 KiB "tile", and #195's 3D shape is wrong whatever the library does (see the earlier comment). My suggestion: - Take #192's slot 10, and have #195 drop its own (theaustinayers already offered). - Drop #169's slots 10 and 11 once a retail run confirms #192 covers `+0x2215c35`. - The array/count question above is the one thing to settle in #192. Not tested: - the retail title on any of the three; - the console library itself; - 1D textures, cubes, and MSAA; - #169's and #195's non-XG changes (#195's are covered in the comment linked above).
Author
Owner

@⁠ivall on GitHub · 2026-11-23 20:57 UTC · original

Closing: main has XG computer #10 as GetResourceTiling, checked against the console library itself (tests/xg_oracle.rs, resource_tiling_matches_the_console_library, 8 960 cases, none differ: 64 KB tiles, the mip tail as tile 0, count out = standard-mip subresources written at sub - first, non-64KB modes E_FAIL). Thanks!

**@⁠ivall** on GitHub · 2026-11-23 20:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/192#issuecomment-7113792358) Closing: main has XG computer #10 as GetResourceTiling, checked against the console library itself (`tests/xg_oracle.rs`, `resource_tiling_matches_the_console_library`, 8 960 cases, none differ: 64 KB tiles, the mip tail as tile 0, `count` out = standard-mip subresources written at `sub - first`, non-64KB modes E_FAIL). Thanks!

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.