Skip to content

GPU: return the output pointer from GetDesc methods - #1093

Closed
BlueCatsz wants to merge 1 commit into
Marvisak:mainfrom
BlueCatsz:fix/gpu-getdesc-return-ptr
Closed

BlueCatsz wants to merge 1 commit into
Marvisak:mainfrom
BlueCatsz:fix/gpu-getdesc-return-ptr

Conversation

@BlueCatsz

Copy link
Copy Markdown

Fixes #779

Summary

Under the Microsoft x64 COM ABI, member methods returning a struct larger than 8 bytes by value receive a caller-allocated hidden output pointer (out, after this) and must return that pointer in RAX.

In victory-gpu, all four GetDesc implementations currently return (), leaving RAX undefined for callers that read the returned pointer rather than their own stack slot:

  • ID3D12Heap::GetDesc (resource::heap_desc, HeapDesc = 48 B)
  • ID3D12Resource::GetDesc (resource::resource_desc, ResourceDesc = 56 B)
  • ID3D12CommandQueue::GetDesc (queue::desc, QueueDesc = 16 B)
  • ID3D12DescriptorHeap::GetDesc (descriptor::desc, HeapDesc = 16 B)

Other hidden-out-pointer methods in the workspace (xsystem::analytics_info, resource::allocation_info, resource::allocation_info2, and resource::custom_heap_properties) already return out.

Changes

  • crates/victory-gpu/src/resource.rs: change heap_desc and resource_desc to return *mut HeapDesc / *mut ResourceDesc (out); update resource::tests::heaps_are_zeroed_aligned_memory and resource::tests::committed_and_placed_resources_map_at_their_gpu_address to verify get_desc(obj, out_ptr) == out_ptr, the populated fields, and null out handling.
  • crates/victory-gpu/src/queue.rs: change queue::desc to return *mut QueueDesc (out) and add synthetic test queue::tests::queue_get_desc_returns_its_output_pointer (resolving vtable slot 0xe0 vs 0xd0 dynamically).
  • crates/victory-gpu/src/descriptor.rs: change descriptor::desc to return *mut HeapDesc (out) and add synthetic test descriptor::tests::heap_get_desc_returns_its_output_pointer.

Verification

  • Fork windows-latest CI run (45374509224 against ef2f8fa16e00856779e40bf1b3050eea508784c7):
    • cargo clippy --workspace --all-targets --locked -- -D warnings — passed
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — passed
    • cargo test --workspace --locked — passed across all workspace crates, including:
      • victory-gpu: 52 passed; 0 failed; 1 ignored (texture_checks_per_submission benchmark), including all four GetDesc tests (heaps_are_zeroed_aligned_memory, committed_and_placed_resources_map_at_their_gpu_address, queue_get_desc_returns_its_output_pointer, heap_get_desc_returns_its_output_pointer)
      • xtask: 4 passed; 0 failed (including policy::tests::repository_passes_policy)
  • Independent Windows hardware / D3D12 checks reported on GPU: GetDesc methods do not return their output pointer in RAX (fix on a fork) #779:
    • Confirmed cleanly compatible with GetDesc returns zero mips for automatically sized textures #773 (ec64d8d atop ef2f8fa) and returning the output pointer on RTX 4070 Ti + WARP (DrDarkDK, 56 passed, 1 benchmark ignored).
    • Cherry-picked downstream in LAKSHYA-cmd-tech/VIctory#12 and verified on Windows 11 D3D12 across all 88 victory-gpu tests on that fork (LAKSHYA-cmd-tech).

Disclosure

Verified with synthetic unit tests only (no game files or external dumps used). This patch and PR are AI-assisted.

Under the Microsoft x64 ABI, COM methods returning a struct larger than 8 bytes by value receive a caller-allocated hidden return pointer (after `this`) and must return that pointer in RAX.

ID3D12Heap::GetDesc, ID3D12Resource::GetDesc, ID3D12CommandQueue::GetDesc, and ID3D12DescriptorHeap::GetDesc returned (), leaving RAX undefined, unlike GetCustomHeapProperties and GetResourceAllocationInfo.

Return `out` from all four methods and cover the return pointer and null output pointer handling with synthetic unit tests.
JMAN730 pushed a commit to JMAN730/project-flamingo that referenced this pull request Nov 24, 2026
@MichaelSmithAI

Copy link
Copy Markdown

Independent Win64 check under Wine/GE 3.2: ef2f8fa applied cleanly to our integration build (290b384), and all four guest vtable tests passed for the resource, heap, descriptor heap and command queue. Each GetDesc returned the address supplied by the caller.

We also combined this change with #933 and checked the returned address and descriptor contents in the same call. On an RTX 4090, a committed 4×2 texture with nine array slices reported three automatic mip levels. A 4×2×9 volume reported four. Requesting two levels explicitly returned two for each. All four results matched GetDesc on the actual D3D12 backing resource, and the guest returned the original output pointer each time. All six focused tests passed on the combined build. This exercises synthetic resources; title use remains unmeasured.

@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at ef2f8fa: cargo test -p victory-gpu passes, 52 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
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.

GPU: GetDesc methods do not return their output pointer in RAX (fix on a fork)

4 participants