You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
windows-bindgen make ID3D12GraphicsCommandList::SetDescriptorHeaps take ManuallyDrop'd references #2930
However, when a function such as SetDescriptorHeaps does use a struct, but just expects an array of pointers to objects, these aren't wrapped in ManuallyDrop:
Although this works, it does mean that there's an unnecessary AddRef/Release going on for each call to SetDescriptorHeaps. This is unfortunate as this is one of the high frequency methods that we expect D3D12 apps to call fairly often so the overhead of AddRef/Release could start to add up.
The solution that I think would fit well here would be if we could get SetDescriptorHeaps to be:
Yep, I've wanted to fix this but the usability of &[ManuallyDrop<Option<T>>] isn't ideal compared with C++. But I agree the extra reference bumps aren't great. Perhaps if there were some kind of IntoParam specialization for this as we do for non-array parameters.
That's an interesting issue indeed. While &[] doesn't move/transfer ownership, the API indeed "requires" the caller to put multiple owned ID3D12DescriptorHeaps in a contiguous array which can only happen by incrementing the refcount.
The only alternative I'd like to mention, for single descriptor heaps, is the existence of std::slice::from_ref(&T) -> &[T], which turns a borrow of an object into a slice of length 1.
Given there is no way to turn an Option<&T> into an &Option<T>, I see now that I ended up implementing that via a transmute in our own codebase though...
changed the title [-]Make ID3D12GraphicsCommandList::SetDescriptorHeaps take ManuallyDrop'd references[/-][+]`windows-bindgen` make ID3D12GraphicsCommandList::SetDescriptorHeaps take ManuallyDrop'd references[/+]on Jul 7, 2026
Activity
kennykerr commentedon Mar 15, 2024
Yep, I've wanted to fix this but the usability of
&[ManuallyDrop<Option<T>>]isn't ideal compared with C++. But I agree the extra reference bumps aren't great. Perhaps if there were some kind ofIntoParamspecialization for this as we do for non-array parameters.MarijnS95 commentedon Mar 18, 2024
That's an interesting issue indeed. While
&[]doesn't move/transfer ownership, the API indeed "requires" the caller to put multiple ownedID3D12DescriptorHeaps in a contiguous array which can only happen by incrementing the refcount.The only alternative I'd like to mention, for single descriptor heaps, is the existence of
std::slice::from_ref(&T) -> &[T], which turns a borrow of an object into a slice of length 1.Given there is no way to turn an
Option<&T>into an&Option<T>, I see now that I ended up implementing that via atransmutein our own codebase though...[-]Make ID3D12GraphicsCommandList::SetDescriptorHeaps take ManuallyDrop'd references[/-][+]`windows-bindgen` make ID3D12GraphicsCommandList::SetDescriptorHeaps take ManuallyDrop'd references[/+]kennykerr commentedon Aug 6, 2026
Materially the same problem as #1339, and closing as not planned for the same reason.