Switched indexers from uint to int
このコミットが含まれているのは:
1 親
332701c0fa
コミット
de42a9de7e
7ファイル変更
+15
-19
検索条件に一致するファイルはありません
@@ -66,21 +66,17 @@ namespace ComputeSharp.Benchmark
|
||||
int c, int n, int m, int p,
|
||||
ReadOnlyBuffer<float> x, ReadOnlyBuffer<float> w, ReadOnlyBuffer<float> b, ReadWriteBuffer<float> 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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the value to get</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else</remarks>
|
||||
public T this[uint i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer<T>)}<T>[uint i]");
|
||||
public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer<T>)}<T>[int i]");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GetData(Span<T> span, int offset, int count)
|
||||
|
||||
@@ -22,6 +22,6 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the value to get</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else</remarks>
|
||||
public T this[uint i] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyBuffer<T>)}<T>[uint i]");
|
||||
public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyBuffer<T>)}<T>[int i]");
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,6 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the value to get or set</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else</remarks>
|
||||
public ref T this[uint i] => throw new InvalidExecutionContextException($"{nameof(ReadWriteBuffer<T>)}<T>[uint i]");
|
||||
public ref T this[int i] => throw new InvalidExecutionContextException($"{nameof(ReadWriteBuffer<T>)}<T>[int i]");
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,16 @@
|
||||
/// <summary>
|
||||
/// The X id of the current thread
|
||||
/// </summary>
|
||||
public readonly uint X;
|
||||
public readonly int X;
|
||||
|
||||
/// <summary>
|
||||
/// The Y id of the current thread
|
||||
/// </summary>
|
||||
public readonly uint Y;
|
||||
public readonly int Y;
|
||||
|
||||
/// <summary>
|
||||
/// The Z id of the current thread
|
||||
/// </summary>
|
||||
public readonly uint Z;
|
||||
public readonly int Z;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする