xg_xs: implement XGSuggestSwizzleMode export #358

Open
FilimonEnc wants to merge 2 commits from upstream-pr/358 into main
FilimonEnc commented 2026-11-24 05:43:35 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by FilimonEnc on 2026-11-24T05:43:35Z.


Adds export ordinal 24 XGSuggestSwizzleMode to crates/compat/xg_xs:

  • Selects appropriate texture swizzle / tiling mode based on width, height, format, and flags.
  • Updates exports.txt and adds regression unit tests.
  • Verified with pr_gate.py (0 problems).
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6575484431 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/358). Originally posted by [FilimonEnc](https://github.com/FilimonEnc) on 2026-11-24T05:43:35Z. --- Adds export ordinal 24 XGSuggestSwizzleMode to crates/compat/xg_xs: - Selects appropriate texture swizzle / tiling mode based on width, height, format, and flags. - Updates exports.txt and adds regression unit tests. - Verified with pr_gate.py (0 problems).
omonkeyz commented 2026-11-25 13:51:11 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:51:11Z.


Thanks. Please cite the source of this signature (it differs from the one in #292), add a console-oracle or unit test of the result, and update the export count in exports_table.rs, whose test fails with the new line.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7164384657 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/358#issuecomment-7164384657). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:51:11Z. --- Thanks. Please cite the source of this signature (it differs from the one in #292), add a console-oracle or unit test of the result, and update the export count in exports_table.rs, whose test fails with the new line.
FilimonEnc commented 2026-11-25 15:41:18 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by FilimonEnc on 2026-11-25T15:41:18Z.


Thanks for catching that. I re-checked the actual call sites in game_scarlett_master.exe (IAT 0x6793f68, thunk 0x5f3ff50, callers at RVA 0xc4b3ce and 0x4eccca2), and they indeed pass const D3D12_RESOURCE_DESC* in RCX, 0 in RDX, and &desc->Layout in R8, expecting an HRESULT in EAX — confirming the signature in #292.

I've updated the PR with:

The verified (desc: *const u8, flags: usize, out: *mut u32) -> i32 signature reusing D3D12Desc::read + optimal_swizzle rules (writing 0x100 | mode).
exports.txt updated to pending with the call-site provenance.
exports_table.rs export count updated from 23 to 24.
Unit test suggest_swizzle_mode_rules covering Texture2D (default/RTV/DSV/UAV), invalid dimensions (E_INVALIDARG), and non-zero flags (E_NOTIMPL).

(If you'd prefer to merge #292 directly since it already covers this, feel free to close this one in favor of #292.)

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7167227336 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/358#issuecomment-7167227336). Originally posted by [FilimonEnc](https://github.com/FilimonEnc) on 2026-11-25T15:41:18Z. --- Thanks for catching that. I re-checked the actual call sites in game_scarlett_master.exe (IAT 0x6793f68, thunk 0x5f3ff50, callers at RVA 0xc4b3ce and 0x4eccca2), and they indeed pass const D3D12_RESOURCE_DESC* in RCX, 0 in RDX, and &desc->Layout in R8, expecting an HRESULT in EAX — confirming the signature in #292. I've updated the PR with: The verified (desc: *const u8, flags: usize, out: *mut u32) -> i32 signature reusing D3D12Desc::read + optimal_swizzle rules (writing 0x100 | mode). exports.txt updated to pending with the call-site provenance. exports_table.rs export count updated from 23 to 24. Unit test suggest_swizzle_mode_rules covering Texture2D (default/RTV/DSV/UAV), invalid dimensions (E_INVALIDARG), and non-zero flags (E_NOTIMPL). (If you'd prefer to merge #292 directly since it already covers this, feel free to close this one in favor of #292.)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/358:upstream-pr/358'
git switch 'upstream-pr/358'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/358'
git switch 'upstream-pr/358'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/358'
git switch 'upstream-pr/358'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/358'
git switch 'main'
git merge --squash 'upstream-pr/358'
git switch 'main'
git merge --ff-only 'upstream-pr/358'
git switch 'main'
git merge 'upstream-pr/358'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator!358
No description provided.