diff --git a/src/ComputeSharp.Core/Attributes/PreserveMemberNameAttribute.cs b/src/ComputeSharp.Core/Attributes/PreserveMemberNameAttribute.cs new file mode 100644 index 00000000..6140a4d2 --- /dev/null +++ b/src/ComputeSharp.Core/Attributes/PreserveMemberNameAttribute.cs @@ -0,0 +1,11 @@ +using System; + +namespace ComputeSharp.Core.Attributes +{ + /// + /// An attribute to indicate that a given member has the same name when mapped to HLSL + /// + internal sealed class PreserveMemberNameAttribute : Attribute + { + } +} diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs index 365fbf5c..ef489415 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs @@ -1,5 +1,6 @@ using System.Diagnostics.Contracts; using System.Numerics; +using ComputeSharp.Core.Attributes; using ComputeSharp.Exceptions; namespace ComputeSharp @@ -1383,6 +1384,206 @@ namespace ComputeSharp [Pure] public static Vector4 Frexp(Vector4 x, out Vector4 exp) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(Frexp)}({nameof(Vector4)},{nameof(Vector4)})"); + /// + /// Performs a guaranteed atomic add of a value to a destination. + /// + /// The destination value. + /// The input value + [PreserveMemberName] + public static void InterlockedAdd(int destination, int value) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAdd)}(int,int)"); + + /// + /// Performs a guaranteed atomic add of a value to a destination. + /// + /// The destination value. + /// The input value + [PreserveMemberName] + public static void InterlockedAdd(uint destination, uint value) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAdd)}(uint,uint)"); + + /// + /// Performs a guaranteed atomic add of a value to a destination. + /// + /// The destination value. + /// The input value + /// The original input value + [PreserveMemberName] + public static void InterlockedAdd(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAdd)}(int,int,int)"); + + /// + /// Performs a guaranteed atomic add of a value to a destination. + /// + /// The destination value. + /// The input value + /// The original input value + [PreserveMemberName] + public static void InterlockedAdd(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAdd)}(uint,uint,uint)"); + + /// + /// Performs a guaranteed atomic and of a value to a destination. + /// + /// The destination value. + /// The input value + [PreserveMemberName] + public static void InterlockedAnd(int destination, int value) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAnd)}(int,int)"); + + /// + /// Performs a guaranteed atomic and of a value to a destination. + /// + /// The destination value. + /// The input value + [PreserveMemberName] + public static void InterlockedAnd(uint destination, uint value) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAnd)}(uint,uint)"); + + /// + /// Performs a guaranteed atomic and of a value to a destination. + /// + /// The destination value. + /// The input value + /// The original input value + [PreserveMemberName] + public static void InterlockedAnd(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAnd)}(int,int,int)"); + + /// + /// Performs a guaranteed atomic and of a value to a destination. + /// + /// The destination value. + /// The input value + /// The original input value + [PreserveMemberName] + public static void InterlockedAnd(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedAnd)}(uint,uint,uint)"); + + /// + /// Atomically compares the destination with the comparison value. If they are identical, the destination + /// is overwritten with the input value. The original value is set to the destination's original value. + /// + /// The destination value. + /// The comparison value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedCompareExchange(int destination, int comparison, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedCompareExchange)}(int,int,int,int)"); + + /// + /// Atomically compares the destination with the comparison value. If they are identical, the destination + /// is overwritten with the input value. The original value is set to the destination's original value. + /// + /// The destination value. + /// The comparison value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedCompareExchange(uint destination, uint comparison, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedCompareExchange)}(uint,uint,uint,uint)"); + + /// + /// Atomically compares the destination to the comparison value. If they + /// are identical, the destination is overwritten with the input value. + /// + /// The destination value. + /// The comparison value. + /// The input value. + [PreserveMemberName] + public static void InterlockedCompareStore(int destination, int comparison, int value) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedCompareStore)}(int,int,int)"); + + /// + /// Atomically compares the destination to the comparison value. If they + /// are identical, the destination is overwritten with the input value. + /// + /// The destination value. + /// The comparison value. + /// The input value. + [PreserveMemberName] + public static void InterlockedCompareStore(uint destination, uint comparison, uint value) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedCompareStore)}(uint,uint,uint)"); + + /// + /// Assigns value to dest and returns the original value. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedExchange(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedExchange)}(int,int,int)"); + + /// + /// Assigns value to dest and returns the original value. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedExchange(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedExchange)}(uint,uint,uint)"); + + /// + /// Performs a guaranteed atomic max. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedMax(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedMax)}(int,int,int)"); + + /// + /// Performs a guaranteed atomic max. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedMax(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedMax)}(uint,uint,uint)"); + + /// + /// Performs a guaranteed atomic min. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedMin(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedMin)}(int,int,int)"); + + /// + /// Performs a guaranteed atomic min. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedMin(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedMin)}(uint,uint,uint)"); + + /// + /// Performs a guaranteed atomic or. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedOr(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedOr)}(int,int,int)"); + + /// + /// Performs a guaranteed atomic or. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedOr(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedOr)}(uint,uint,uint)"); + + /// + /// Performs a guaranteed atomic xor. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedXor(int destination, int value, out int original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedXor)}(int,int,int)"); + + /// + /// Performs a guaranteed atomic xor. + /// + /// The destination value. + /// The input value. + /// The original value. + [PreserveMemberName] + public static void InterlockedXor(uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(InterlockedXor)}(uint,uint,uint)"); + /// /// Determines if the specified floating-point value is finite ///