Add fractal reservoir render contract

This commit is contained in:
Meta Vens 2026-05-20 01:29:51 +01:00
commit f4934aa247
4 changed files with 61 additions and 0 deletions

View file

@ -426,6 +426,28 @@ public sealed class AquariumTemporalGaussianField
public float PresentationDelaySeconds { get; init; }
}
public sealed class AquariumFractalReservoirField
{
public static AquariumFractalReservoirField Empty { get; } = new();
public int SplatCount { get; init; }
public int Depth { get; init; } = 8;
public uint Seed { get; init; } = 0xA17EA11u;
public int CandidatesPerReservoirUpdate { get; init; } = 2;
public int ReservoirUpdatesPerPass { get; init; }
public bool HasInput =>
SplatCount > 0 &&
Depth > 0 &&
CandidatesPerReservoirUpdate > 0 &&
ReservoirUpdatesPerPass > 0 &&
ReservoirUpdatesPerPass <= SplatCount;
}
public sealed class AquariumSceneState
{
public static AquariumSceneState Empty { get; } = new();
@ -442,6 +464,8 @@ public sealed class AquariumSceneState
public AquariumTemporalGaussianField TemporalGaussianField { get; init; } = AquariumTemporalGaussianField.Empty;
public AquariumFractalReservoirField FractalReservoirField { get; init; } = AquariumFractalReservoirField.Empty;
public AquariumGpuSensorFrame GpuSensorFrame { get; init; } = AquariumGpuSensorFrame.Empty;
public AquariumAcousticFieldFrame AcousticFieldFrame { get; init; } = AquariumAcousticFieldFrame.Empty;

View file

@ -178,3 +178,4 @@
{"timestamp":"2026-05-19T21:03:19+00:00","topic":"gpu-resident-fractal-splat-receipt","lesson":"The first honest performance receipt is GPU-resident compute, not CPU object population. `tools/Aquarium.Fractal.Receipt` allocates an 80-byte packed `AquariumPackedFractalSdfSplat3D` UAV, populates it entirely in a D3D12 compute shader, measures GPU timestamp queries, and reads back only 64 splats for checksum. On the local NVIDIA GTX 1070, `2,000,000` splats over `120` measured frames ran at `3.362 ms/frame`, `297.5 FPS` equivalent, and about `594.9M` splats/sec. This proves compute-side population throughput; final shaded rendering still has to consume the packed buffer.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Fractal/Lod/FractalNativeBuffer.cs","tests/Aquarium.Engine.Fractal.Tests/FractalNativeBufferTests.cs","tools/Aquarium.Fractal.Receipt/Aquarium.Fractal.Receipt.csproj","tools/Aquarium.Fractal.Receipt/Program.cs","scripts/fractal-splat-receipt.ps1","docs/perfect-machine-architecture.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json","state/map.yaml"],"source":"user demanded a receipt showing millions of splats at hundreds of FPS and rejected CPU-resident architecture"}
{"timestamp":"2026-05-19T21:29:26+00:00","topic":"gpu-resident-layered-reservoir-receipt","lesson":"The layered temporal cache is not one generic reservoir with a layer enum. SDF envelope splats, PBR material splats, and radiosity splats are three different sampled measures, so the GPU receipt now uses three distinct 64-byte reservoir packet types and three independent compute passes. Full rewrites of all three 2,000,000-entry reservoir layers every frame missed the target on the GTX 1070; the coherent architecture is stochastic budgeted refresh over resident reservoirs. With 50,000 updates per reservoir layer per frame, 2 candidates/update, and 2,000,000 resident splats/reservoirs, the receipt measured 4.471 ms/frame and 223.7 FPS equivalent over 120 frames, with full reservoir coverage in 40 frames.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","tests/Aquarium.Engine.Fractal.Tests/FractalSdfSplat3DContractTests.cs","tools/Aquarium.Fractal.Receipt/Program.cs","scripts/fractal-splat-receipt.ps1","docs/perfect-machine-architecture.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json","state/map.yaml"],"source":"user corrected that SDF splats, PBR splats, and radiosity splats are sampled independently in different shader passes"}
{"timestamp":"2026-05-20T01:24:49+01:00","topic":"fractal-reservoir-shader-asset","lesson":"The fractal GPU reservoir compute path must live as an engine shader asset, not as embedded receipt-tool text. `src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl` now owns the splat population pass plus the independent SDF envelope, PBR material, and radiosity reservoir update passes. `tools/Aquarium.Fractal.Receipt` compiles that shader file directly, keeping the receipt and future renderer pass on one source of truth.","files":["src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","tools/Aquarium.Fractal.Receipt/Program.cs","state/map.yaml"],"source":"continued Perfect Machine build after the GPU receipt proved the pass should become reusable renderer architecture"}
{"timestamp":"2026-05-20T01:31:00+01:00","topic":"fractal-reservoir-render-contract","lesson":"The render contract now exposes `AquariumFractalReservoirField` on `AquariumSceneState`: clients request a GPU-resident fractal reservoir field by resident splat count, depth, seed, reservoir candidates/update, and updates/pass. This keeps million-instance splat population inside GPU compute instead of making clients publish CPU splat lists.","files":["src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","tests/Aquarium.Engine.Fractal.Tests/FractalReservoirFieldContractTests.cs","state/map.yaml"],"source":"continued Perfect Machine build: the shared shader needed a client-to-renderer contract surface"}

