Skip to content

Retail game: XGTextureAddressComputer subresource layout, DSV format … - #169

Closed
sandhani01 wants to merge 1 commit into
ivall:mainfrom
sandhani01:fix/gta6-startup-fixes
Closed

sandhani01 wants to merge 1 commit into
ivall:mainfrom
sandhani01:fix/gta6-startup-fixes

Conversation

@sandhani01

Copy link
Copy Markdown

…118 remap

  • hle/xg.rs: implement XGTextureAddressComputer::Olympus: harden GameSave read results #10 and Olympus: honor disabled process task queues #11 (GetSubresourceLayout and GetSubresourceOffsetBytes) to resolve the null-write crash at +0x2215c35.

  • hle/d3d12x/real.rs: remap console DSV format 118 (D16_UNORM_S8_UINT) to format 45 (D24_UNORM_S8_UINT) with format 20 fallback, fixing 620 rejected PSOs.

  • hle/d3d12x/real.rs: disambiguate mesh pipeline stream AS/MS subobject fallback.

  • HANDOFF.md: document first-run analysis and fixes.

  • .github/workflows/ci.yml: add GitHub Actions CI workflow for Windows.

…118 remap

- hle/xg.rs: implement XGTextureAddressComputer::ivall#10 and ivall#11 (GetSubresourceLayout and GetSubresourceOffsetBytes) to resolve the null-write crash at +0x2215c35.

- hle/d3d12x/real.rs: remap console DSV format 118 (D16_UNORM_S8_UINT) to format 45 (D24_UNORM_S8_UINT) with format 20 fallback, fixing 620 rejected PSOs.

- hle/d3d12x/real.rs: disambiguate mesh pipeline stream AS/MS subobject fallback.

- HANDOFF.md: document first-run analysis and fixes.

- .github/workflows/ci.yml: add GitHub Actions CI workflow for Windows.
@sandhani01 sandhani01 closed this Nov 23, 2026
@sandhani01 sandhani01 reopened this Nov 23, 2026
gbuyssens pushed a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…offset (from ivall#169)

The retail game called ivall#10 (a stub returning E_NOTIMPL) and then wrote to address 0 at
+0x2215c35. ivall#10 / ivall#11 are GetSubresourceLayout / GetSubresourceOffsetBytes: the
XG_SUBRESOURCE_LAYOUT of a subresource, or its byte offset.

Only xg.rs of ivall#169 is taken: its DSV format 118 remap is covered more completely by
ivall#163 (merged with ivall#170: resource descs, pipelines, depth buffers that are UAVs).
gbuyssens pushed a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…offset (from ivall#169)

A title called ivall#10 (a stub returning E_NOTIMPL) and then wrote to address 0.
ivall#10 / ivall#11 are GetSubresourceLayout / GetSubresourceOffsetBytes: the
XG_SUBRESOURCE_LAYOUT of a subresource, or its byte offset.

Only xg.rs of ivall#169 is taken: its DSV format 118 remap is covered more completely by
ivall#163 (merged with ivall#170: resource descs, pipelines, depth buffers that are UAVs).
@TheFrenchPepeAI

Copy link
Copy Markdown

Tested on a third machine: #169 does clear the null-write.

RTX 4090, Windows 10 22H2 (19045), driver 32.0.16.2114, main@956a476 + #169, device_type = anaconda, title_memory = auto. The run presents its first frame, then dies at a different, later stop:

unhandled exception 0x80000003 in game_scarlett_master.exe+0x344196
stack: +0x71c1560, +0x71c27c0, +0x6a0a6, +0x51fbdb5, +0x4fac3d7, +0x4b95b

It happens while pixel-shader pipelines are being set up (the log's last lines are [SHADER] ps …), with an xcl-dstorage thread parked. Without #169 the same build dies earlier at +0x2215c35 (write at 0), so #169 moves the frontier on NVIDIA too.

device_type = "lockhart" with title_memory = "8192" dies before any present, at the old +0x2215c35; anaconda + auto is the working pair here.

Also: xcl shaders <shaders.rpf> --precompile --pipelines works as documented (26 503 programs, ~10/s on 31 threads).

@TheFrenchPepeAI

Copy link
Copy Markdown

Isolation follow-up on the same machine (RTX 4090, Windows 10 22H2):

Both runs present one frame first. Every build here is anaconda + title_memory = auto; lockhart + "8192" dies before any present at the old +0x2215c35.

gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
… 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.
@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

A note on this PR's xg.rs part, from a CPU-only probe at 4283131 (synthetic textures, no console library). The full comparison with #192 and #195 is at #192 (comment).

Slots 10 and 11 are answered as GetSubresourceLayout / GetSubresourceOffsetBytes, and the code picks a form by checking which arguments look like pointers. Called with GetResourceTiling's real arguments, legal calls go wrong, because the first four outputs are [out, optional]:

  • All six arguments given: returns E_INVALIDARG, because the "plane" is the low half of a pointer.
  • (NULL, NULL, &shape, &count, 0, tilings): returns S_OK, but writes a 0x70-byte XG_SUBRESOURCE_LAYOUT into the 12-byte D3D12_TILE_SHAPE, 100 bytes past it.
  • Only the tile count requested: returns S_OK and writes nothing.
  • Slot 11 called as XGTextureAddressComputer #10 is GetResourceTiling (read from the cons… #192's GetDescriptor(0, 32-byte buffer): writes 0x70 bytes, 80 past the buffer, and returns S_OK.

TheFrenchPepeAI's runs show that this PR gets past the null write at +0x2215c35. The probe can't tell which answer did that. If #192 on its own also gets past it, this PR's slots 10 and 11 could be dropped in favour of #192. The DSV-118 and mesh parts aren't affected. Could someone with the title try #192 alone?

AI-assisted (Claude Code).

@RemingtonWilcox

Copy link
Copy Markdown
Contributor

Read: hle/xg.rs, d3d12x/real.rs, .github/workflows/ci.yml, HANDOFF.md in this PR, and real.rs on main.

  • xg.rs:706-716: get_subresource_info serves both slots and tells the forms apart by whether a3 / a2 look like pointers. In the offset forms those registers (r9, r8) are not arguments, so a leftover pointer there makes it write a layout into that memory and return S_OK instead of the offset. The two slots need their own functions and signatures.
  • xg.rs:722-725: 0x20 bytes are checked, then MIP_BYTES (0x70) are written.
  • The description lists a mesh stream AS/MS change and queue slot 35; neither is in the diff (slot 35 is on main, real.rs:4147).
  • ci.yml is also added by CI: build and tests on a Windows runner (no GPU) #143, and the DSV 118 → 45 mapping in pc_topology_type by D3D12.X: Xbox D16S8 depth formats and depth buffers that are also UAVs #163.

AI-assisted review (Gemini + Claude); code read only, not run.

@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Closing: this is covered on main now. XG computer #10 is GetResourceTiling, checked against the console library (resource_tiling_matches_the_console_library, 8 960 cases, none differ). The D16S8 family (118-120) has the console's layouts and PC formats, and mesh streams with the MS in the AS slot are handled (38b05b7). The argument mismatch your probe found is what led there. Thanks!

@ivall ivall closed this Nov 23, 2026
@TheFrenchPepeAI

Copy link
Copy Markdown

One more isolation result, same machine: main moved under #169. After af20b4b, xg.rs already carries get_resource_tiling in the vtable and the merge conflicts in that slot list.

With that conflict resolved either way — subresource slots after tiling (#10 tiling, #11/#12 subresource) or before it (#10/#11 subresource, #12 tiling) — the run is back to 0xc0000005 write at 0x0 at +0x2215c35 and never presents. On 956a476 (no get_resource_tiling in that table) the same #169 build presents a frame and stops later at +0x344196.

So on this machine the #169 fix does not survive the new vtable entry; whoever owns the slot numbering should reconcile it. Back on 956a476 + #169 here, which is the only build that presents.

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.

5 participants