diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs index d2829172..efcd2acb 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs @@ -348,7 +348,7 @@ internal sealed unsafe partial class SwapChainManager : ReferenceTracked using (ComPtr idxgiSwapChain = default) { - this.dxgiSwapChain3.CopyTo(&idxgiSwapChain).Assert(); + this.dxgiSwapChain3.CopyTo(idxgiSwapChain.GetAddressOf()).Assert(); this.swapChainPanelNative.Get()->SetSwapChain(idxgiSwapChain.Get()).Assert(); } diff --git a/src/TerraFX.Interop.Windows/ComPtr`1.cs b/src/TerraFX.Interop.Windows/ComPtr`1.cs index 092aa947..48d5ab37 100644 --- a/src/TerraFX.Interop.Windows/ComPtr`1.cs +++ b/src/TerraFX.Interop.Windows/ComPtr`1.cs @@ -98,56 +98,6 @@ internal unsafe struct ComPtr : IDisposable InternalAddRef(); } - /// Converts the current object reference to type and assigns that to a target value. - /// The interface type to use to try casting the current COM object. - /// A raw pointer to the target value to write to. - /// The result of for the target type . - /// This method will automatically release the target COM object pointed to by , if any. - public readonly HRESULT As(ComPtr* p) - where U : unmanaged - { - return ((IUnknown*)ptr_)->QueryInterface(__uuidof(), (void**)p->ReleaseAndGetAddressOf()); - } - - /// Converts the current object reference to type and assigns that to a target value. - /// The interface type to use to try casting the current COM object. - /// A reference to the target value to write to. - /// The result of for the target type . - /// This method will automatically release the target COM object pointed to by , if any. - public readonly HRESULT As(ref ComPtr other) - where U : unmanaged - { - U* ptr; - HRESULT result = ((IUnknown*)ptr_)->QueryInterface(__uuidof(), (void**)&ptr); - - other.Attach(ptr); - return result; - } - - /// Converts the current object reference to a type indicated by the given IID and assigns that to a target value. - /// The IID indicating the interface type to convert the COM object reference to. - /// A raw pointer to the target value to write to. - /// The result of for the target IID. - /// This method will automatically release the target COM object pointed to by , if any. - public readonly HRESULT AsIID(Guid* riid, ComPtr* other) - { - return ((IUnknown*)ptr_)->QueryInterface(riid, (void**)other->ReleaseAndGetAddressOf()); - } - - /// Converts the current object reference to a type indicated by the given IID and assigns that to a target value. - /// The IID indicating the interface type to convert the COM object reference to. - /// A reference to the target value to write to. - /// The result of for the target IID. - /// This method will automatically release the target COM object pointed to by , if any. - public readonly HRESULT AsIID(Guid* riid, ref ComPtr other) - { - IUnknown* ptr; - HRESULT result = ((IUnknown*)ptr_)->QueryInterface(riid, (void**)&ptr); - - other.Attach(ptr); - return result; - } - /// Releases the current COM object, if any, and replaces the internal pointer with an input raw pointer. /// The input raw pointer to wrap. /// This method will release the current raw pointer, if any, but it will not increment the references for . @@ -308,16 +258,9 @@ internal unsafe struct ComPtr : IDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] public T** ReleaseAndGetAddressOf() { - _ = InternalRelease(); - return GetAddressOf(); - } + Dispose(); - /// Resets the current instance by decrementing the reference count for the target COM object and setting the internal raw pointer to . - /// The updated reference count for the COM object that was in use, if any. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public uint Reset() - { - return InternalRelease(); + return GetAddressOf(); } /// Swaps the current COM object reference with that of a given instance. @@ -350,19 +293,4 @@ internal unsafe struct ComPtr : IDisposable _ = ((IUnknown*)temp)->AddRef(); } } - - // Decrements the reference count for the current COM object, if any - private uint InternalRelease() - { - uint @ref = 0; - T* temp = ptr_; - - if (temp != null) - { - ptr_ = null; - @ref = ((IUnknown*)temp)->Release(); - } - - return @ref; - } } \ No newline at end of file