diff --git a/src/ComputeSharp.Pix/ComputeContextExtensions.cs b/src/ComputeSharp.Pix/ComputeContextExtensions.cs
index 804009f8..16de0c2a 100644
--- a/src/ComputeSharp.Pix/ComputeContextExtensions.cs
+++ b/src/ComputeSharp.Pix/ComputeContextExtensions.cs
@@ -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);
}
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The color to use for the event (the alpha channel will be ignored).
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -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 when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// 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 -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEventUnsafe(this in ComputeContext context, Color color, ReadOnlySpan 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);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The index to identify the group this event belongs to (PIX will choose a color to represent all entries in the group).
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -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 when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// 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 -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEventUnsafe(this in ComputeContext context, byte index, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ uint pixColor = Pix.PIX_COLOR_INDEX(index);
+
+ commandList.D3D12GraphicsCommandList->BeginEventUnsafe(pixColor, message);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -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 when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// 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 -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEventUnsafe(this in ComputeContext context, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ commandList.D3D12GraphicsCommandList->BeginEventUnsafe(0, message);
+ }
+
///
/// Ends a PIX event on a target object.
///
@@ -113,4 +196,86 @@ public static class ComputeContextExtensions
commandList.D3D12GraphicsCommandList->SetPixMarker(0, message);
}
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The color to use for the log (the alpha channel will be ignored).
+ /// The message to use for the marker (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -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 when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// 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 -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void LogUnsafe(this in ComputeContext context, Color color, ReadOnlySpan 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);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The index to identify the group this log belongs to (PIX will choose a color to represent all entries in the group).
+ /// The message to use for the marker (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -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 when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// 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 -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void LogUnsafe(this in ComputeContext context, byte index, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ uint pixColor = Pix.PIX_COLOR_INDEX(index);
+
+ commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(pixColor, message);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The message to use for the marker (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -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 when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// 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 -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void LogUnsafe(this in ComputeContext context, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(0, message);
+ }
}
diff --git a/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs b/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs
index 971bca2a..816128a2 100644
--- a/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs
+++ b/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs
@@ -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.Shared.Return(buffer);
}
+ ///
+ /// Begins a PIX event on a target object.
+ ///
+ /// The target object.
+ /// The color to use for the event.
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ public static unsafe void BeginEventUnsafe(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, ReadOnlySpan message)
+ {
+ fixed (byte* messagePtr = message)
+ {
+ Pix.PIXBeginEventOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)messagePtr);
+ }
+ }
+
///
/// Sets a PIX marker on a target object.
///
@@ -73,4 +88,18 @@ internal static class ID3D12GraphicsCommandListExtensions
// Return the buffer (if an exception is thrown, it's fine to not do so)
ArrayPool.Shared.Return(buffer);
}
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The target object.
+ /// The color to use for the marker.
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ public static unsafe void SetPixMarkerUnsafe(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, ReadOnlySpan message)
+ {
+ fixed (byte* messagePtr = message)
+ {
+ Pix.PIXSetMarkerOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)messagePtr);
+ }
+ }
}