Skip to content

d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS) - #1079

Closed
Moriz82 wants to merge 1 commit into
ProjectLeonida:mainfrom
Moriz82:split/rt-title-texture-views
Closed

Moriz82 wants to merge 1 commit into
ProjectLeonida:mainfrom
Moriz82:split/rt-title-texture-views

Conversation

@Moriz82

@Moriz82 Moriz82 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Rebased diff at 0a92b139. Main already has the placed-texture SRV and UAV paths. This PR keeps regression coverage for choosing the right live array placement when two textures share an address, rejecting a view after that placement is released, and accepting a complete 3D mip while rejecting a partial view. CTest also runs the same fixture with LEONIDA_PLACED_TEXTURE_UAV=0. The test results below apply to earlier heads.

Claimed in the coordination issue as: RT-TITLE-TEXTURE-VIEWS (claim).

Part of the split of #984 into small pull requests.

Depends on: none

Overlaps: #356 supplied the null SRV fallback for Xbox device slot 70. This child retains that fallback for missing images. #461 concerns CPU texture layout. The live-image path uses the Vulkan image already created by slot 133.

What and why

A shader-resource view of an existing GPU texture returned a null descriptor when the caller supplied the texture's placement address. The equivalent unordered-access call could reach an unrelated PC device method.

Slots 70 and 71 now resolve a live slot-133 texture by address, shape and format. When several images share an address, the most recent compatible image wins. The lookup holds a reference while writing the descriptor. Final release removes only that resource from the index. A UAV requires writable backing. A 3D UAV must span a complete mip. Unmatched views produce null descriptors. Set LEONIDA_PLACED_TEXTURE_UAV=0 to return null placed UAVs for comparison.

CPU-source uploads and refresh belong to the separate RT-TITLE-TEXTURE-SOURCES topic.

Tested

Linux/Proton Experimental (Wine 11), GeForce RTX 4070 12 GB, NVIDIA 620.73.04. Release cross-build with clang-cl 23 and an xwin SDK. Each command below used the same configured build directory. PROTON_WINE names the Wine executable and WINEPREFIX selects the test prefix.

cmake --build runtime/build/boot --target gta6rt -j6
cmake --build runtime/build/boot --target d3d12_set0_compute_test -j6
cmake --build runtime/build/boot --target xs_proxy_mock_test -j6
cd runtime/build/boot
export WINEDEBUG=-all
unset LEONIDA_PLACED_TEXTURE_UAV
timeout 120 "$PROTON_WINE" d3d12_set0_compute_test.exe
LEONIDA_PLACED_TEXTURE_UAV=0 timeout 120 "$PROTON_WINE" d3d12_set0_compute_test.exe
for arg in "" --fail-virtualalloc --fail-virtualprotect --fail-veh --env-slots --env-slots-invalid; do
    timeout 120 "$PROTON_WINE" xs_proxy_mock_test.exe $arg
done

All three targets built. The default and rollback runs each sampled all 64 expected texels through the placed SRV. Each also checked an ordinary SRV, a clamping sampler and a missing-descriptor fallback, for 256 texel checks per run. The default produced two valid UAVs (an array layer and a complete volume mip) and two null controls (released placement and partial mip). The rollback produced four null UAVs. The plain-device proxy test passed at both emulated device interface levels and checked both slots with and without destinations. The six ways CTest runs it (plain, three refused allocations, and the two environment-slot cases) all exit zero.

Fixed after the first version. xs_proxy_mock --env-slots-invalid failed on the first head. It used device slot 71 as its example of a PC slot that is forwarded unchanged, and this change routes slot 71 to the placed texture UAV. The first version ran only the plain form of the test, so it missed that. The case now probes slot 72 and asserts that it is not overridden. Reported by Plaaasma on native Windows and reproduced by madhyn on Wine; reproduced here before the fix (exit 1 at that line) and passing after it.

Rebased onto main 9f25f1ef2. #375 (XMem hooks and console render-target sizes) changed the same two places as this change. In device_slot_overridden (runtime/shims/d3d12_xs_device.cpp) it adds slots 17 to 24 and 56 and this change adds slot 71; in the list of checks of runtime/test/xs_proxy_mock_test.cpp it adds five checks and this change renames check_slot70 to check_placed_views. Both sides are kept, and nothing else conflicted. Slot 72, which the invalid environment-slot case probes, is still not routed. On the rebased head the three targets were rebuilt and all eight registered forms were run again: d3d12_set0_compute, d3d12_placed_texture_uav_off (LEONIDA_PLACED_TEXTURE_UAV=0) and the six xs_proxy_mock forms. These runs used Wine 11.22 (distribution package, a prefix of its own) instead of Proton Experimental, on the same GPU and driver. All exit 0 with the results described above (2 matching UAVs and 2 null controls by default, 4 null controls in the rollback, 64 texels per sampled view), and the plain xs_proxy_mock run includes the five checks #375 added.

