63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
using AcDream.App.Rendering.Packs;
|
|
using AcDream.Plugin.Abstractions.Rendering;
|
|
|
|
namespace AcDream.App.Tests.Rendering.Packs;
|
|
|
|
public sealed class AtmosphericGpuTimerSamplingTests
|
|
{
|
|
[Fact]
|
|
public void LowMeasuresOneCompleteFrameInFour()
|
|
{
|
|
bool[] measured = Enumerable.Range(1, 12)
|
|
.Select(frame => AtmosphericGpuTimerSampling.ShouldMeasure(
|
|
RenderQualitySemantic.Low,
|
|
frame))
|
|
.ToArray();
|
|
|
|
Assert.Equal(
|
|
[false, false, false, true, false, false, false, true, false, false, false, true],
|
|
measured);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(RenderQualitySemantic.Medium)]
|
|
[InlineData(RenderQualitySemantic.High)]
|
|
public void OtherQualitiesMeasureEveryFrame(RenderQualitySemantic quality)
|
|
{
|
|
for (long frame = 1; frame <= 32; frame++)
|
|
Assert.True(AtmosphericGpuTimerSampling.ShouldMeasure(quality, frame));
|
|
}
|
|
|
|
[Fact]
|
|
public void RejectsNonPositiveFrameSerial()
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
|
AtmosphericGpuTimerSampling.ShouldMeasure(
|
|
RenderQualitySemantic.Low,
|
|
frameSerial: 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void WarmSamplingDecisionsAllocateZero()
|
|
{
|
|
_ = AtmosphericGpuTimerSampling.ShouldMeasure(
|
|
RenderQualitySemantic.Low,
|
|
frameSerial: 1);
|
|
|
|
int measured = 0;
|
|
long before = GC.GetAllocatedBytesForCurrentThread();
|
|
for (long frame = 1; frame <= 10_000; frame++)
|
|
{
|
|
if (AtmosphericGpuTimerSampling.ShouldMeasure(
|
|
RenderQualitySemantic.Low,
|
|
frame))
|
|
{
|
|
measured++;
|
|
}
|
|
}
|
|
long allocated = GC.GetAllocatedBytesForCurrentThread() - before;
|
|
|
|
Assert.Equal(2_500, measured);
|
|
Assert.Equal(0, allocated);
|
|
}
|
|
}
|