ファイル
ComputeSharp/src/ComputeSharp.D2D1/Shaders/Loaders/D2D1DrawInfoDispatchDataLoader.cs
T
Sergio Pedri b51b002a3a Cleanup the D2D1 generator constant buffer code
Also bumps the maximum constant buffer size
2022-08-08 01:33:38 +02:00

39 行
1.2 KiB
C#

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.__Internals;
using TerraFX.Interop.DirectX;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.Shaders.Loaders;
/// <summary>
/// A data loader for D2D1 pixel shaders dispatched via <see cref="ID2D1DrawInfo"/>.
/// </summary>
internal readonly unsafe struct D2D1DrawInfoDispatchDataLoader : ID2D1DispatchDataLoader
{
/// <summary>
/// The <see cref="ID2D1DrawInfo"/> object in use.
/// </summary>
private readonly ID2D1DrawInfo* d2D1DrawInfo;
/// <summary>
/// Creates a new <see cref="D2D1DrawInfoDispatchDataLoader"/> instance.
/// </summary>
/// <param name="d2D1DrawInfo">The <see cref="ID2D1DrawInfo"/> object to use.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal D2D1DrawInfoDispatchDataLoader(ID2D1DrawInfo* d2D1DrawInfo)
{
this.d2D1DrawInfo = d2D1DrawInfo;
}
/// <inheritdoc/>
void ID2D1DispatchDataLoader.LoadConstantBuffer(ReadOnlySpan<byte> data)
{
this.d2D1DrawInfo->SetPixelShaderConstantBuffer(
buffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)),
bufferCount: (uint)data.Length);
}
}