gpu: give a descriptor heap plain memory when its desktop start is not an address #1396
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1403"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T10:41:29Z.
Change
A console executable treats the CPU start of a descriptor heap as an address. A desktop CPU descriptor handle is opaque, and a translation layer may keep tag bits in its low bits. Through vkd3d-proton a sampler heap starts at
...007.For a view heap created without memory of its own, the device wrapper already gives the executable plain memory as the heap's CPU side and translates handles on each call. Heaps of the other types were handed the desktop start as it is.
This PR extends the existing rule: a heap of any type gets plain memory when its desktop start is not pointer-aligned (
src/startup_stubs/title_heap_memory.h, one condition indevice_create_descriptor_heap). Heaps whose desktop start is an address are unchanged, so nothing changes on an adapter whose handles are addresses.What was measured
One console executable under the startup debugger,
mainatda8bfc74, clang-cl build under Wine 11.0 with vkd3d-proton on an RTX 4070 Ti SUPER,X2W_HOST_CPU=1:0x74adb007,0x74add007In the failing run the wrapper's call into the layer had destination
0x74add007and source0xfd00000074adb007: the staging heap's start, and the shader-visible heap's start with0xfdin its top byte. How the executable arrives at that source handle is not known; only the handle and the fault were observed. With aligned starts the same copies arrive with intact handles.Tests
New
tests/startup_title_heap_check.cpp:startup_title_heap: the rule without a device, on the four starts measured through the layer and on aligned starts of each heap type.startup_title_heap_tags_controlruns it with the alignment test removed and must fail (WILL_FAIL).startup_title_heap_device_warp/_hardware: through the wrapper, with the four heaps the executable creates without memory (two sampler heaps of 128, a render-target heap of 4,096, a depth heap of 2,048). For each it creates the same heap on the desktop device, prints both starts, and requires the wrapper's start to be an aligned address; where the desktop start is tagged the heap must have memory of its own. Then three samplers are created in the staging heap and copied to the shader-visible one through handles computed as start plus index times stride, and the device must not be removed.Results
At
ea978727, same host:Negative control for the device check: the same test binary against a wrapper built with the condition reverted to view heaps only:
docs_links_check.pypasses.Not verified
desktop handlefour times; that has not been run.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T10:52:25Z.
Review: COMMENTED
Reviewed commit
ea9787279d53e3d802ce0ed148d21aa218d84560:x2w_startup::heap_needs_title_memoryinsrc/startup_stubs/title_heap_memory.h(returns true forCBV_SRV_UAVor non-pointer-aligneddesktop_cpu_start) and wires it intodevice_create_descriptor_heapinsrc/startup_stubs/d3d12_xs_device.cppwithVirtualAllocfallback anddescriptor_rangestracking, plustests/startup_title_heap_check.cpp(9 unit cases,--mutate tagsnegative control, and device test creating 4 heaps and copying 3 samplers viaCopyDescriptorsSimple) anddocs/startup-runtime.md.git diff --checkclean;tests/docs_links_check.py(16 Markdown files, 316 links) andtests/bidi_controls_check.py(1178 files) passed.--preset dev,startup_title_heap_check): 4/4 passed (startup_title_heap,startup_title_heap_tags_control,startup_title_heap_device_warp,startup_title_heap_device_hardware)./O2(--preset release,startup_title_heap_check): 4/4 passed.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T10:58:06Z.
Pushed
85c6183eso heap creation returns E_OUTOFMEMORY if it needs CPU backing and that allocation fails. The wrapper therefore never publishes the tagged handle as a CPU address on that path. The control injects a failed allocation for a tagged sampler and verifies that an aligned sampler or caller-supplied backing does not allocate. All four startup_title_heap Release checks passed, including WARP and RTX 4060 Laptop.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:08:19Z.
Review: COMMENTED
Retested at commit
85c6183e(delta overea978727):ensure_title_heap_memoryinsrc/startup_stubs/title_heap_memory.hcleanly extracts the required-backing check and rejects OOM whenheap_needs_title_memoryrequires CPU backing and allocation fails (E_OUTOFMEMORYindevice_create_descriptor_heap, releasingheap), while preserving caller-providedtitle_memorywithout extra allocation;tests/startup_title_heap_check.cppcovers OOM rejection, empty backing on failure, aligned sampler skip, and caller-provided memory retention.git diff --checkclean;tests/docs_links_check.pypassed (16 Markdown files, 316 links);tests/bidi_controls_check.pypassed (1178 files).--preset dev):startup_title_heap_checkbuilt;ctest -R '^startup_title_heap'4/4 passed (startup_title_heap,startup_title_heap_tags_control,startup_title_heap_device_warp,startup_title_heap_device_hardware)./O2(--preset release):startup_title_heap_checkbuilt;ctest -R '^startup_title_heap'4/4 passed.