From c9bee1a0477f2de68c83e9c55e2fbc3a1e2b641c Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 29 Jun 2023 18:51:32 +0200 Subject: [PATCH] Add ID3D12AllocationExtensions type --- .../Interop/ID3D12AllocationExtensions.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/ComputeSharp/Graphics/Extensions/Interop/ID3D12AllocationExtensions.cs diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12AllocationExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12AllocationExtensions.cs new file mode 100644 index 00000000..ff1a050b --- /dev/null +++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12AllocationExtensions.cs @@ -0,0 +1,29 @@ +using ComputeSharp.Core.Extensions; +using ComputeSharp.Interop.Allocation; +using TerraFX.Interop.DirectX; +using TerraFX.Interop.Windows; + +namespace ComputeSharp.Graphics.Extensions; + +/// +/// A with extensions for the type. +/// +internal static unsafe class ID3D12AllocationExtensions +{ + /// + /// Gets the underlying for a given object. + /// + /// The input object. + /// An reference for the current object. + /// + /// The returned resource should not be used after the current allocation instance has been released. + /// + public static ComPtr GetD3D12Resource(this ref ID3D12Allocation allocation) + { + using ComPtr d3D12Resource = default; + + allocation.GetD3D12Resource(d3D12Resource.GetAddressOf()).Assert(); + + return d3D12Resource.Move(); + } +} \ No newline at end of file