GPUs tested: NVIDIA GeForce RTX 4070. Native Windows, AMD, Intel and a game boot were not tested on this child by us; the reviewers' native Windows and Wine runs were on the first head. The cross-build omitted the optional XMA decoder because the Rust Windows target was unavailable.

AI-assisted: yes.

Checklist

  • One commit based on upstream main 3aa975421. Merges cleanly.
  • Live placement views only, with synthetic GPU and proxy coverage.
  • All eight changed files passed scripts/check_no_game_data.py.
  • Runtime change only. No translator rule changed.

🤖 Generated with Claude Code

@Plaaasma

Copy link
Copy Markdown
Contributor

Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022 (VS 17 generator, Release), Vulkan.

Head 0ffeeed0e. Built xs_proxy_mock_test d3d12_set0_compute_test, then ctest -C Release -R "^(xs_proxy_mock.*|d3d12_set0_compute|d3d12_placed_texture_uav_off)$" --output-on-failure --timeout 300:

  • xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots: passed (0.02 s each)
  • d3d12_set0_compute: passed, 0.72 s
  • d3d12_placed_texture_uav_off: passed, 0.66 s
  • xs_proxy_mock_env_slots_invalid: FAILED, at
    xs_proxy_mock line 1073: hr_of(raw(device, 71)) == S_OK && mock->calls[71] == 1

7 passed, 1 failed. The same test passes on current main (71f99e224), so it looks like the --env-slots-invalid branch still expects slot 71 to be forwarded as "not an Xbox slot", while this PR now overrides 71.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified. Robust resolution of live slot-133 placed textures by address, format, and dimensions for Xbox device slots 70 (SRV) and 71 (UAV). Cleanly manages lifetime via TexturePlacements multimap under placement_mutex, returning null descriptors for unmatched placements or released resources. Includes LEONIDA_PLACED_TEXTURE_UAV=0 rollback and comprehensive tests in d3d12_set0_compute_test and xs_proxy_mock_test. 100% clean-room.

@madhyn

madhyn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Independently reproduced on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (0ffeeed0e, clang-cl + xwin cross-build):

ctest --test-dir runtime/build/win -R "^(xs_proxy_mock.*|d3d12_set0_compute|d3d12_placed_texture_uav_off)$" --output-on-failure:

  • xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots: Passed
  • d3d12_set0_compute: Passed (5.49 s)
  • d3d12_placed_texture_uav_off: Passed (5.45 s)
  • xs_proxy_mock_env_slots_invalid: Failed (5.32 s) — same failure as reported above:
    [rt] d3d12_xs: device slot 71 routed to placed texture UAV
    xs_proxy_mock line 1073: hr_of(raw(device, 71)) == S_OK && mock->calls[71] == 1

7 passed, 1 failed (88%).

AI-assisted: yes

@Moriz82

Moriz82 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@Plaaasma @madhyn thank you, you were both right, and the diagnosis in the first report was exact. xs_proxy_mock --env-slots-invalid used device slot 71 as its example of a PC slot that is forwarded unchanged, and this pull request routes slot 71 to the placed texture UAV. I had run only the plain form of the test, not the six ways CTest runs it, so I missed it.

