カーネルの検証をTilePlanの関数に分ける
このコミットが含まれているのは:
3ファイル変更
+16
-2
検索条件に一致するファイルはありません
@@ -146,6 +146,15 @@ public sealed class TilePlanTests
|
||||
Assert.Equal(plan.TileCount * expected, plan.GroupCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AKernelThatDoesNotFitTheTileIsRejected()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => TilePlan.ValidateKernel(64, 32));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => TilePlan.ValidateKernel(63, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => TilePlan.ValidateKernel(64, -1));
|
||||
TilePlan.ValidateKernel(64, 31);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheShadersHoldTwoValuesPerThreadInEveryGroup()
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ internal sealed class KernelSpectrum
|
||||
|
||||
public void Update(ReadOnlySpan<double> values, int radius, int size)
|
||||
{
|
||||
_ = TilePlan.Create(size, radius, 0, 0, 1, 1);
|
||||
TilePlan.ValidateKernel(size, radius);
|
||||
var kernelSize = radius * 2 + 1;
|
||||
var kernelArea = kernelSize * kernelSize;
|
||||
if (values.Length != kernelArea)
|
||||
|
||||
@@ -76,12 +76,17 @@ internal readonly record struct TilePlan
|
||||
public static TilePlan Create(int radius, int regionX, int regionY, int regionWidth, int regionHeight)
|
||||
=> Create(SelectSize(radius), radius, regionX, regionY, regionWidth, regionHeight);
|
||||
|
||||
public static TilePlan Create(int size, int radius, int regionX, int regionY, int regionWidth, int regionHeight)
|
||||
public static void ValidateKernel(int size, int radius)
|
||||
{
|
||||
if (!IsSupportedSize(size))
|
||||
throw new ArgumentOutOfRangeException(nameof(size));
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(radius);
|
||||
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(radius * 2, size);
|
||||
}
|
||||
|
||||
public static TilePlan Create(int size, int radius, int regionX, int regionY, int regionWidth, int regionHeight)
|
||||
{
|
||||
ValidateKernel(size, radius);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(regionWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(regionHeight);
|
||||
return new TilePlan(size, radius, regionX, regionY, regionWidth, regionHeight);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする