From b12c5501a8c124159553c3befc69164681e941ec Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 8 Mar 2021 13:09:15 +0100 Subject: [PATCH] Added unit test for GridIds class --- tests/ComputeSharp.Tests/DispatchTests.cs | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/ComputeSharp.Tests/DispatchTests.cs b/tests/ComputeSharp.Tests/DispatchTests.cs index a454c2e7..030adbbd 100644 --- a/tests/ComputeSharp.Tests/DispatchTests.cs +++ b/tests/ComputeSharp.Tests/DispatchTests.cs @@ -153,5 +153,32 @@ namespace ComputeSharp.Tests buffer[3] = GroupSize.Count; } } + + [CombinatorialTestMethod] + [AllDevices] + public void Verify_GridIds(Device device) + { + using ReadWriteBuffer buffer = device.Get().AllocateReadWriteBuffer(256); + + device.Get().For(256, 1, 1, 32, 1, 1, new GridIdsShader(buffer)); + + int[] data = buffer.ToArray(); + + for (int i = 0; i < data.Length; i++) + { + Assert.AreEqual(data[i], i / 32); + } + } + + [AutoConstructor] + internal readonly partial struct GridIdsShader : IComputeShader + { + public readonly ReadWriteBuffer buffer; + + public void Execute() + { + buffer[ThreadIds.X] = GridIds.X; + } + } } }