Add PIX overloads taking a ReadOnlySpan<byte> message

このコミットが含まれているのは:
Sergio Pedri committed 2022-06-19 15:37:40 +02:00
1 親 6144932685
コミット 9d7098002c
2ファイル変更
+196 -2

検索条件に一致するファイルはありません

+30 -1
ファイルの表示
@@ -1,4 +1,5 @@
using System.Buffers;
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Text;
using TerraFX.Interop.DirectX;
@@ -42,6 +43,20 @@ internal static class ID3D12GraphicsCommandListExtensions
ArrayPool<byte>.Shared.Return(buffer);
}
/// <summary>
/// Begins a PIX event on a target <see cref="ID3D12GraphicsCommandList"/> object.
/// </summary>
/// <param name="d3D12GraphicsCommandList">The target <see cref="ID3D12GraphicsCommandList"/> object.</param>
/// <param name="color">The color to use for the event.</param>
/// <param name="message">The message to use for the event (it's assumed to be a <see langword="null"/>-terminated ANSI characters sequence).</param>
public static unsafe void BeginEventUnsafe(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, ReadOnlySpan<byte> message)
{
fixed (byte* messagePtr = message)
{
Pix.PIXBeginEventOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)messagePtr);
}
}
/// <summary>
/// Sets a PIX marker on a target <see cref="ID3D12GraphicsCommandList"/> object.
/// </summary>
@@ -73,4 +88,18 @@ internal static class ID3D12GraphicsCommandListExtensions
// Return the buffer (if an exception is thrown, it's fine to not do so)
ArrayPool<byte>.Shared.Return(buffer);
}
/// <summary>
/// Sets a PIX marker on a target <see cref="ID3D12GraphicsCommandList"/> object.
/// </summary>
/// <param name="d3D12GraphicsCommandList">The target <see cref="ID3D12GraphicsCommandList"/> object.</param>
/// <param name="color">The color to use for the marker.</param>
/// <param name="message">The message to use for the event (it's assumed to be a <see langword="null"/>-terminated ANSI characters sequence).</param>
public static unsafe void SetPixMarkerUnsafe(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, ReadOnlySpan<byte> message)
{
fixed (byte* messagePtr = message)
{
Pix.PIXSetMarkerOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)messagePtr);
}
}
}