Skip to content

Runtime: GetHeapProperties reports a placed resource's heap flags as the host does - #3164

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
mrp1no:d3d-heap-properties-host
Nov 23, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
mrp1no:d3d-heap-properties-host

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

New D3D item, claimed in #3047 (claim).

Depends on: #2864. It uses the placed_ flag that PR adds to Resource, so this branch is built on it and the diff shows #2864's two commits until that lands. Only the last commit is this item. It stays clear of #2590 (ID3D12Resource1/2, ID3D12Heap1).

What was wrong

GetHeapProperties was compared with the host only by d3d12_node_mask_test, for six committed resources in three heap types. On every other case it answers as the host, but one:

A placed resource in an ALLOW_ALL heap reads back the heap's flags as they are (0) on the host. The layer added the DENY bits of the resource classes the resource isn't (0xC0 for a buffer, 0x44 for a texture). Those bits are the runtime's to choose only for a committed resource's implicit heap. A placed resource sits in the application's heap, whose flags are reported unchanged, without the two creation-only bits. In ALLOW_ONLY_* heaps the two answers happen to agree, since the heap's flags are the DENY bits already.

The change

  • Resource::resolved_heap_flags(): for a placed resource, the heap's flags minus CREATE_NOT_RESIDENT / CREATE_NOT_ZEROED. For a committed resource, the existing rule (the caller's flags plus the DENY bits), which matched everywhere.
  • New d3d12_heap_properties_test (standalone device, which has the address arena heaps need) records 561 values:
    • Values: for each case, Type, CPUPageProperty, MemoryPoolPreference, both node masks and the flags, with properties only, flags only and both null. Each output starts as a sentinel, so a call that writes on failure would show.
    • Committed resources (21): buffers in DEFAULT, UPLOAD, READBACK and four custom heaps (write-back and write-combine L0, not-available L0 and L1); explicit node masks; SHARED, CREATE_NOT_ZEROED, CREATE_NOT_RESIDENT and SHARED | CREATE_NOT_ZEROED; plain, render-target, depth and UAV textures; ALLOW_DISPLAY and SHARED render targets; textures in custom heaps.
    • Placed resources (10): buffers and textures in ALLOW_ONLY_* and ALLOW_ALL heaps, in UPLOAD, READBACK and custom heaps, with SHARED and CREATE_NOT_ZEROED heap flags.
    • Reserved: a buffer and a texture.
  • docs/d3d12_vulkan.md states the rule next to the reserved-resource note.

Tested

