diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj index 3167bf64..a436e08f 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj +++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj @@ -22,6 +22,7 @@ + diff --git a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs index ebb3db4a..1d7f8ece 100644 --- a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs @@ -279,4 +279,32 @@ public partial class ShaderRewriterTests buffer2[7] = exponentUppercaseField; } } + + [CombinatorialTestMethod] + [AllDevices] + public void InterlockedOperations(Device device) + { + using ReadWriteBuffer buffer = device.Get().AllocateReadWriteBuffer(16); + + device.Get().For(16, new InterlockedOperationsShader(buffer)); + + int[] result = buffer.ToArray(); + + for (int i = 0; i < result.Length; i++) + { + Assert.AreEqual(i, result[i]); + } + } + + [AutoConstructor] + [EmbeddedBytecode(DispatchAxis.X)] + internal readonly partial struct InterlockedOperationsShader : IComputeShader + { + public readonly ReadWriteBuffer buffer; + + public void Execute() + { + Hlsl.InterlockedAdd(buffer[ThreadIds.X], ThreadIds.X); + } + } }