Skip to content

d3d12_xs: CreateSamplerX writes through, and mapped heaps take bound tables (RT-XS-DESCRIPTOR-MIRROR-GAPS) - #2498

Open
Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:rt-xs-descriptor-mirror-gaps
Open

Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:rt-xs-descriptor-mirror-gaps

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-XS-DESCRIPTOR-MIRROR-GAPS (#1608 (comment))

What and why

Item 2 of @kevincommits' finding in #1608 (#1608 (comment)). Thanks for the audit.

Both gaps are in runtime/shims/d3d12_xs_device.cpp, where title-backed descriptor heaps are kept in step with the real heap:

  • Slot 61 write-through. Xbox device slot 61 (proxy_create_sampler_x, CreateSamplerX) created the sampler in the real heap only. Every other descriptor creator and copier calls local_write_through to store the result at the title's address as well: slots 17-22, 23/24, and the placed view. A title that copies slot-61 samplers out of its own heap memory into a shader-visible heap therefore copied zeros or stale bytes. Slot 61 now writes through, as slot 22 does.
  • Mapped ranges on Wine. local_mirror_table runs when a descriptor table is bound (list slots 35/36) and checks the real range with VirtualQuery, even for a mapped range (DescriptorRange::mapped). Wine can report a live vkMapMemory span as MEM_FREE, so on Wine with mapped descriptor heaps the table was never mirrored. The check is now skipped for a mapped range, as local_write_through and pull_title_descriptors already do.

No overlap with #2484 or the other open PRs on d3d12_xs_device.cpp: git merge-tree finds no conflict with #2484.

Tested

Windows 11, MSVC (VS 18), RelWithDebInfo, on main 43a9d56. CPU only.

  • xs_proxy_mock_test gains check_descriptor_mirror. The mock's real heap reports a CPU start in test memory (g_mock_heap_cpu_start; other checks keep the old fake address), and the XMem hook hands out a title buffer.

    1. Slot 61 from a title caller, on a sampler heap: the real call gets the real slot, and the title's slot holds the bytes the "driver" wrote there, that slot only. With main's slot 61 this fails.
    2. A mapped shader-visible heap: a slot the title wrote in its own memory is copied into the real heap when a table covering it is bound through list slot 36.

    On Windows VirtualQuery reports that memory truthfully, so case 2 checks that the mapped path mirrors; it cannot reproduce the Wine report itself, and it passes on main too.

  • ctest -R "^(xs_proxy_mock.*|device_proxy)$": 10/10 pass.

  • scripts/check_no_game_data.py: clean.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…tables

Two gaps in mirroring title-backed descriptor heaps on the Xbox console path:

- Xbox device slot 61 (CreateSamplerX) created the sampler in the real heap only. Every other
  descriptor creator and copier also stores the result at the title's address (local_write_through),
  so a title that copies samplers out of its own heap memory read zeros. Slot 61 now writes through
  as slot 22 does.
- local_mirror_table, run when a descriptor table is bound (list slots 35/36), checked the real range
  with VirtualQuery even when it is a mapped range. Wine can report a live vkMapMemory span as
  MEM_FREE, so on Wine the table was never mirrored. It now skips the check for a mapped range, as
  local_write_through does.

From kevincommits' finding in ProjectLeonida#1608 (item 2). xs_proxy_mock_test gains check_descriptor_mirror, with
the mock's real heap pointed at memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant