Closed
Description
Summary of feature
The API of ComPtr from wrl has Detach method, which will return the underlying handle to the object and nullify the handle inside the pointer. But for some reason, Silk.NET doesn't implement such method, which can be very helpful for cleaning interfaces in case error occur.
Example:
public ID3D12Device* Device;
static bool Initialize() {
using ComPtr<ID3D12Device> pDevice = new();
HResult hr = D3D12.CreateDevice(null, D3DFeatureLevel.Feature110, SilkMarshal.GuidPtrOf<ID3D12Device>(), (void**)pDevice.GetAddressOf());
if (hr.IsFailure) {
return false;
}
// Initialize ID3D12CommandQueue, IDXGIFactory, etc... here without having to release every successfully created object on every failure
Device = pDevice.Detach();
}