カーネルの検証をTilePlanの関数に分ける

このコミットが含まれているのは:
routersys committed 2026-10-08 12:45:59 +09:00
1 親 0af60a0df3
コミット f770b2bfd6
3ファイル変更
+16 -2

検索条件に一致するファイルはありません

+9
ファイルの表示
@@ -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()
{
+1 -1
ファイルの表示
@@ -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)
+6 -1
ファイルの表示
@@ -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);