The branch is updated. The case now probes slot 72 and asserts that slot 72 is not overridden, which is what the integration branch (#984) already does.

Run here on the new head (CachyOS, Proton Experimental, clang-cl + xwin, RTX 4070, NVIDIA 620.73.04): before the fix --env-slots-invalid exits 1 at that line; after it, all six forms of xs_proxy_mock_test exit 0 (plain, --fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid), and d3d12_set0_compute_test exits 0 with and without LEONIDA_PLACED_TEXTURE_UAV=0 (2 matching UAVs and 2 null controls by default, 4 null controls with the switch). Native Windows is not run here; if either of you reruns the same ctest -R line on this head, that closes it.

🤖 Generated with Claude Code

@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo.

Head 99176da10 (the one with the xs_proxy_mock fix):

  • xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots, _env_slots_invalid and d3d12_set0_compute: 7 of 7 pass. The slot-71 failure of the previous head is gone here.

iFeyz added a commit to iFeyz/leonida that referenced this pull request Nov 24, 2026
…m a buffer description and its address

DadaCap measured that slots 70 (SRV) and 71 (UAV) also make buffer views, and that the null descriptor
they got left the instance-culling dispatches reading leftover memory as a V# until the device was
lost (issue ProjectLeonida#14 comment 7140195321). A buffer description now reaches ProjectLeonida#1079's placed-view handler,
which writes the V# of a view of Width bytes at the address (taken as a GPU address, as a CBV's
BufferLocation is). The V# comes from the code CreateShaderResourceView / CreateUnorderedAccessView
use for a buffer resource, factored out as write_buffer_srv_at / write_buffer_uav_at, so the view
kinds and bounds are the PC methods'. A refused view or a UAV counter offset keeps the null view.
d3d12_set0_compute_test compares six views with the PC methods' and checks three null controls.
@azsekazvamdimitar

Copy link
Copy Markdown
Contributor

Ran this on Linux under Wine and Proton, as part of VERIFY-WINE-PROTON-GPU in #14. Your branch at 99176da, merged into main at 58be9cd (the merge is clean).

tests main main + this PR main + only this PR's tests
d3d12_set0_compute pass pass fail: line 104: got == (enabled ? expected : Words{}), line 249: check_placed_uavs(device.p) == 0
d3d12_placed_texture_uav_off (not registered) pass fail: line 108: got == Words{}, line 249
xs_proxy_mock pass pass fail: line 1174: device_slot_overridden(70) && device_slot_overridden(71)
xs_proxy_mock_no_reserve, _no_protect, _no_handler, _env_slots, _env_slots_invalid pass pass pass

The same results on each host: WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11, with d3d12, d3d12core and dxgi set to native) on an RTX 3090 (NVIDIA 590.48.01), and GE-Proton on the Radeon iGPU of a Ryzen 5 7600 (RADV, Mesa 26.0.8) for the two d3d12_set0_compute registrations. So the new checks fail on main's code and pass with your change.

These tests are Windows-only, so nothing ran natively. Built with clang-cl and xwin in a container; not run on Windows or with the retail game.

AI-assisted (Claude).

@Moriz82
Moriz82 force-pushed the split/rt-title-texture-views branch from 99176da to c8b2308 Compare November 24, 2026 22:18
@Moriz82

Moriz82 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main 9f25f1ef2: the branch had started to conflict after #375 merged. #375 and this change both edit device_slot_overridden in runtime/shims/d3d12_xs_device.cpp (#375 adds slots 17 to 24 and 56, this change adds slot 71) and the list of checks in runtime/test/xs_proxy_mock_test.cpp (#375 adds five, this change renames check_slot70 to check_placed_views). Both sides are kept; nothing else changed.

On the new head the three targets were rebuilt and all eight registered forms run again on an RTX 4070 (NVIDIA 620.73.04), this time under Wine 11.22 (distribution package): d3d12_set0_compute, d3d12_placed_texture_uav_off and the six xs_proxy_mock forms all exit 0, with the same results as before. The plain xs_proxy_mock run includes the checks #375 added. The description has a paragraph on this.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
A raw shader-resource view of a live image used to return a null
descriptor. Match the placement and resource description for SRVs and
UAVs, retain the chosen image while creating its view, and remove its
entry on final release. The placement ABI is also documented by VIctory.

The default and rollback GPU tests each sampled 64 expected texels from
a placed view. The default accepted two writable views and rejected two
controls. The rollback returned four null UAVs.

xs_proxy_mock's invalid environment-slot case used slot 71 as its
forwarded PC slot. Slot 71 is routed now, so the case probes slot 72.
All six CTest forms of the proxy test pass.

Rebased onto main after #375: both sides of device_slot_overridden and of
the proxy test's check list are kept. All eight registered forms of the
two tests pass on the rebased head under Wine 11.22.

AI-assisted (Codex and Claude Code agents).

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Moriz82
Moriz82 force-pushed the split/rt-title-texture-views branch from c8b2308 to 0a92b13 Compare November 25, 2026 03:51
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@Moriz82 Moriz82 closed this by deleting the head repository Nov 26, 2026
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.

6 participants