feat(render): implement Campaign AR and terrain fidelity

This commit is contained in:
Erik 2026-08-22 13:13:29 +02:00
parent 99cf26e00c
commit 7a5f96ede5
368 changed files with 50611 additions and 950 deletions

View file

@ -140,6 +140,20 @@ public sealed class RecordingGpuDeviceTests
Assert.Equal(0, device.OpenFrameCount);
}
[Fact]
public void TimerMeasurementsCanBeInspectedOrConsumedExactlyOnce()
{
using RecordingGpuDevice device = new();
device.RecordingTimers.SetResolved("pack-pass", 1.25);
Assert.True(device.Timers.TryResolve("pack-pass", out double inspected));
Assert.Equal(1.25, inspected);
Assert.True(device.Timers.TryTakeResolved("pack-pass", out double consumed));
Assert.Equal(1.25, consumed);
Assert.False(device.Timers.TryTakeResolved("pack-pass", out _));
Assert.False(device.Timers.TryResolve("pack-pass", out _));
}
[Fact]
public void ReleasedTextureSlotsAreRecycledRatherThanLeaked()
{
@ -177,6 +191,98 @@ public sealed class RecordingGpuDeviceTests
Assert.True(device.DefaultTextureSlot.IsAssigned);
}
[Fact]
public void MultisampledHdrTargetExposesSingleSampledColorAndOptionalDepthResults()
{
using RecordingGpuDevice device = new();
device.Clear();
var description = new GpuRenderTargetDescription(
"hdr-world",
1920,
1080,
GpuTextureFormat.Rgba16FloatRenderTarget,
GpuTextureFormat.Depth24Stencil8,
SampleCount: 4,
SampleableDepth: true);
var target = Assert.IsType<RecordingGpuRenderTarget>(
device.CreateRenderTarget(description));
Assert.Equal(description, target.Description);
Assert.Equal(GpuTextureFormat.Rgba16FloatRenderTarget, target.ColorTexture.Format);
Assert.NotNull(target.DepthTexture);
Assert.Equal(GpuTextureFormat.Depth24Stencil8, target.DepthTexture!.Format);
Assert.Equal(4, target.AttachmentSampleCount);
Assert.True(target.UsesMultisampleResolve);
Assert.Same(target, Assert.Single(device.CreatedRenderTargets));
Assert.Equal(
new GpuRecordedRenderTargetCreate(description),
Assert.Single(device.Calls));
using IGpuFrame frame = device.BeginFrame();
using (frame.BeginPass(new GpuPassDescription
{
Name = "hdr-world",
Color = new GpuColorAttachment(
target,
GpuLoadOp.Clear,
GpuStoreOp.Resolve,
Vector4.Zero),
Depth = new GpuDepthAttachment(
GpuLoadOp.Clear,
GpuStoreOp.Store,
1f,
0),
SampleCount = 4,
}))
{
}
frame.End();
target.Dispose();
Assert.True(target.IsDisposed);
Assert.True(Assert.IsType<RecordingGpuTexture>(target.ColorTexture).IsDisposed);
Assert.True(Assert.IsType<RecordingGpuTexture>(target.DepthTexture).IsDisposed);
}
[Fact]
public void AttachmentOnlyDepthIsNotExposedAndInvalidResolveContractsFailLoudly()
{
using RecordingGpuDevice device = new();
var target = Assert.IsType<RecordingGpuRenderTarget>(
device.CreateRenderTarget(new GpuRenderTargetDescription(
"ordinary-offscreen",
320,
240,
GpuTextureFormat.Rgba8UnormRenderTarget,
GpuTextureFormat.Depth24Stencil8,
SampleCount: 1)));
Assert.Null(target.DepthTexture);
using IGpuFrame frame = device.BeginFrame();
Assert.Throws<InvalidOperationException>(() => frame.BeginPass(new GpuPassDescription
{
Name = "invalid-resolve",
Color = new GpuColorAttachment(
target,
GpuLoadOp.Clear,
GpuStoreOp.Resolve,
Vector4.Zero),
SampleCount = 1,
}));
frame.End();
Assert.Throws<ArgumentException>(() => device.CreateRenderTarget(
new GpuRenderTargetDescription(
"missing-depth",
16,
16,
GpuTextureFormat.Rgba16FloatRenderTarget,
DepthFormat: null,
SampleCount: 1,
SampleableDepth: true)));
}
[Fact]
public void SamplersAreDeduplicatedByValue()
{