xg_xs: add XGSuggestSwizzleMode #292
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!292
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/292/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@gringoestrangeiro on GitHub · 2026-11-23 16:05 UTC · original
gringoestrangeiro:xg-suggest-swizzle-mode→main· +96 −1 · 3 files · 1 commits · closed without mergingWhat
GTA VI 1.0.2.1 (Scarlett) imports
XGSuggestSwizzleModefromxg_xs.dllby name. The compat DLL exports 23 functions today; this one is missing, so the title's loader cannot bind the import.Contract from the title's call sites
Two call sites agree:
RCX= pointer to aD3D12_RESOURCE_DESCRDX= 0R8= pointer todesc->Layout(desc + 0x2C)The title builds the descriptor, calls the API, then hands it to
XGCreateTextureComputer. Its own fallback for a known mode writes0x100 | modeintodesc->Layout;D3D12Desc::to_tex2dalready decodes0x100..=0x11Faslayout & 0x1F. The API therefore has to write0x100 | XG_SWIZZLE_MODEinto*out.Implementation
XGSuggestSwizzleModereads the descriptor, derives the bind/misc bits with the same mapping asD3D12Desc::to_tex2d, and reusesoptimal_swizzle(the already-verifiedXGComputeOptimalSwizzleModerules). It writes0x100 | modeand returnsS_OK.flags != 0returnsE_NOTIMPLbecause the title only passes 0 and no console behavior is known.Tests cover 2D SRV/RT/depth/UAV, 3D, 1D, an invalid dimension and non-zero flags.
cargo check --target x86_64-pc-windows-msvc -p xg_xs --libpasses; the crate's test target still needs the localoracle.rsfixture, same as before this change.Verification limit
No console
xg_xs.dllexporting this function was present in the analysed dumps (only the console OS image, not an extractedEmbeddedXvd), so the row is markedpending. If you can point me at a newer EmbeddedXvd with this export, I can turn it into a real oracle comparison.@gringoestrangeiro on GitHub · 2026-11-23 16:05 UTC · original
Import coverage of the GTA VI 1.0.2.1 Scarlett exe against the compat crates (console-only DLLs only):
The only missing name is
XGSuggestSwizzleMode, which this PR adds. The remaining imports are title-shipped (Bink2Scarlett, XboxBvhBuilder, libHttpClient.GDK, XCurl), PC-provided (MFPlat/MFReadWrite, GameInput, WinHTTP, WS2_32), or API sets.Also worth noting for the title entry: the dump has no extracted
EmbeddedXvd(only the console OS image), so there is no per-title console-OS export table for GTA VI; theXGSuggestSwizzleModerow is thereforependingrather than oracle-verified.@GDAgent on GitHub · 2026-11-23 17:08 UTC · original
Independent confirmation: we had reached the same contract from the call sites of the same title (desc in RCX, flags 0,
&desc->Layoutin R8,0x100 | modewritten, HRESULT returned) and an implementation with the same mode rules, so we are dropping ours in favour of this PR.Two small suggestions from our version, take them or leave them:
D3D12Desc::to_tex2d. We split it into abind_and_misc()helper and animplicit_mode()helper onD3D12Descand used them from both places, so the layout-UNKNOWN path ofto_tex2dandXGSuggestSwizzleModecannot drift apart. A test that checksXGSuggestSwizzleModeagainstto_tex2dwithLayout = 0for the same desc pins that.src/oracle.rs: we hit the same thing (the crate's test target does not build on a clean checkout). We could only run the xg_xs tests by cutting the oracle modules out locally; it may be worth a separate issue so the fixture-dependent tests are gated instead.@BuHHuTlyx on GitHub · 2026-11-23 21:27 UTC · original
I tried the shared-helper approach suggested above. The attached patch applies to
b90b64fc70cfdc70762ea658e105f8d53aac7b5f. It shares the descriptor flag and implicit layout logic and adds a regression test that passes&desc->Layoutas the output pointer and checks the resulting mode againstto_tex2dwithLayout = 0.With #310 applied,
cargo test --locked -p xg_xspassed all 21 tests on native Windows MSVC.dumpbin /exportsalso confirmed the PR DLL exportsXGSuggestSwizzleModeby name.One loader detail to verify: the
pendingrow is absent from the generatedcompat_routes.rs. If the title import uses the host route table, it needs a route entry. The exported name is available when loading the built DLL directly.xg-swizzle-shared-layout.patch.txt
@omonkeyz on GitHub · 2026-11-25 13:51 UTC · original
Thanks. The exports.txt line describes a specific title's call site, and the project cannot take title-specific facts. Please resubmit with the note removed and the (desc, flags, out) signature backed by a public source (GDK header or docs) or a console xg_xs.dll oracle test.
Pull request closed