Skip to content

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

Closed
gbuyssens wants to merge 1 commit into
ivall:mainfrom
gbuyssens:pr/xg-resource-tiling
Closed

gbuyssens wants to merge 1 commit into
ivall:mainfrom
gbuyssens:pr/xg-resource-tiling

Conversation

@gbuyssens

Copy link
Copy Markdown
Contributor

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

… console 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#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.
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 23, 2026
…applied

ivall#192: XGTextureAddressComputer ivall#10 as GetResourceTiling, read from the console library's code - replaces the local version, which was not checked against it. ivall#191: recompiler wave32 src_vccz / src_execz and SDWA f16 inline constants. Their authors' work, applied as it is. 200 s run through the title's menus: no change in the picture, no regression.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 23, 2026
ivall#192 reads the method from the console library; the version here was derived from the layout model and differs from it for 4 KiB modes, 3D textures and packed levels (review on ivall#195).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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:

This builds on the #192-vs-#195 comparison in #195 (comment) (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 XGTextureAddressComputer #10 is GetResourceTiling (read from the cons… #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:

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:

Not tested:

@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Owner

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 ivall closed this Nov 23, 2026
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