using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.Descriptors;
using ComputeSharp.D2D1.Extensions;
using ComputeSharp.Win32;
namespace ComputeSharp.D2D1.Shaders.Loaders;
///
/// A data loader for D2D1 pixel shaders dispatched via .
///
internal readonly unsafe struct D2D1DrawInfoConstantBufferLoader : ID2D1ConstantBufferLoader
{
///
/// The object in use.
///
private readonly ID2D1DrawInfo* d2D1DrawInfo;
///
/// Creates a new instance.
///
/// The object to use.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal D2D1DrawInfoConstantBufferLoader(ID2D1DrawInfo* d2D1DrawInfo)
{
this.d2D1DrawInfo = d2D1DrawInfo;
}
///
void ID2D1ConstantBufferLoader.LoadConstantBuffer(ReadOnlySpan data)
{
this.d2D1DrawInfo->SetPixelShaderConstantBuffer(
buffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)),
bufferCount: (uint)data.Length).Assert();
}
}