Windows 11 Pro 26300, MSVC 19.52 (VS 18 Build Tools, Ninja, RelWithDebInfo), NVIDIA GeForce RTX 3060, driver 610.88, Vulkan headers/loader 1.4.357:

  • d3d12_heap_properties_test with LEONIDA_VK_VALIDATION=1: 561 values compared, 0 mismatches.
  • Negative control: on main's layer (16282101), 4 mismatches: the placed buffer and texture in ALLOW_ALL heaps, flags with and without properties.
  • d3d12_node_mask_test: still 18/18 against the default adapter and 18/18 against WARP.
  • Full ctest (on this branch, i.e. with Runtime: MakeResident, Evict, SetResidencyPriority and EnqueueMakeResident answer as the host does #2864): 126/126 pass; the 7 that skip on this machine (no game work folder, no vk_sync_validation layer, no RGB9E5 render target) skip on main too, and gameinput isn't built without SDL3.

No game files involved. AI-assisted (Claude Code).

🤖 Generated with Claude Code

@yagoviccari1-spec

Copy link
Copy Markdown

Tested the merge of PR #3164 head af96d7e with origin/main 1628210 (tree 2ec3acb9) on Windows 11 build 26200.9974, NVIDIA RTX 5060 Ti / driver 621.24 (Vulkan 1.4.357), MSVC 19.44.35207, CMake 4.5.1 + Ninja 1.13.2, llvm-mc 21.1.8 and SPIRV-Tools v2026.4 on PATH:

  • Full ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure: 131 ran, 0 failed out of 132 registered (~119 s).
  • Both new tests passed: d3d12_residency 7.05 s, d3d12_heap_properties 0.76 s.
  • At the bare PR head (before merging current main) the test set is older; I tested the merge because that is what the maintainer would get after merging. No game files used.

Scope: these are the runtime test results on this GPU/driver, not an independent check of the host-runtime comparison the PR implements. Ran with an AI agent on my machine.

@ICUMADETHIS

Copy link
Copy Markdown
Contributor

Tested af96d7e3 on top of main 16282101 (Windows 11 26300, RTX 2080 Ti on 621.14, MSVC 14.44): pass.

With LEONIDA_VK_VALIDATION=1:

  • d3d12_heap_properties: 561 values compared with the host, 0 mismatches.
  • d3d12_residency: 99 values from 58 steps, 0 mismatches.
  • d3d12_node_mask: heap properties still 18/18 against both the 2080 Ti and WARP.

There were no validation messages, and the full ctest -j 4 is 123/123.

AI-assisted.

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested af96d7e3, applied alone on main 16282101: pass.
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), picked with LEONIDA_VK_DEVICE.

  • The diff against main includes Runtime: MakeResident, Evict, SetResidencyPriority and EnqueueMakeResident answer as the host does #2864's two commits, as the description says, so this is the three commits together.
  • Tests only, on main's layer: d3d12_heap_properties_test fails on both GPUs with 561 values compared with the host (0 more not compared), 4 mismatches, then line 280: mismatches == 0. The four are the placed buffer (ours 0xc0, host 0x0) and the placed texture (ours 0x44, host 0x0) in ALLOW_ALL heaps, each with and without the properties pointer. From Runtime: MakeResident, Evict, SetResidencyPriority and EnqueueMakeResident answer as the host does #2864's part: d3d12_residency_test 7 mismatches, d3d12_vulkan_device_test stops at line 4427.
  • Whole change: 0 errors, 0 warnings. d3d12_heap_properties_test: 561 values compared, 0 mismatches, exit 0 on both GPUs. d3d12_residency_test: 99 values from 58 steps compared (11 more not compared), 0 mismatches on both. d3d12_vulkan_device_test and d3d12_node_mask_test exit 0 on both.
  • The host device in d3d12_heap_properties_test is created with a null adapter, so the reference was the RTX 3070's D3D12 in both runs, whichever GPU the layer used.

