feat(render): implement Campaign AR and terrain fidelity
This commit is contained in:
parent
99cf26e00c
commit
7a5f96ede5
368 changed files with 50611 additions and 950 deletions
|
|
@ -0,0 +1,75 @@
|
|||
using AcDream.App.Rendering;
|
||||
|
||||
namespace AcDream.App.Tests.Rendering.Wb;
|
||||
|
||||
public sealed class DirectionalShadowTerrainPreparedDrawTests
|
||||
{
|
||||
[Fact]
|
||||
public void Product_ContainsEveryResidentRangeWithoutVisibilityClassification()
|
||||
{
|
||||
var product = new DirectionalShadowTerrainPreparedDraws();
|
||||
Assert.True(product.TryBegin(frameSequence: 10, estimatedCommands: 3));
|
||||
DirectionalShadowTerrainRange[] resident =
|
||||
[
|
||||
new(FirstIndex: 0, IndexCount: 384),
|
||||
new(FirstIndex: 384, IndexCount: 384),
|
||||
new(FirstIndex: 768, IndexCount: 384),
|
||||
];
|
||||
foreach (DirectionalShadowTerrainRange range in resident)
|
||||
product.Add(in range);
|
||||
|
||||
product.Complete(frameSequence: 10);
|
||||
|
||||
Assert.Equal(3, product.Commands.Length);
|
||||
Assert.Equal(0u, product.Commands[0].FirstIndex);
|
||||
Assert.Equal(384u, product.Commands[1].FirstIndex);
|
||||
Assert.Equal(768u, product.Commands[2].FirstIndex);
|
||||
Assert.All(
|
||||
product.Commands.ToArray(),
|
||||
static command =>
|
||||
{
|
||||
Assert.Equal(384u, command.Count);
|
||||
Assert.Equal(1u, command.InstanceCount);
|
||||
Assert.Equal(0, command.BaseVertex);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SameFrame_AllCascadesReuseOneTerrainBuild()
|
||||
{
|
||||
var product = new DirectionalShadowTerrainPreparedDraws();
|
||||
Assert.True(product.TryBegin(frameSequence: 1, estimatedCommands: 1));
|
||||
var range = new DirectionalShadowTerrainRange(100, 24);
|
||||
product.Add(in range);
|
||||
product.Complete(frameSequence: 1);
|
||||
long retained = product.RetainedScratchBytes;
|
||||
|
||||
Assert.False(product.TryBegin(frameSequence: 1, estimatedCommands: 500));
|
||||
|
||||
Assert.Equal(1ul, product.BuildSequence);
|
||||
Assert.Equal(retained, product.RetainedScratchBytes);
|
||||
Assert.Single(product.Commands.ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NextFrame_RebuildsIntoRetainedStorage()
|
||||
{
|
||||
var product = new DirectionalShadowTerrainPreparedDraws();
|
||||
Assert.True(product.TryBegin(frameSequence: 1, estimatedCommands: 2));
|
||||
var first = new DirectionalShadowTerrainRange(10, 3);
|
||||
var second = new DirectionalShadowTerrainRange(20, 6);
|
||||
product.Add(in first);
|
||||
product.Add(in second);
|
||||
product.Complete(frameSequence: 1);
|
||||
long retained = product.RetainedScratchBytes;
|
||||
|
||||
Assert.True(product.TryBegin(frameSequence: 2, estimatedCommands: 1));
|
||||
product.Add(in second);
|
||||
product.Complete(frameSequence: 2);
|
||||
|
||||
Assert.Equal(2ul, product.BuildSequence);
|
||||
Assert.Equal(retained, product.RetainedScratchBytes);
|
||||
Assert.Single(product.Commands.ToArray());
|
||||
Assert.Equal(20u, product.Commands[0].FirstIndex);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue