Repository navigation
Conversation
…teTextureComputer) The retail executable makes textures through XGCreateTextureComputer and fills them with the computer's slot 8; two of its four call sites use *out without checking the HRESULT, so the traced E_NOTIMPL stops the boot on a null computer. - src/gfx10_layout.h: where every element of a GFX10 texture sits. Mips padded to whole blocks and stored smallest first, with the AMD mip tail, by the rule docs/textures.md measured byte-exact on the retail pools (tools/tex_headers.py compact_surface_layout); the SW_4KB_S and RbPlus SW_64KB_D bit orders of gfx10_tiling.h. Array slices are slice-major, because the executable addresses slice s of mip m as s * plane+0x10 + mip+0x08 in its lock and view paths. Z, R and XOR modes get a stand-in bit order, said so in the layout. - src/xg_surface.h: the 0x38-byte description (a D3D12_RESOURCE_DESC whose Layout is 0x100 | AMD swizzle mode, as the title's own builder writes it: 0x105 SW_4KB_S, 0x10A SW_64KB_D for sparse textures, 0x102 SW_256B_D), the 0x1B38-byte layout structure its callers read, DXGI element sizes, the suggestion (SW_64KB_D from a 64 KiB slice, SW_4KB_S below) and slot 10's tiling from src/resource_tiling.h. - shims/xg_xs.cpp: ref-counted computers with slots 0 AddRef, 1 Release, 2 GetResourceLayout, 8 CopyIntoSubresource and 10 GetResourceTiling. A description the model cannot lay out still gets a computer, which writes nothing. - test/xg_surface_test.cpp (portable): nine layouts against compact_surface_layout's numbers, the measured bit orders, a copy round trip in every mode with mips, tails, arrays and volumes. test/xg_xs_test.cpp follows the new answers.
|
Tested 1b95067 merged with main 5d74c27 under Wine: pass On: Linux, Ubuntu 24.04, cross-built with clang-cl 19.1.1 + xwin SDK (RelWithDebInfo), run by
AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). Synthetic test only, no game files. |
|
Tested on AMD Radeon RX 7700 XT (RDNA3), AMD Windows driver 32.0.32029.2010, Windows 11, MSVC 14.51 Release, at 1b95067. Full No regression. The only failures are the same 5 as on AI-assisted (Claude Code). |
LaugeM
left a comment
There was a problem hiding this comment.
Read at 1b950670 against main 5d74c2723. Of the three open xg_xs.dll changes (#8529, #8763 and this one), this is the one I'd merge. It reads the Layout word as 0x100 | ADDR_SW_MODE throughout (runtime/src/xg_surface.h:146-153), so it accepts the 0x105 the title builds itself, where #8529 refuses it. It keeps a fallback computer in *out on failure (runtime/shims/xg_xs.cpp:197-208) for the two callers that don't check the HRESULT, and its slot 10 uses the same resource_tiling.h rule as the Vulkan layer. ikurta92's control run is the one to go by: with main's xg_xs.cpp, 15 of the 25 xg_xs_test checks fail. GeremC's control swapped in headers that don't exist on main.
Two things to settle before or right after it lands:
- It disagrees with main's D3D12 layer on what 0x101 is. Main takes 0x101 as the tiled 64 KiB word from device slot 76 and treats it as
64KB_UNDEFINED_SWIZZLE, withSW_64KB_Ddetiling (docs/d3d12_vulkan.md:2267-2270,:2343;runtime/shims/d3d12_vulkan_device.cpp:443-446,runtime/src/resource_detile.h:27). Under this PR's model 0x101 isSW_256B_S,SW_64KB_Dis 0x10A, and the title's own textures are 0x105.is_tiled_layouton main knows only 0x101, so a 0x105 or 0x10A description reaching slot 76 isn't treated as tiled there. One of the two readings is wrong, and the doc and the layer should follow whichever this PR's static read confirms. Worth a line indocs/d3d12_vulkan.mdin this PR, and afinding:for the layer. Plausible (two static reads that disagree). - One creation site may leak a computer per call (
xg_xs.cpp:200). Each call allocates a new ref-countedComputer(with twoSurfaceLayoutplanes). The header counts four creation sites (:8-9) but only three that call slot 1 (:10). If the fourth never releases, that is one computer per texture it creates. Main and #8763 cache one computer per description for that reason. If the fourth site is one of the failure paths, it is fine. Plausible (counts from the header, not traced).
Smaller: std::getenv at xg_xs.cpp:57 adds a C4996 warning in gta6rt and xg_xs_test (ikurta92). A one-line #pragma warning or _dupenv_s keeps the build clean.
If this lands, #8529 and #8763 have nothing left to add, and both conflict with it in runtime/shims/xg_xs.cpp.
AI-assisted review (Opus 5.5). Read the diff against main; not built.
Claimed in the coordination issue as: #9401 (comment)
Depends on: none. Conflicts with #8529 and #8763 (the same exports,
runtime/shims/xg_xs.cpp).What and why
The retail executable makes textures with
XGCreateTextureComputerand fills them through the computer's slot 8. Two of the four call sites use*outwithout checking the HRESULT, somain's tracedE_NOTIMPLleaves those callers holding a computer that answers nothing.This PR answers from a model of the GFX10 layout, so a placement the title sizes through XG matches what XG later copies into it.
What it reads from the executable (statically; RVAs only):
D3D12_RESOURCE_DESC. Its Layout word is0x100 | AMD ADDR_SW_MODE, which is what the title's own builder (RVA0x4ecc940) writes:0x100 |the mode in its texture record;0x10A(SW_64KB_D) for a texture the record marks sparse;0x102(SW_256B_D) for one kind of small 2D texture;XGSuggestSwizzleModewhen the record says0xFF. That function writes into the description's Layout field.+0x18and index 0x70-byte mips from a plane's+0x38. The fields they read:+0x00size,+0x08offset,+0x102D slice size and+0x1Crow pitch;+0x10.0x5121852) and the view path (RVA0x555eaf5) both address slice s of mip m ass * plane+0x10 + mip[m]+0x08. The pools store arrays mip-major (docs/textures_arrays.md), but that's the streaming payload the title copies, not XG's answer.What changes:
runtime/src/gfx10_layout.h(portable): placement for the GFX10 swizzle modes.tools/tex_headers.py compact_surface_layout).gfx10_tiling.h. SW_64KB_S, SW_4KB_D and the 256 B modes are prefixes or extensions of those two.exact == false), and slot 8 logs it once.runtime/src/xg_surface.h(portable):static_asserts on the measured offsets;XGSuggestSwizzleMode's policy: SW_64KB_D when one slice of mip 0 fills a 64 KiB block, SW_4KB_S below that (the two modes the pools use), linear for 1D and 12-byte elements;src/resource_tiling.h, the same numbers the Vulkan layer'sGetResourceTilinggives.runtime/shims/xg_xs.cpp: per-description, ref-counted computers with slots 0 (AddRef), 1 (Release), 2, 8 and 10. As in runtime: xg_xs.dll shim, XGCreateTextureComputer and XGSuggestSwizzleMode as traced E_NOTIMPL (RT-489) #6891, a description the model can't lay out still gets a computer (E_INVALIDARG). That computer writes nothing and answers every slot withE_NOTIMPL.LEONIDA_XG_LOG=1prints every description.A follow-up I have locally but am not claiming: device slots 25 and 108 should size the console's textures from the same model, so a placement fits what slot 8 copies.
Tested
xg_surface_test(new, portable, CTestxg_surface), g++ 16.2,-std=c++20 -Wall -Wextra -Wconversion -Werror. It passes, and checks:compact_surface_layout's own output: size, first tail mip, every standalone offset and padding, every tail origin;TiledSurface2D;Two deliberate breaks make it fail: a 64 KiB tail of 11 mips instead of 12, and the Morton bit of the tail origin.
xg_xs_test, updated for the new answers: suggestion, slot 2 against the model, slot 8 againstelement_offset, slot 10, ref counting, and the fallback computer. Cross-built with clang-cl 22 and xwin (MSVC 14.44 headers), and run on Linux under a native PE loader: 25 checks, 0 failures. Not built with MSVC or run on Windows.Retail 1.0.2.1 on Linux with the Vulkan device (RTX 3070, NVIDIA 615.71) and a local integration stack: the boot goes past its first texture creations, where it stopped on the null computer before. The title creates its textures with Layout
0x105and fills them through slot 8.python -I scripts/check_no_game_data.pyon the six changed files: clean.AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed. (No translator change.)