試験とハーネスのコメントを外して名前で表す
このコミットが含まれているのは:
4ファイル変更
+13
-21
検索条件に一致するファイルはありません
@@ -85,9 +85,6 @@ internal sealed class ConvolutionScene
|
||||
return new ConvolutionScene(source, margin, margin, sourceWidth, sourceHeight, spectrum, plan, light);
|
||||
}
|
||||
|
||||
// The region starts at (regionX, regionY) of the canvas, and the source lies inside it at (sourceX, sourceY).
|
||||
// The helpers that compare with the exact correlation assume a region at the origin, so a scene made
|
||||
// here is only for comparing two implementations with each other.
|
||||
public static ConvolutionScene CreateShifted(
|
||||
byte[] source, int sourceX, int sourceY, int sourceWidth, int sourceHeight,
|
||||
int regionX, int regionY, int regionWidth, int regionHeight, int radius, int size, LightOptions light = default)
|
||||
|
||||
@@ -362,10 +362,12 @@ public sealed class GpuTileConvolverTests
|
||||
Assert.All(Measure(scene, run), measurement => Assert.True(measurement.Passes, $"{measurement}"));
|
||||
}
|
||||
|
||||
const int OutputValuesPerToleratedRoundingFlip = 2000;
|
||||
|
||||
static void AssertOutputIsTheTransformOfTheStore(ConvolutionScene scene, GpuRun run, float gain, LightOptions light)
|
||||
{
|
||||
var width = scene.Plan.RegionWidth;
|
||||
var differing = 0;
|
||||
var roundingFlips = 0;
|
||||
for (var y = 0; y < scene.Plan.RegionHeight; y++)
|
||||
{
|
||||
for (var x = 0; x < width; x++)
|
||||
@@ -376,15 +378,12 @@ public sealed class GpuTileConvolverTests
|
||||
Assert.InRange(run.Output[index + 1] - expected.Green, -1, 1);
|
||||
Assert.InRange(run.Output[index + 2] - expected.Red, -1, 1);
|
||||
Assert.InRange(run.Output[index + 3] - expected.Alpha, -1, 1);
|
||||
differing += (run.Output[index] != expected.Blue ? 1 : 0) + (run.Output[index + 1] != expected.Green ? 1 : 0)
|
||||
roundingFlips += (run.Output[index] != expected.Blue ? 1 : 0) + (run.Output[index + 1] != expected.Green ? 1 : 0)
|
||||
+ (run.Output[index + 2] != expected.Red ? 1 : 0) + (run.Output[index + 3] != expected.Alpha ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
// The power function of the GPU differs from the table of the CPU by a few millionths, which moves the
|
||||
// rounded value by one step in a few of ten thousand places. A wrong threshold or a wrong rounding
|
||||
// moves it in about a third of them.
|
||||
Assert.InRange(differing, 0, run.Output.Length / 2000);
|
||||
Assert.InRange(roundingFlips, 0, run.Output.Length / OutputValuesPerToleratedRoundingFlip);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -249,11 +249,11 @@ static int Convolution(HarnessImage image)
|
||||
return subject;
|
||||
}
|
||||
|
||||
void Measure(string title, Func<(string Name, Action<bool> Run)[]> create)
|
||||
void MeasureSet(string title, Func<(string Name, Action<bool> Run)[]> createOwnedSubjects)
|
||||
{
|
||||
try
|
||||
{
|
||||
var variants = create();
|
||||
var variants = createOwnedSubjects();
|
||||
var samples = new List<double>[variants.Length];
|
||||
for (var index = 0; index < samples.Length; index++)
|
||||
samples[index] = new List<double>(Rounds);
|
||||
@@ -303,9 +303,7 @@ static int Convolution(HarnessImage image)
|
||||
|
||||
Console.WriteLine($"convolution recompute at {image.Width}x{image.Height} over {Rounds} interleaved rounds (ms)");
|
||||
|
||||
// Each set owns its pipelines while it runs. Keeping the pipelines of the other set alive would
|
||||
// change the memory the GPU has left and slow every row down.
|
||||
Measure("default options", () =>
|
||||
MeasureSet("default options", () =>
|
||||
{
|
||||
var cached = Gpu();
|
||||
var gain = Gpu();
|
||||
@@ -336,7 +334,7 @@ static int Convolution(HarnessImage image)
|
||||
|
||||
var linearLight = new SpectralConvolution.LightOptions(true, false, 0f, 0f);
|
||||
var highlightLight = new SpectralConvolution.LightOptions(true, false, 0.7f, 30f);
|
||||
Measure("light options", () =>
|
||||
MeasureSet("light options", () =>
|
||||
{
|
||||
var source = Gpu();
|
||||
var checkedSource = Gpu(true);
|
||||
|
||||
@@ -345,12 +345,10 @@ public sealed class WaveOpticsLightTests
|
||||
var dithered = parameters with { Light = new LightOptions(false, true, 0f, 0f) };
|
||||
|
||||
var reference = Total(source);
|
||||
var plain = Total(RenderCpu(source, Size, Size, in parameters)) / reference;
|
||||
var kept = Total(RenderCpu(source, Size, Size, in dithered)) / reference;
|
||||
var retainedWithoutDither = Total(RenderCpu(source, Size, Size, in parameters)) / reference;
|
||||
var retainedWithDither = Total(RenderCpu(source, Size, Size, in dithered)) / reference;
|
||||
|
||||
// Each rounding error is about 0.3 of a level, and the sum of the 40000 errors is a few percent of
|
||||
// the light of the spot at most. Without dithering, the faint tails are rounded down to nothing.
|
||||
Assert.InRange(plain, 0.88, 0.97);
|
||||
Assert.InRange(kept, 0.97, 1.03);
|
||||
Assert.InRange(retainedWithoutDither, 0.88, 0.97);
|
||||
Assert.InRange(retainedWithDither, 0.97, 1.03);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする