using System;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Graphics.Buffers.Interop;
using TerraFX.Interop;
namespace ComputeSharp.Graphics.Extensions
{
///
/// A with extensions for the type.
///
internal static unsafe class ID3D12ResourceExtensions
{
///
/// Maps the current resource to a specified subresource.
///
/// The target to map.
/// A instance representing the mapped resource.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ID3D12ResourceMap Map(this ref ID3D12Resource d3D12Resource)
{
void* pointer;
d3D12Resource.Map(0, null, &pointer).Assert();
return new((ID3D12Resource*)Unsafe.AsPointer(ref d3D12Resource), pointer);
}
///
/// Maps a given memory area.
///
/// The target to map.
/// A pointer to the mapped area for .
/// Thrown when the mapping operation fails.
/// Only use this method to unmap resources that were mapped with .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Unmap(this ref ID3D12Resource d3D12Resource)
{
d3D12Resource.Unmap(0, null);
}
}
}