acdream/tests/AcDream.App.Tests/Rendering/Packs/RenderPackResidentBudgetTests.cs
Erik 132395e6f7 fix #425: pack resident budget is a 1080p ceiling that scales with pixel count; an explicit Apply retries a failed selection
Live Holtburg at 2560x1440: the Low preset needed 67,368,164 resident bytes
(screen-sized HDR/depth/ray targets are 44 MB of that) against an absolute
64 MiB ceiling that had only been validated at 1080p, so Options -> Apply
fell back to the default path; every later Apply was then refused by the
controller's failure memo, which treated the user's deliberate choice like
automatic re-activation.

RenderPackResidentBudget.Effective scales the declared 1080p figure by the
viewport's pixel-count ratio (never below 1), still capped by the hardware
MaxPackResidentBytes; both pack graphs use it and the performance-matrix
tool judges its resident column by the same rule (contract test updated).
RenderPackController.Request gains explicitUserChoice, which clears the
memo for that selection; RenderPackSelectionBinding passes it on every
display edge (Apply, including resolution changes) and keeps the memo for
the startup request.

Tests: RenderPackResidentBudgetTests (1080p/720p keep the declared
ceiling, 1440p = 16/9x, 4K = 4x, hardware cap wins, zero extent rejected);
controller explicit-retry; the binding test now proves the user's next
Apply activates once the cause is gone. App hermetic lane 6,068/0 (Release).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 10:00:11 +02:00

51 lines
1.8 KiB
C#

using AcDream.App.Rendering.Packs;
namespace AcDream.App.Tests.Rendering.Packs;
public sealed class RenderPackResidentBudgetTests
{
private const long LowAt1080p = 64L * 1024 * 1024;
private const long Unlimited = long.MaxValue;
[Theory]
[InlineData(1920, 1080, LowAt1080p)]
[InlineData(1280, 720, LowAt1080p)] // smaller than the reference keeps the declared ceiling
[InlineData(1600, 900, LowAt1080p)]
public void AtOrBelowTheReferenceResolutionTheDeclaredCeilingApplies(int width, int height, long expected)
{
Assert.Equal(expected, RenderPackResidentBudget.Effective(LowAt1080p, width, height, Unlimited));
}
[Fact]
public void At1440pTheCeilingScalesByPixelCount()
{
// 2560x1440 / 1920x1080 = 16/9 ≈ 1.777…; #425's live Holtburg Low
// preset needed 67,368,164 bytes, which the scaled ceiling admits.
long effective = RenderPackResidentBudget.Effective(LowAt1080p, 2560, 1440, Unlimited);
Assert.Equal((long)Math.Ceiling(LowAt1080p * 16.0 / 9.0), effective);
Assert.True(effective >= 67_368_164L);
}
[Fact]
public void At4KTheCeilingIsFourTimesTheDeclaredFigure()
{
Assert.Equal(4L * LowAt1080p, RenderPackResidentBudget.Effective(LowAt1080p, 3840, 2160, Unlimited));
}
[Fact]
public void TheHardwareCapStillWins()
{
Assert.Equal(
100_000_000L,
RenderPackResidentBudget.Effective(LowAt1080p, 3840, 2160, hardwareCapBytes: 100_000_000L));
}
[Theory]
[InlineData(0, 1080)]
[InlineData(1920, 0)]
public void AZeroExtentIsRejected(int width, int height)
{
Assert.Throws<ArgumentOutOfRangeException>(
() => RenderPackResidentBudget.Effective(LowAt1080p, width, height, Unlimited));
}
}