Not checked: LEONIDA_VK_VALIDATION=1 and the full ctest. main has since moved to f847748c; git merge-tree reports conflicts there in docs/d3d12_vulkan.md and runtime/CMakeLists.txt, and I did not build on it.

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested af96d7e3 (the branch's own commit, merged locally onto main 16282101 together with its parent #2864; clean merge) on RTX 4070 (NVIDIA 621.01), Windows 11 (10.0.26300), MSVC 14.44, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, RelWithDebInfo: pass.

  • Full build: no new warnings (14 warning lines, same as base). Full ctest -C RelWithDebInfo --output-on-failure: 123 passed, 0 failed, 8 skipped and gameinput disabled (124 registered: the base ec8ec4c9 has 122, plus d3d12_residency from Runtime: MakeResident, Evict, SetResidencyPriority and EnqueueMakeResident answer as the host does #2864 and the new d3d12_heap_properties; the same skips as the base: no game files, no LEONIDA_VK_VALIDATION, no RGB9E5 render targets here, no SDL3). d3d12_heap_properties: 561 values compared with the host D3D12, 0 mismatches. The docs tests pass.
  • Negative control: with only the three lines of the fix removed from d3d12_vulkan_device.cpp, d3d12_heap_properties fails with 4 mismatches against the host, all placed resources in ALLOW_ALL heaps (placed buffer ... flags: ours 0xc0 host 0x0, placed texture ... flags: ours 0x44 host 0x0, each also in the flags-only variant); with the fix it passes.

Not tested: AMD/Intel hosts, validation layers, Windows 10. Tested with AI assistance (Claude); no game files or data involved.

@Catskan

Catskan commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested af96d7e on Sapphire RX 9070 XT Nitro+ (AMD 26.11.2 LLPC, driverVersion 2.0.416), Windows 11 26200, MSVC: pass. The runtime builds. Full ctest from a desktop session: 0 failed out of 126, with 6 skipped (game package or optional tools). AI-assisted run.

mrp1no and others added 3 commits November 22, 2026 22:04
d3d12_residency_test runs the same 110 MakeResident / Evict /
SetResidencyPriority / EnqueueMakeResident steps on the Vulkan-backed device
and on the host runtime, with a committed buffer, a heap, a placed buffer, a
descriptor heap, a query heap and a fence of each. It compares every HRESULT,
the device-removed reason after each step, and the value EnqueueMakeResident
leaves the fence at. Steps that leave the host runtime unusable run there in a
child process with a fresh device (--host-step). On main 7 steps differed (RTX
3060, driver 610.88); now none do:

- SetResidencyPriority takes a priority only for objects that own their
  memory, committed resources and heaps. A placed resource (a reserved one too,
  by the same rule; not measured), a descriptor heap, a query heap or a fence is E_INVALIDARG, also inside a
  longer list (the layer accepted all of them). The host also removes its
  device then (DXGI_ERROR_INVALID_CALL); the layer doesn't, since a title that
  sets priorities on placed resources would lose its device over a hint.
- EnqueueMakeResident accepts a null fence and signals nothing (the layer
  answered E_INVALIDARG).

Not compared: a nonzero count with a null array and a null entry in an array,
which the host dereferences; and a value below the fence's current one, which
moves the host's fence back but not the layer's (Vulkan timelines only go up,
already documented).

d3d12_vulkan_device_test's residency checks expected the old answers for a
fence and an allocator's priority and for a null fence, and now expect the
host's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the review on ItsNotRexed#2864. The exit code a host-step child gives when it
couldn't run its step (kNoChild, 0xC41DFA11) fell into the crash-status mask
and counted as a host fault, so a broken child path would have left those
steps "not compared" and passed. It is now checked first and fails the test,
and the values left out may not exceed the 11 measured (the nine null-pointer
steps the host faults on and the backwards fence twice), so the comparison
can't go vacuous. The summary and docs now say 58 steps and 110 values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d3d12_heap_properties_test compares what ID3D12Resource::GetHeapProperties
returns on the Vulkan-backed device and on the host runtime: the properties
and heap flags of committed resources in every heap type (custom ones and
SHARED, ALLOW_DISPLAY, CREATE_NOT_ZEROED, CREATE_NOT_RESIDENT included), of
placed resources in heaps of each kind, and of reserved resources, with null
arguments too, and whether each call wrote its outputs: 561 values. On main 4
differed (RTX 3060, driver 610.88), all the same rule: a placed resource
reports its heap's flags as they are, so one in an ALLOW_ALL heap reads back
0, while the layer added the DENY bits of the resource classes it isn't (0xC0
for a buffer, 0x44 for a texture). Those bits are the runtime's choice only for
a committed resource's implicit heap, where the layer already matched.

Builds on ItsNotRexed#2864, which adds the placed_ flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrp1no
mrp1no force-pushed the d3d-heap-properties-host branch from af96d7e to 4676609 Compare November 22, 2026 21:07
@mrp1no

mrp1no commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the rebased #2864 (now 4676609) to clear a docs/d3d12_vulkan.md conflict with #2462's paragraph. Both paragraphs are kept. There are no code changes. d3d12_heap_properties_test, d3d12_node_mask_test, d3d12_residency_test and d3d12_vulkan_device_test pass with LEONIDA_VK_VALIDATION=1 (RTX 3060 / 610.88).

@ItsNotRexed
ItsNotRexed merged commit 06393b2 into ItsNotRexed:main Nov 23, 2026
2 of 4 checks passed
@Vonsek

Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 4676609 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_heap_properties|d3d12_residency|d3d12_vulkan_device)$" (the tests this PR adds/changes): pass on both GPUs, 3/3 each. No game files.

AI-assisted.

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.

8 participants