View file

@ -138,6 +138,7 @@ renderer_state:
- Compact 3D SDF splats now have a stable fractal contract and CPU compiler/kernel: structural FractalProbeSample evidence can lower into AquariumFractalSdfSplat3D packets with compact shaped support before GPU rendering exists.
- Hot fractal splats and their temporal cache layers must be GPU-resident packed buffers. AquariumPackedFractalSdfSplat3D is the 80-byte numeric splat packet; the SDF envelope, PBR material, and radiosity reservoir packets are distinct 64-byte UAV rows sampled in independent compute passes. tools/Aquarium.Fractal.Receipt proves a D3D12 compute path can keep 2,000,000 splats and 2,000,000 reservoirs per layer resident on the GTX 1070, update 50,000 entries per reservoir layer per frame with 2 candidates/update, and run at 4.471 ms/frame, 223.7 FPS equivalent, with only tiny checksum readback. The receipt now compiles the shared engine shader asset src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl instead of carrying private embedded shader text.
- 2D-projected-to-3D splats have a pure compiler seam: FractalProjectedSdfSplatCompiler maps resident SignedDistance2D page payload samples through an explicit page-to-world function and normal into bounded AquariumFractalSdfSplat3D packets.
- AquariumSceneState now carries AquariumFractalReservoirField as the narrow client-to-renderer request for GPU-resident fractal reservoirs: resident splat count, IFS depth/seed, candidates per reservoir update, and stochastic updates per pass. This is a budgeted GPU field request, not a CPU splat list.
- The consolidated fractal brush architecture plan defines the intended pipeline: client intent -> domain roots -> semantic IFS brush grammar -> ownership tree -> node summaries -> contribution cache/residency scheduler -> backend packets -> renderer passes -> debug/evidence, with explicit module boundaries and mockable unit-test seams.
- The Perfect Machine architecture lives in docs/perfect-machine-architecture.md. It is the current waterfall design authority for fast 2D SDF splats, 3D SDF splats, 2D-projected-to-3D surface splats, IFS `.aquageo` structural probes, Mimir-style camera/audio evidence candidates, ReSTIR/GRIS reservoir reuse, heuristic occupancy graph updates, resource-tier residency, and TAA guide-buffer integration.
- Fractal surface page planning now has a CPU boundary: FractalSurfacePagePlanner lowers selected IFS cuts into stable height, 2D signed-distance, material, and confidence page metadata; ZyphosFractalRenderPlan exposes these pages, while the live D3D12 page store and atlas remain future work.

View file

@ -0,0 +1,35 @@
using Aquarium.Engine.Render;
namespace Aquarium.Engine.Fractal.Tests;
public sealed class FractalReservoirFieldContractTests
{
[Fact]
public void SceneStateCarriesFractalReservoirFieldRequest()
{
var field = new AquariumFractalReservoirField
{
SplatCount = 2_000_000,
ReservoirUpdatesPerPass = 50_000,
};
var scene = new AquariumSceneState
{
FractalReservoirField = field,
};
Assert.True(scene.FractalReservoirField.HasInput);
Assert.Equal(8, scene.FractalReservoirField.Depth);
Assert.Equal(2, scene.FractalReservoirField.CandidatesPerReservoirUpdate);
Assert.Equal(0xA17EA11u, scene.FractalReservoirField.Seed);
}
[Fact]
public void FractalReservoirFieldRejectsNonConvergingUpdateBudgets()
{
Assert.False(AquariumFractalReservoirField.Empty.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, ReservoirUpdatesPerPass = 0 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, ReservoirUpdatesPerPass = 17 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, ReservoirUpdatesPerPass = 4, CandidatesPerReservoirUpdate = 0 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, ReservoirUpdatesPerPass = 4, Depth = 0 }.HasInput);
}
}