diff --git a/samples/ComputeSharp.Benchmark/Dnn.cs b/samples/ComputeSharp.Benchmark/Dnn.cs index 58e6d2aa..34d6bd34 100644 --- a/samples/ComputeSharp.Benchmark/Dnn.cs +++ b/samples/ComputeSharp.Benchmark/Dnn.cs @@ -66,21 +66,17 @@ namespace ComputeSharp.Benchmark int c, int n, int m, int p, ReadOnlyBuffer x, ReadOnlyBuffer w, ReadOnlyBuffer b, ReadWriteBuffer y) { - uint u_n = (uint)n; - uint u_m = (uint)m; - uint u_p = (uint)p; - void Kernel(ThreadIds id) { - uint x_offset = id.X * u_n * u_p + id.Y * u_m; + int x_offset = id.X * n * p + id.Y * m; float result = 0f; - for (uint k = 0; k < u_m; k++) + for (int k = 0; k < m; k++) { - result += x[x_offset + k] * w[k * u_p + id.Z]; + result += x[x_offset + k] * w[k * p + id.Z]; } - y[id.X * u_n * u_p + id.Y * u_p + id.Z] = result + b[id.Z]; + y[id.X * n * p + id.Y * p + id.Z] = result + b[id.Z]; }; Gpu.Default.For(c, n, p, Kernel); diff --git a/samples/ComputeSharp.BokehBlur/Program.cs b/samples/ComputeSharp.BokehBlur/Program.cs index 52208139..20b6c0d5 100644 --- a/samples/ComputeSharp.BokehBlur/Program.cs +++ b/samples/ComputeSharp.BokehBlur/Program.cs @@ -93,8 +93,8 @@ namespace ComputeSharp.BokehBlur { for (int x = -Radius; x <= Radius; x++) { - int iy = (int)id.X + y; - int jx = (int)id.Y + x; + int iy = id.X + y; + int jx = id.Y + x; if (iy < 0) iy = -iy; else if (iy > height) iy = 2 * height - iy; @@ -104,11 +104,11 @@ namespace ComputeSharp.BokehBlur int ki = Radius - y; int kj = Radius - x; - total += image_gpu[(uint)(iy * width + jx)] * kernel_gpu[(uint)(ki * diameter + kj)]; + total += image_gpu[iy * width + jx] * kernel_gpu[ki * diameter + kj]; } } - result_gpu[(uint)(id.X * width + id.Y)] = total; + result_gpu[id.X * width + id.Y] = total; }); // Copy data back diff --git a/samples/ComputeSharp.Sample/Program.cs b/samples/ComputeSharp.Sample/Program.cs index 27ce5170..f54aabdf 100644 --- a/samples/ComputeSharp.Sample/Program.cs +++ b/samples/ComputeSharp.Sample/Program.cs @@ -30,7 +30,7 @@ namespace ComputeSharp.Sample // Run the shader Gpu.Default.For(100, id => { - uint offset = id.X + id.Y * (uint)width; + int offset = id.X + id.Y * width; gpuBuffer[offset] *= 2; }); diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs index f6b26f28..106ff3cf 100644 --- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs @@ -39,7 +39,7 @@ namespace ComputeSharp.Graphics.Buffers /// /// The index of the value to get /// This API can only be used from a compute shader, and will always throw if used anywhere else - public T this[uint i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer)}[uint i]"); + public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer)}[int i]"); /// public override void GetData(Span span, int offset, int count) diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs index d3ad9052..f4d936d6 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs @@ -22,6 +22,6 @@ namespace ComputeSharp.Graphics.Buffers /// /// The index of the value to get /// This API can only be used from a compute shader, and will always throw if used anywhere else - public T this[uint i] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyBuffer)}[uint i]"); + public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyBuffer)}[int i]"); } } diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs index 9e71a9c3..db4bee6d 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs @@ -22,6 +22,6 @@ namespace ComputeSharp.Graphics.Buffers /// /// The index of the value to get or set /// This API can only be used from a compute shader, and will always throw if used anywhere else - public ref T this[uint i] => throw new InvalidExecutionContextException($"{nameof(ReadWriteBuffer)}[uint i]"); + public ref T this[int i] => throw new InvalidExecutionContextException($"{nameof(ReadWriteBuffer)}[int i]"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs b/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs index 219f4ef9..aa0f8035 100644 --- a/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs +++ b/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs @@ -8,16 +8,16 @@ /// /// The X id of the current thread /// - public readonly uint X; + public readonly int X; /// /// The Y id of the current thread /// - public readonly uint Y; + public readonly int Y; /// /// The Z id of the current thread /// - public readonly uint Z; + public readonly int Z; } }