GPU/COM: return hidden sret out pointer in RAX from Heap/Resource/DescriptorHeap/Queue GetDesc #3058

Closed
github-bot wants to merge 1 commit from gh-pr/3058/head into gh-pr/3058/base
Owner

@⁠RVZO6 on GitHub · 2026-11-26 05:43 UTC · original
RVZO6:rvzo/com-getdesc-sret → main · +54 −5 · 3 files · 1 commits · closed without merging

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 sret pointer (out) and must return that same out pointer in RAX.

Four D3D12 COM GetDesc methods in victory-gpu currently 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), and xsystem::analytics_info, which already return out. In --release builds, LLVM leaves a clobbered register (e.g. the vtable pointer) in RAX instead of out, so MSVC C++ callers chaining res->GetDesc().Width / heap->GetDesc().SizeInBytes via RAX read garbage or fault.

Fix

Change all four GetDesc implementations to return *mut HeapDesc / *mut ResourceDesc / *mut QueueDesc and return out. Disjoint from #933, #2193, and #2690 (which adjust ResourceDesc field values while keeping ()).

Verification

  • Extended resource::tests::heaps_are_zeroed_aligned_memory, descriptor::tests::heaps_hold_count_descriptors_from_their_start, and queue::tests::queue_signals_complete_at_once to call all four vtable slots as extern "system" fn(This, *mut T) -> *mut T and assert the returned pointer equals out.
  • Negative control in --release before fix: all 3 tests failed with vtable pointers (0x1405...) in RAX instead of the stack out pointer (0x7fffff...); all 3 pass in --release and debug after fix.
  • Verified green on windows-latest MSVC + 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/45762903919
  • Not run: the title; any hardware GPU.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

**@⁠RVZO6** on GitHub · 2026-11-26 05:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/3058) `RVZO6:rvzo/com-getdesc-sret` → `main` · +54 −5 · 3 files · 1 commits · closed without merging ### 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 `sret` pointer (`out`) **and must return that same `out` pointer in `RAX`**. Four D3D12 COM `GetDesc` methods in `victory-gpu` currently 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`), and `xsystem::analytics_info`, which already return `out`. In `--release` builds, LLVM leaves a clobbered register (e.g. the vtable pointer) in `RAX` instead of `out`, so MSVC C++ callers chaining `res->GetDesc().Width` / `heap->GetDesc().SizeInBytes` via `RAX` read garbage or fault. ### Fix Change all four `GetDesc` implementations to return `*mut HeapDesc` / `*mut ResourceDesc` / `*mut QueueDesc` and return `out`. Disjoint from #933, #2193, and #2690 (which adjust `ResourceDesc` field values while keeping `()`). ### Verification - Extended `resource::tests::heaps_are_zeroed_aligned_memory`, `descriptor::tests::heaps_hold_count_descriptors_from_their_start`, and `queue::tests::queue_signals_complete_at_once` to call all four vtable slots as `extern "system" fn(This, *mut T) -> *mut T` and assert the returned pointer equals `out`. - Negative control in `--release` before fix: all 3 tests failed with vtable pointers (`0x1405...`) in `RAX` instead of the stack `out` pointer (`0x7fffff...`); all 3 pass in `--release` and debug after fix. - Verified green on `windows-latest` MSVC + 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/45762903919 - **Not run:** the title; any hardware GPU. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:45 +00:00
github-bot closed this pull request 2026-11-26 06:27:45 +00:00
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-26 05:58 UTC · original

Closing: after checking closed PR #2058's second-look review, Xbox D3D12.X GetDesc vtable slots take an explicit out-pointer returning void (the C++ inline wrapper returns its local copy), so no caller reads RAX. Apologies for the noise!

**@⁠RVZO6** on GitHub · 2026-11-26 05:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3058#issuecomment-7183967295) Closing: after checking closed PR #2058's second-look review, Xbox D3D12.X `GetDesc` vtable slots take an explicit out-pointer returning `void` (the C++ inline wrapper returns its local copy), so no caller reads `RAX`. Apologies for the noise!

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3058
No description provided.