Add PIX overloads taking a ReadOnlySpan<byte> message
このコミットが含まれているのは:
1 親
6144932685
コミット
9d7098002c
2ファイル変更
+196
-2
検索条件に一致するファイルはありません
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Interop;
|
||||
@@ -56,6 +57,88 @@ public static class ComputeContextExtensions
|
||||
commandList.D3D12GraphicsCommandList->BeginEvent(0, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a PIX event on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to start the PIX event.</param>
|
||||
/// <param name="color">The color to use for the event (the alpha channel will be ignored).</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>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <paramref name="message"/> parameter is not checked to ensure it has a <see langword="null"/>-terminator. This allows callers
|
||||
/// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
|
||||
/// The compiler will automatically insert a terminator right past the end of the returned <see cref="ReadOnlySpan{T}"/> when doing so.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method offers greatly reduced overhead compared to the overlods taking a <see cref="string"/>, as there is no need to create the
|
||||
/// <see cref="string"/> instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
|
||||
/// Callers must take extra care to ensure the input message is in fact <see langword="null"/>-terminated when invoking this API.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Conditional("USE_PIX")]
|
||||
public static unsafe void BeginEventUnsafe(this in ComputeContext context, Color color, ReadOnlySpan<byte> message)
|
||||
{
|
||||
ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
|
||||
|
||||
int argb = color.ToArgb();
|
||||
uint pixColor = Pix.PIX_COLOR((byte)((argb & 0x00FF0000) >> 16), (byte)((argb & 0x0000FF00) >> 8), (byte)(argb & 0x000000FF));
|
||||
|
||||
commandList.D3D12GraphicsCommandList->BeginEventUnsafe(pixColor, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a PIX event on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to start the PIX event.</param>
|
||||
/// <param name="index">The index to identify the group this event belongs to (PIX will choose a color to represent all entries in the group).</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>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <paramref name="message"/> parameter is not checked to ensure it has a <see langword="null"/>-terminator. This allows callers
|
||||
/// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
|
||||
/// The compiler will automatically insert a terminator right past the end of the returned <see cref="ReadOnlySpan{T}"/> when doing so.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method offers greatly reduced overhead compared to the overlods taking a <see cref="string"/>, as there is no need to create the
|
||||
/// <see cref="string"/> instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
|
||||
/// Callers must take extra care to ensure the input message is in fact <see langword="null"/>-terminated when invoking this API.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Conditional("USE_PIX")]
|
||||
public static unsafe void BeginEventUnsafe(this in ComputeContext context, byte index, ReadOnlySpan<byte> message)
|
||||
{
|
||||
ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
|
||||
|
||||
uint pixColor = Pix.PIX_COLOR_INDEX(index);
|
||||
|
||||
commandList.D3D12GraphicsCommandList->BeginEventUnsafe(pixColor, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a PIX event on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to start the PIX 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>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <paramref name="message"/> parameter is not checked to ensure it has a <see langword="null"/>-terminator. This allows callers
|
||||
/// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
|
||||
/// The compiler will automatically insert a terminator right past the end of the returned <see cref="ReadOnlySpan{T}"/> when doing so.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method offers greatly reduced overhead compared to the overlods taking a <see cref="string"/>, as there is no need to create the
|
||||
/// <see cref="string"/> instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
|
||||
/// Callers must take extra care to ensure the input message is in fact <see langword="null"/>-terminated when invoking this API.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Conditional("USE_PIX")]
|
||||
public static unsafe void BeginEventUnsafe(this in ComputeContext context, ReadOnlySpan<byte> message)
|
||||
{
|
||||
ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
|
||||
|
||||
commandList.D3D12GraphicsCommandList->BeginEventUnsafe(0, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends a PIX event on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
@@ -113,4 +196,86 @@ public static class ComputeContextExtensions
|
||||
|
||||
commandList.D3D12GraphicsCommandList->SetPixMarker(0, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a PIX marker on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the PIX marker.</param>
|
||||
/// <param name="color">The color to use for the log (the alpha channel will be ignored).</param>
|
||||
/// <param name="message">The message to use for the marker (it's assumed to be a <see langword="null"/>-terminated ANSI characters sequence).</param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <paramref name="message"/> parameter is not checked to ensure it has a <see langword="null"/>-terminator. This allows callers
|
||||
/// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
|
||||
/// The compiler will automatically insert a terminator right past the end of the returned <see cref="ReadOnlySpan{T}"/> when doing so.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method offers greatly reduced overhead compared to the overlods taking a <see cref="string"/>, as there is no need to create the
|
||||
/// <see cref="string"/> instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
|
||||
/// Callers must take extra care to ensure the input message is in fact <see langword="null"/>-terminated when invoking this API.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Conditional("USE_PIX")]
|
||||
public static unsafe void LogUnsafe(this in ComputeContext context, Color color, ReadOnlySpan<byte> message)
|
||||
{
|
||||
ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
|
||||
|
||||
int argb = color.ToArgb();
|
||||
uint pixColor = Pix.PIX_COLOR((byte)((argb & 0x00FF0000) >> 16), (byte)((argb & 0x0000FF00) >> 8), (byte)(argb & 0x000000FF));
|
||||
|
||||
commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(pixColor, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a PIX marker on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the PIX marker.</param>
|
||||
/// <param name="index">The index to identify the group this log belongs to (PIX will choose a color to represent all entries in the group).</param>
|
||||
/// <param name="message">The message to use for the marker (it's assumed to be a <see langword="null"/>-terminated ANSI characters sequence).</param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <paramref name="message"/> parameter is not checked to ensure it has a <see langword="null"/>-terminator. This allows callers
|
||||
/// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
|
||||
/// The compiler will automatically insert a terminator right past the end of the returned <see cref="ReadOnlySpan{T}"/> when doing so.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method offers greatly reduced overhead compared to the overlods taking a <see cref="string"/>, as there is no need to create the
|
||||
/// <see cref="string"/> instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
|
||||
/// Callers must take extra care to ensure the input message is in fact <see langword="null"/>-terminated when invoking this API.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Conditional("USE_PIX")]
|
||||
public static unsafe void LogUnsafe(this in ComputeContext context, byte index, ReadOnlySpan<byte> message)
|
||||
{
|
||||
ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
|
||||
|
||||
uint pixColor = Pix.PIX_COLOR_INDEX(index);
|
||||
|
||||
commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(pixColor, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a PIX marker on a target <see cref="ComputeContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the PIX marker.</param>
|
||||
/// <param name="message">The message to use for the marker (it's assumed to be a <see langword="null"/>-terminated ANSI characters sequence).</param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <paramref name="message"/> parameter is not checked to ensure it has a <see langword="null"/>-terminator. This allows callers
|
||||
/// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
|
||||
/// The compiler will automatically insert a terminator right past the end of the returned <see cref="ReadOnlySpan{T}"/> when doing so.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method offers greatly reduced overhead compared to the overlods taking a <see cref="string"/>, as there is no need to create the
|
||||
/// <see cref="string"/> instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
|
||||
/// Callers must take extra care to ensure the input message is in fact <see langword="null"/>-terminated when invoking this API.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Conditional("USE_PIX")]
|
||||
public static unsafe void LogUnsafe(this in ComputeContext context, ReadOnlySpan<byte> message)
|
||||
{
|
||||
ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
|
||||
|
||||
commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(0, message);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする