GPU/COM: return hidden sret out pointer in RAX from Heap/Resource/DescriptorHeap/Queue GetDesc #3056
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3058"
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 Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T05:43:06Z.
Problem
Under the Microsoft x64 calling convention (Return values), COM methods returning structs larger than 8 bytes by value write into the caller-supplied hidden
sretpointer (out) and must return that sameoutpointer inRAX.Four D3D12 COM
GetDescmethods invictory-gpucurrently return()instead of*mut ...:ID3D12Heap::GetDesc(resource.rs::heap_desc, 48 B)ID3D12Resource::GetDesc(resource.rs::resource_desc, 56 B)ID3D12DescriptorHeap::GetDesc(descriptor.rs::desc, 16 B)ID3D12CommandQueue::GetDesc(queue.rs::desc, 16 B)Compare with
allocation_info,allocation_info2,custom_heap_properties(resource.rs), andxsystem::analytics_info, which already returnout. In--releasebuilds, LLVM leaves a clobbered register (e.g. the vtable pointer) inRAXinstead ofout, so MSVC C++ callers chainingres->GetDesc().Width/heap->GetDesc().SizeInBytesviaRAXread garbage or fault.Fix
Change all four
GetDescimplementations to return*mut HeapDesc/*mut ResourceDesc/*mut QueueDescand returnout. Disjoint from #933, #2193, and #2690 (which adjustResourceDescfield values while keeping()).Verification
resource::tests::heaps_are_zeroed_aligned_memory,descriptor::tests::heaps_hold_count_descriptors_from_their_start, andqueue::tests::queue_signals_complete_at_onceto call all four vtable slots asextern "system" fn(This, *mut T) -> *mut Tand assert the returned pointer equalsout.--releasebefore fix: all 3 tests failed with vtable pointers (0x1405...) inRAXinstead of the stackoutpointer (0x7fffff...); all 3 pass in--releaseand debug after fix.windows-latestMSVC + WARP SM 6.6 CI (cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features,xtask policy, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45762903919AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:55:34Z.
Review: APPROVED
Reviewed head
51f4e879line-by-line (CI green):GetDesc) must return the hiddensretdestination pointer inRAX; callers frequently dereferenceRAXdirectly for chained field reads.GetDescimplementations (descriptor::desc,queue::desc,resource::heap_desc,resource::resource_desc) now returnout, matchingcustom_heap_properties, and each has a regression assertion checking the returned pointer equals the caller's out pointer.Clean ABI fix.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T05:59:30Z.
Review: APPROVED
Verified: MSVC's x64 sret convention returns the hidden out pointer in RAX — a void signature left it undefined for any title code that chains or inspects it. All four desc methods (descriptor Heap, queue, resource Heap, Resource) now return
out; the queue test correctly handles both vtable layouts (desc slot 0xe0/0xd0 by signal_slot) and each asserts ret == out plus populated contents.Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T05:58:01Z.
Closing: after checking closed PR #2058's second-look review, Xbox D3D12.X
GetDescvtable slots take an explicit out-pointer returningvoid(the C++ inline wrapper returns its local copy), so no caller readsRAX. Apologies for the noise!Pull request closed