Skip to content

d3d12: validate objects[] and fence in MakeResident, Evict, EnqueueMakeResident - #7317

Open
DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:fix/d3d12-residency-validation
Open

DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:fix/d3d12-residency-validation

Conversation

@DenRakEiw

Copy link
Copy Markdown
Contributor

Claim: #7049 (comment)

Summary

Validates objects[] entries and fence ownership in MakeResident, Evict, SetResidencyPriority, and EnqueueMakeResident in runtime/shims/d3d12_vulkan_device.cpp:

  • owns_child / validate_residency_objects:
    • Verifies objects[i] != nullptr and that every entry's GetDevice(IID_IUnknown) matches this device's canonical IUnknown identity (works both standalone and behind the Xbox-ABI DeviceProxy).
    • Returns E_INVALIDARG on null array, null entry, foreign-device object, or non-owned COM object (never faulting).
    • Also validates device ownership in SetResidencyPriority.
  • EnqueueMakeResident:
    • Validates flags (only D3D12_RESIDENCY_FLAG_NONE / D3D12_RESIDENCY_FLAG_DENY_OVERBUDGET), objects[], and (when non-null) that fence belongs to this device and implements ID3D12Fence before calling Signal(value).
    • Never signals the fence on any error path.

Live Windows 11 D3D12 Oracle Results (WARP & NVIDIA GeForce RTX 5090)

  • MakeResident / Evict with count == 0, objects == nullptr: S_OK on both WARP and RTX 5090.
  • MakeResident / Evict with count > 0 and null array, null entry, or dummy COM object: host faults (0xc0000005); foreign-device object (cross-adapter) faults on RTX 5090 and removes the device (DXGI_ERROR_INTERNAL_ERROR) on WARP. Layer returns E_INVALIDARG.
  • SetResidencyPriority with foreign-device object: E_INVALIDARG on both WARP and RTX 5090.
  • EnqueueMakeResident with valid count == 0, objects == nullptr + valid fence: S_OK and signals fence on both WARP and RTX 5090.
  • EnqueueMakeResident with invalid flags (0x2), foreign-device fence, or dummy COM fence: E_INVALIDARG and fence is not signaled on both WARP and RTX 5090.
  • EnqueueMakeResident with null array, null entry, or dummy COM object: host faults without signaling the fence; layer returns E_INVALIDARG without signaling the fence.

Tests (NVIDIA GeForce RTX 5090, LEONIDA_VK_VALIDATION=1, 0 VUIDs)

  • d3d12_residency: PASSED (107 values from 62 steps compared with live host D3D12, 0 mismatches + exhaustive layer validation assertions for null/foreign/dummy objects and fences; FAIL_REGULAR_EXPRESSION "Validation Error;VUID-" added in runtime/CMakeLists.txt).
  • d3d12_com: PASSED (0 VUIDs).
  • xs_proxy_mock, queue_proxy, allocator_proxy: PASSED (3/3, 0 VUIDs).
  • d3d12_vulkan_device: all residency assertions (lines 5680-5712) passed with 0 VUIDs (pre-existing unrelated failure on RTX 5090 at line 6564 CreateReservedResource2/GetResourceTiling tiles == 1).

AI-assisted (Gemini 4 Neon).

@MartinIndra02

Copy link
Copy Markdown

Independent Windows + GPU test of 3494d64d0: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24), Vulkan SDK 1.4.363.1, no game files.

  • d3d12_residency_test.exe: residency: 107 values from 62 steps compared with the host (11 more not compared), 0 mismatches -> d3d12_residency_test: OK (exit 0).

AI-assisted review/test.

@myokex

myokex commented Nov 23, 2026

Copy link
Copy Markdown

Tested 3494d64d0 on Windows 11, AMD Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), MSVC 2022 RelWithDebInfo, CMake 4.4.4, Vulkan SDK 1.4.363.0; merged alone onto main 042c5f378, full ctest -j8; synthetic, no game files: pass. 255/260, no new failures; d3d12_residency passes. The 5 failures main itself has on this card (vk_queue_query_sync, d3d12_vulkan_device, d3d12_texture_tiles, d3d12_indirect_dispatch_count, d3d12_pipeline_library_host, see #166) fail the same way with and without this PR. AI-assisted (Claude Code).

@TheHoracio

Copy link
Copy Markdown
Contributor

Tested 3494d64d0 on AMD Radeon RX 7800 XT (RDNA3), Windows 11, MSVC 2022 RelWithDebInfo: pass. Full ctest without game files: 255/259; the 4 failures (d3d12_vulkan_device, d3d12_texture_tiles, d3d12_indirect_dispatch_count, d3d12_pipeline_library_host) fail the same way on clean main on this adapter. (AI-assisted run.)

@h0useadv

Copy link
Copy Markdown

Tested 3494d64d0 on AMD Radeon RX 9070 XT (RDNA4), AMD Windows driver 32.0.32029.2010, Windows 11 Pro build 26300: pass. Built with clang-cl 23.1.6 + lld-link against an xwin splat (MSVC 14.44, SDK 10.0.26100), RelWithDebInfo, Vulkan-Headers 1.4.369; synthetic, no game files.

AI-assisted (Claude Code).

@caiodstx

Copy link
Copy Markdown

Tested 3494d64d0 merged alone on main dde82f27e on AMD Radeon RX 6700 XT (RDNA2, gfx1031), AMD 26.9.1 (Vulkan 1.4.315), Windows 11 IoT Enterprise LTSC 2024 (26100), MSVC 14.51 + Ninja, RelWithDebInfo, Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON, no game files: pass, no regressions.

  • The PR's tests pass: d3d12_residency
  • Full ctest: no test fails with this PR that doesn't also fail on main alone.

On main alone, on this GPU, the full ctest fails these: d3d12_vulkan_device, d3d12_texture_tiles and d3d12_pipeline_library_host (each has an open fix PR), d3d12_depth_resolve (from #6610, fixed by #7905), and vk_queue_query_sync, which is flaky on main here (line 468: progress_loss_ok, 5 of 10 serial runs fail; also seen in #8426).

Ran the full ctest --test-dir runtime/build -j 6 with the PR merged alone and compared the failures with main alone. AI-assisted (Claude Code).

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