From 903c5504c6792efd7d4fb5a37b6b976d968cd9fb Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 18 Jun 2022 12:57:55 +0200 Subject: [PATCH] Port PIX color helpers from pix3.h file --- src/ComputeSharp.Pix/Interop/Pix.cs | 2 +- src/ComputeSharp.Pix/Interop/Pix.h.cs | 43 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/ComputeSharp.Pix/Interop/Pix.h.cs diff --git a/src/ComputeSharp.Pix/Interop/Pix.cs b/src/ComputeSharp.Pix/Interop/Pix.cs index ca2bb7fc..cc6ee0bf 100644 --- a/src/ComputeSharp.Pix/Interop/Pix.cs +++ b/src/ComputeSharp.Pix/Interop/Pix.cs @@ -6,7 +6,7 @@ namespace ComputeSharp.Interop; /// /// A collection of native bindings for PIX APIs (see ). /// -internal static unsafe class Pix +internal static unsafe partial class Pix { /// /// Starts a PIX event on a target object. diff --git a/src/ComputeSharp.Pix/Interop/Pix.h.cs b/src/ComputeSharp.Pix/Interop/Pix.h.cs new file mode 100644 index 00000000..3cca15bd --- /dev/null +++ b/src/ComputeSharp.Pix/Interop/Pix.h.cs @@ -0,0 +1,43 @@ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: pix3.h + * Content: PIX include file + * + ****************************************************************************/ + +// The following methods in this file have been ported from the +// pix3.h file in the winpixeventruntime.1.0.220124001 package. + +using System.Runtime.CompilerServices; + +namespace ComputeSharp.Interop; + +/// +partial class Pix +{ + /// + /// Gets a value representing a color for a PIX event. + /// + /// The red channel value for the color. + /// The green channel value for the color. + /// The blue channel value for the color. + /// A value representing a color for a PIX event. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint PIX_COLOR(byte r, byte g, byte b) + { + return 0xFF000000 | ((uint)r << 16) | ((uint)g << 8) | b; + } + + /// + /// Gets a value representing an indexed color for a PIX event. + /// + /// The index of the event to get the color for. + /// A value representing an indexed color for a PIX event. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint PIX_COLOR_INDEX(byte i) + { + return i; + } +}