Add GPU-resident flame iteration state

This commit is contained in:
Meta Vens 2026-05-21 00:27:51 +01:00
commit c9eb44cc0c
13 changed files with 178 additions and 37 deletions

View file

@ -252,6 +252,56 @@ Local GTX 1070 receipt from 2026-05-20:
- equivalent FPS: `971.3`
- readback checksum: `0x2647D8B08575B848`
The flame hot path now keeps per-splat iteration state in a GPU UAV instead of
replaying every chaos-game ancestry from the origin. `Depth` is the number of
iterations advanced when a row is touched; the row stores point, support,
material, random state, and accumulated step for the next stochastic update.
This makes the receipt a two-phase cache:
- acquisition: seed every resident row and optionally advance the full resident
population for a few warmup frames
- maintenance: update only the budgeted stochastic subset while the layered
SDF/PBR/radiosity reservoirs continue their independent passes
```powershell
.\scripts\fractal-splat-receipt.ps1 `
-ProgramFlame artifacts\reference-tools\j-wildfire-9.00\lib\FARenderJWF\selftest.flame `
-Splats 2000000 `
-WarmupSplatUpdates 2000000 `
-SplatUpdates 50000 `
-Warmup 8 `
-Frames 20 `
-Depth 8 `
-ReservoirUpdates 15000 `
-ReadbackSplats 250000 `
-VisualParity `
-VisualParityReferenceSamples 1000000 `
-HistogramSize 256x256 `
-HistogramBounds -8,-8,8,8 `
-VisualParityImageDirectory artifacts\fractal-jwildfire-faceplant\source `
-VisualParityImagePrefix selftest-persistent-warmfull-depth008-frame-020
```
Local GTX 1070 receipt from 2026-05-21:
- resident splats: `2,000,000`
- flame iteration states: `2,000,000` at `32` bytes each
- resident reservoir rows: `2,000,000` each for SDF, PBR, and radiosity
- warmup splat updates/frame: `2,000,000`
- steady splat updates/frame: `50,000`
- reservoir updates/pass/frame: `15,000`
- measured steady GPU time: `1.011 ms/frame`
- equivalent steady FPS: `988.8`
- visual parity against Aquarium CPU slice oracle: `84.86%`
- cosine similarity: `0.986955`
- readback checksum: `0xC633FADC3BD7E5BE`
Without the full-population acquisition pass, the same steady budget scored only
`32.64%` on the JWildfire selftest slice because most rows were still shallow
ancestry. That is a useful failure: persistent state is not magic, it is a cache
that must be filled before a tiny maintenance budget can look clever.
## Visual Parity Receipt
The receipt tool can compare GPU flame splat positions against the local CPU

View file

@ -1,5 +1,6 @@
param(
[int]$Splats = 2000000,
[int]$WarmupSplatUpdates = 2000000,
[int]$SplatUpdates = 2000000,
[int]$Warmup = 30,
[int]$Frames = 120,
@ -45,6 +46,7 @@ if ($VisualParity) {
dotnet run --project (Join-Path $repoRoot "tools\Aquarium.Fractal.Receipt\Aquarium.Fractal.Receipt.csproj") -c Release -- `
--splats $Splats `
--warmup-splat-updates $WarmupSplatUpdates `
--splat-updates $SplatUpdates `
--warmup $Warmup `
--frames $Frames `

View file

@ -178,6 +178,11 @@ public readonly record struct AquariumPackedFractalIfsTransform(
Vector4 PostMatrix,
Vector4 PostTranslation);
[StructLayout(LayoutKind.Sequential)]
public readonly record struct AquariumPackedFractalFlameState(
Vector4 PointSupportMaterial,
Vector4 RandomStep);
[StructLayout(LayoutKind.Sequential)]
public readonly record struct AquariumPackedSdfEnvelopeReservoir(
Vector4 CenterRadius,

View file

@ -455,6 +455,8 @@ public sealed class AquariumFractalReservoirField
public int CandidatesPerReservoirUpdate { get; init; } = 2;
public int SplatUpdatesPerFrame { get; init; }
public int ReservoirUpdatesPerPass { get; init; }
public IReadOnlyList<AquariumPackedFractalIfsTransform> ProgramTransforms { get; init; } = [];
@ -465,6 +467,8 @@ public sealed class AquariumFractalReservoirField
SplatCount > 0 &&
Depth > 0 &&
CandidatesPerReservoirUpdate > 0 &&
SplatUpdatesPerFrame > 0 &&
SplatUpdatesPerFrame <= SplatCount &&
ReservoirUpdatesPerPass > 0 &&
ReservoirUpdatesPerPass <= SplatCount;
}

View file

@ -76,7 +76,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
private const int RootFractalSdfReservoirs = 2;
private const int RootFractalPbrReservoirs = 3;
private const int RootFractalRadiosityReservoirs = 4;
private const int RootFractalProgramTransforms = 5;
private const int RootFractalFlameStates = 5;
private const int RootFractalProgramTransforms = 6;
private static readonly DebugUi.DebugUiOption[] RenderDebugOptions =
[
new(0, "Final"),
@ -172,6 +173,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
private D3D12StructuredBuffer? fractalSdfReservoirBuffer;
private D3D12StructuredBuffer? fractalPbrReservoirBuffer;
private D3D12StructuredBuffer? fractalRadiosityReservoirBuffer;
private D3D12StructuredBuffer? fractalFlameStateBuffer;
private D3D12StructuredBuffer? fractalProgramTransformBuffer;
private readonly Dictionary<string, D3D12ExternalSensorTexture> externalSensorTextures = new(StringComparer.Ordinal);
private readonly D3D12CubeTexture studioPmremTexture;
@ -1338,7 +1340,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
return;
}
if (fractalSplatBuffer is not null && fractalSplatBuffer.ElementCount >= field.SplatCount)
if (fractalSplatBuffer is not null && fractalFlameStateBuffer is not null && fractalSplatBuffer.ElementCount >= field.SplatCount && fractalFlameStateBuffer.ElementCount >= field.SplatCount)
{
return;
}
@ -1361,6 +1363,10 @@ public sealed class D3D12Renderer : IAquariumRenderer
field.SplatCount,
"fractal-radiosity-reservoir-buffer",
"Aquarium D3D12 Fractal Radiosity Reservoir Buffer");
fractalFlameStateBuffer = CreateFractalReservoirBuffer<AquariumPackedFractalFlameState>(
field.SplatCount,
"fractal-flame-state-buffer",
"Aquarium D3D12 Fractal Flame Iteration State Buffer");
}
private D3D12StructuredBuffer CreateFractalReservoirBuffer<T>(int elementCount, string registryName, string resourceName)
@ -1403,16 +1409,19 @@ public sealed class D3D12Renderer : IAquariumRenderer
private void DisposeFractalReservoirBuffers()
{
resourceRegistry.RemoveStructuredBuffer("fractal-program-transform-buffer");
resourceRegistry.RemoveStructuredBuffer("fractal-flame-state-buffer");
resourceRegistry.RemoveStructuredBuffer("fractal-radiosity-reservoir-buffer");
resourceRegistry.RemoveStructuredBuffer("fractal-pbr-material-reservoir-buffer");
resourceRegistry.RemoveStructuredBuffer("fractal-sdf-envelope-reservoir-buffer");
resourceRegistry.RemoveStructuredBuffer("fractal-sdf-splat-buffer");
fractalProgramTransformBuffer?.Dispose();
fractalFlameStateBuffer?.Dispose();
fractalRadiosityReservoirBuffer?.Dispose();
fractalPbrReservoirBuffer?.Dispose();
fractalSdfReservoirBuffer?.Dispose();
fractalSplatBuffer?.Dispose();
fractalProgramTransformBuffer = null;
fractalFlameStateBuffer = null;
fractalRadiosityReservoirBuffer = null;
fractalPbrReservoirBuffer = null;
fractalSdfReservoirBuffer = null;
@ -1728,6 +1737,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
fractalSdfReservoirBuffer is null ||
fractalPbrReservoirBuffer is null ||
fractalRadiosityReservoirBuffer is null ||
fractalFlameStateBuffer is null ||
fractalProgramTransformBuffer is null)
{
return;
@ -1750,14 +1760,19 @@ public sealed class D3D12Renderer : IAquariumRenderer
fractalSdfReservoirBuffer.Transition(activeCommandList, ResourceStates.UnorderedAccess);
fractalPbrReservoirBuffer.Transition(activeCommandList, ResourceStates.UnorderedAccess);
fractalRadiosityReservoirBuffer.Transition(activeCommandList, ResourceStates.UnorderedAccess);
fractalFlameStateBuffer.Transition(activeCommandList, ResourceStates.UnorderedAccess);
activeCommandList.SetComputeRootSignature(fractalReservoirRootSignature);
BindFractalReservoirConstants(activeCommandList);
var splatDispatchCount = temporalFrameIndex == 0
? activeFractalReservoirField.SplatCount
: activeFractalReservoirField.SplatUpdatesPerFrame;
BindFractalReservoirConstants(activeCommandList, splatDispatchCount);
activeCommandList.SetComputeRootUnorderedAccessView(RootFractalSplats, fractalSplatBuffer.Resource.GPUVirtualAddress);
activeCommandList.SetComputeRootUnorderedAccessView(RootFractalSdfReservoirs, fractalSdfReservoirBuffer.Resource.GPUVirtualAddress);
activeCommandList.SetComputeRootUnorderedAccessView(RootFractalPbrReservoirs, fractalPbrReservoirBuffer.Resource.GPUVirtualAddress);
activeCommandList.SetComputeRootUnorderedAccessView(RootFractalRadiosityReservoirs, fractalRadiosityReservoirBuffer.Resource.GPUVirtualAddress);
activeCommandList.SetComputeRootUnorderedAccessView(RootFractalFlameStates, fractalFlameStateBuffer.Resource.GPUVirtualAddress);
activeCommandList.SetComputeRootShaderResourceView(RootFractalProgramTransforms, fractalProgramTransformBuffer.Resource.GPUVirtualAddress);
Dispatch(fractalSplatPipelineState!, activeFractalReservoirField.SplatCount);
Dispatch(fractalSplatPipelineState!, splatDispatchCount);
activeCommandList.ResourceBarrier(ResourceBarrier.BarrierUnorderedAccessView(fractalSplatBuffer.Resource));
Dispatch(fractalSdfReservoirPipelineState!, activeFractalReservoirField.ReservoirUpdatesPerPass);
Dispatch(fractalPbrReservoirPipelineState!, activeFractalReservoirField.ReservoirUpdatesPerPass);
@ -1775,7 +1790,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
}
}
private void BindFractalReservoirConstants(ID3D12GraphicsCommandList activeCommandList)
private void BindFractalReservoirConstants(ID3D12GraphicsCommandList activeCommandList, int splatDispatchCount)
{
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)activeFractalReservoirField.SplatCount, 0);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)temporalFrameIndex, 1);
@ -1785,6 +1800,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)activeFractalReservoirField.ReservoirUpdatesPerPass, 5);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)activeFractalProgramTransforms.Length, 6);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, activeFractalProgramTransforms.Length > 0 ? 1u : 0u, 7);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)splatDispatchCount, 8);
}
private void CreateGpuSensorTextureViews(AquariumGpuSensorFrame sensorFrame, D3D12DescriptorSlot firstDescriptor)
@ -2080,17 +2096,19 @@ public sealed class D3D12Renderer : IAquariumRenderer
$"{frameResources.TransientShaderDescriptors.Describe()}; " +
$"{staticShaderDescriptorArena.Describe()}; " +
$"{renderTargetViewArena.Describe()}");
if (activeFractalReservoirField.HasInput && fractalSplatBuffer is not null && fractalSdfReservoirBuffer is not null && fractalPbrReservoirBuffer is not null && fractalRadiosityReservoirBuffer is not null)
if (activeFractalReservoirField.HasInput && fractalSplatBuffer is not null && fractalSdfReservoirBuffer is not null && fractalPbrReservoirBuffer is not null && fractalRadiosityReservoirBuffer is not null && fractalFlameStateBuffer is not null)
{
var residentBytes =
fractalSplatBuffer.SizeBytes +
fractalSdfReservoirBuffer.SizeBytes +
fractalPbrReservoirBuffer.SizeBytes +
fractalRadiosityReservoirBuffer.SizeBytes;
fractalRadiosityReservoirBuffer.SizeBytes +
fractalFlameStateBuffer.SizeBytes;
Console.WriteLine(
$"D3D12 fractal reservoirs: splats {activeFractalReservoirField.SplatCount:N0}; " +
$"visible {visibleFractalSplatCount:N0}; " +
$"program transforms {activeFractalProgramTransforms.Length:N0}; " +
$"splat updates/frame {activeFractalReservoirField.SplatUpdatesPerFrame:N0}; " +
$"updates/pass {activeFractalReservoirField.ReservoirUpdatesPerPass:N0}; " +
$"candidates/update {activeFractalReservoirField.CandidatesPerReservoirUpdate}; " +
$"resident {residentBytes / (1024.0 * 1024.0):0.0} MiB");
@ -2611,11 +2629,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
{
var rootParameters = new[]
{
new RootParameter(new RootConstants(0, 0, 8), ShaderVisibility.All),
new RootParameter(new RootConstants(0, 0, 9), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(0, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(1, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(2, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(3, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(4, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.ShaderResourceView, new RootDescriptor(0, 0), ShaderVisibility.All),
};
var description = new RootSignatureDescription(

View file

@ -41,6 +41,12 @@ struct FractalIfsTransform
float4 postTranslation;
};
struct FlameIterationState
{
float4 pointSupportMaterial;
float4 randomStep;
};
cbuffer ReceiptConstants : register(b0)
{
uint SplatCount;
@ -51,12 +57,14 @@ cbuffer ReceiptConstants : register(b0)
uint ReservoirUpdatesPerPass;
uint ProgramTransformCount;
uint ProgramMode;
uint SplatDispatchCount;
};
RWStructuredBuffer<FractalSdfSplat> Splats : register(u0);
RWStructuredBuffer<SdfEnvelopeReservoir> SdfReservoirs : register(u1);
RWStructuredBuffer<PbrMaterialReservoir> PbrReservoirs : register(u2);
RWStructuredBuffer<RadiosityReservoir> RadiosityReservoirs : register(u3);
RWStructuredBuffer<FlameIterationState> FlameStates : register(u4);
StructuredBuffer<FractalIfsTransform> ProgramTransforms : register(t0);
uint Hash(uint x)
@ -74,6 +82,21 @@ float Random01(uint value)
return (float)(Hash(value) & 16777215u) / 16777216.0;
}
uint XorShift(inout uint state)
{
uint value = state == 0u ? 0xA341316Cu : state;
value ^= value << 13;
value ^= value >> 17;
value ^= value << 5;
state = value == 0u ? 0xA341316Cu : value;
return state;
}
float StateRandom01(inout uint state)
{
return (float)(XorShift(state) & 16777215u) / 16777216.0;
}
float2 CubeTileFaceUv(float2 authoredPoint, float4 tileAddress)
{
float level = max(tileAddress.y, 0.0);
@ -118,10 +141,19 @@ float3 FractalPoint(uint index, out float radius)
{
if (ProgramTransformCount > 0u && ProgramMode == 2u)
{
uint n = Hash(index ^ Seed);
float2 p = 0.0;
float material = 0.0;
float support = 1.0;
FlameIterationState state = FlameStates[index];
uint n = asuint(state.randomStep.x);
float step = state.randomStep.y;
if (FrameIndex == 0u || n == 0u)
{
n = Hash(index ^ Seed);
state.pointSupportMaterial = float4(0.0, 0.0, 1.0, 0.0);
step = 0.0;
}
float2 p = state.pointSupportMaterial.xy;
float support = max(state.pointSupportMaterial.z, 0.000001);
float material = state.pointSupportMaterial.w;
float totalWeight = 0.0;
[loop]
for (uint weightIndex = 0u; weightIndex < ProgramTransformCount; weightIndex++)
@ -132,7 +164,7 @@ float3 FractalPoint(uint index, out float radius)
[loop]
for (uint depth = 0; depth < Depth; depth++)
{
float target = Random01(n + depth * 747796405u + FrameIndex * 1664525u) * max(totalWeight, 0.000001);
float target = StateRandom01(n) * max(totalWeight, 0.000001);
float cumulative = 0.0;
uint transformIndex = ProgramTransformCount - 1u;
[loop]
@ -168,7 +200,7 @@ float3 FractalPoint(uint index, out float radius)
{
float power = abs(transform.tileAddress.z) < 1.0 ? 1.0 : transform.tileAddress.z;
float absPower = max(abs(power), 1.0);
float branch = floor(Random01(n + depth * 2246822519u + 97u) * absPower);
float branch = floor(StateRandom01(n) * absPower);
float angle = (theta + 6.28318530717958647692 * branch) / power;
float radial = pow(max(r, 0.000001), transform.materialSeedShape.w / power);
nextPoint += julian * radial * float2(cos(angle), sin(angle));
@ -178,11 +210,11 @@ float3 FractalPoint(uint index, out float radius)
if (blur != 0.0)
{
float blurRadius = blur * (
Random01(n + depth * 3266489917u + 11u) +
Random01(n + depth * 3266489917u + 23u) +
Random01(n + depth * 3266489917u + 37u) +
Random01(n + depth * 3266489917u + 53u) - 2.0);
float blurAngle = Random01(n + depth * 668265263u + 71u) * 6.28318530717958647692;
StateRandom01(n) +
StateRandom01(n) +
StateRandom01(n) +
StateRandom01(n) - 2.0);
float blurAngle = StateRandom01(n) * 6.28318530717958647692;
nextPoint += blurRadius * float2(cos(blurAngle), sin(blurAngle));
}
@ -194,9 +226,12 @@ float3 FractalPoint(uint index, out float radius)
p = nextPoint;
material = transform.materialSeedShape.z;
support *= saturate(max(length(m.xy), length(m.zw)));
n = Hash(n + asuint(transform.materialSeedShape.w) + transformIndex + depth);
}
FlameIterationState nextState;
nextState.pointSupportMaterial = float4(p, support, material);
nextState.randomStep = float4(asfloat(n), step + (float)Depth, 0.0, 0.0);
FlameStates[index] = nextState;
radius = max(0.0025 * max(support, 0.04), 0.00015);
return float3(p, material * 0.08);
}
@ -301,13 +336,13 @@ float4 ReservoirStats(uint index, uint passKind, float baseTarget, out uint sele
void D3D12FractalSplatReceiptCS(uint3 id : SV_DispatchThreadID)
{
uint updateIndex = id.x;
if (updateIndex >= SplatCount)
if (updateIndex >= SplatDispatchCount)
{
return;
}
uint index = updateIndex;
if (ProgramMode == 2u && FrameIndex > 0u)
if (FrameIndex > 0u && SplatDispatchCount < SplatCount)
{
index = ReservoirIndex(updateIndex, 4u);
}

View file

@ -15,6 +15,7 @@ public static class ZyphosSceneBuilder
FractalReservoirField = new AquariumFractalReservoirField
{
SplatCount = 2_000_000,
SplatUpdatesPerFrame = 50_000,
ReservoirUpdatesPerPass = 20_000,
WorldCenterRadius = new Vector4(ZyphosUmbrosSystem.ZyphosCenter, ZyphosUmbrosSystem.ZyphosSurfaceRadius),
ProgramTransforms = fractalPlan.GpuProgramTransforms,

View file

@ -190,3 +190,4 @@
{"timestamp":"2026-05-20T14:05:00+01:00","topic":"apophysis-reference-first-fractal-parity","lesson":"Zyphos is too entangled to be the first correctness oracle for the fractal DSL. Aquarium now has a tiny Apophysis/FLAM3-shaped reference gate: `.flame` linear Sierpinski is parsed by an independent test helper, `.aquageo` expresses the same affine IFS through `affineifs`/`affinemap`, and tests compare exact fixed-transform sequence points plus chaos-game moment bounds. This follows the AquaSynth pattern: open-source/reference systems are external pressure and receipts, not runtime organs or copied code. Next parity gates should parse more `.flame` semantics and compare against FLAM3/Apophysis-compatible rendered histograms before feeding the GPU reservoir renderer.","files":["src/Aquarium.Engine.Fractal/Grammar/FractalAffineIfsDefinition.cs","src/Aquarium.Engine.Fractal/Grammar/FractalAffineIfsChaosGame.cs","src/Aquarium.Engine.Fractal/Grammar/FractalDslCompiler.cs","src/Aquarium.Engine.Fractal/Grammar/FractalOwnershipTree.cs","tests/Aquarium.Engine.Fractal.Tests/ApophysisReferenceParityTests.cs","tests/Aquarium.Engine.Fractal.Tests/Fixtures/Apophysis/linear-sierpinski.flame","tests/Aquarium.Engine.Fractal.Tests/Fixtures/Apophysis/linear-sierpinski.aquageo","research/rendering/fractal-reference-oracles.md"],"source":"user redirected from visual Zyphos debugging to reference-rendered IFS parity and suggested Apophysis 7x"}
{"timestamp":"2026-05-20T14:20:00+01:00","topic":"flame-subset-parser-histogram-receipts","lesson":"The reference path now parses and evaluates a small Apophysis/FLAM3 flame subset in runtime code: xform weight, color, affine coefficients, and `linear`, `spherical`, and `bubble` variation weights. Tests cover parser fields, independent variation formulas, and a deterministic 64x64 histogram checksum for a mixed linear/spherical/bubble fixture. This is still not external renderer parity, but it gives Aquarium a stable CPU receipt before GPU lowering and keeps Zyphos out of the correctness loop.","files":["src/Aquarium.Engine.Fractal/Grammar/FractalFlameDefinition.cs","src/Aquarium.Engine.Fractal/Grammar/FractalFlameFileParser.cs","src/Aquarium.Engine.Fractal/Grammar/FractalFlameChaosGame.cs","src/Aquarium.Engine.Fractal/Grammar/FractalPointHistogram.cs","tests/Aquarium.Engine.Fractal.Tests/ApophysisReferenceParityTests.cs","tests/Aquarium.Engine.Fractal.Tests/Fixtures/Apophysis/linear-spherical-bubble.flame","research/rendering/fractal-reference-oracles.md"],"source":"continued after adopting Apophysis/FLAM3 as the fractal reference family"}
{"timestamp":"2026-05-20T14:30:00+01:00","topic":"flame-histogram-receipt-cli","lesson":"The receipt tool now has a non-GPU `--flame` mode that loads a `.flame` fixture, runs FractalFlameChaosGame, bins points through FractalPointHistogramBuilder, and writes a JSON checksum receipt. `scripts/fractal-flame-receipt.ps1` runs the default mixed linear/spherical/bubble fixture with seed 0x0BADC0DE and emits checksum 0xAEB1C81B. This creates a cheap local receipt path before wiring external FLAM3/Apophysis renderer parity or GPU lowering.","files":["tools/Aquarium.Fractal.Receipt/Program.cs","scripts/fractal-flame-receipt.ps1","research/rendering/fractal-reference-oracles.md"],"source":"continued reference-first fractal pipeline build"}
{"timestamp":"2026-05-21T00:25:00+01:00","topic":"gpu-resident-flame-iteration-state","lesson":"Flame splat generation now has a real GPU-resident iteration cache. `AquariumPackedFractalFlameState` is a 32-byte UAV row per resident splat storing point/support/material plus RNG/step; D3D12FractalReservoirCompute advances touched rows instead of replaying chaos-game ancestry from zero. The receipt harness separates full-population acquisition from steady stochastic maintenance: on the GTX 1070, JWildfire FARender selftest.flame with 2,000,000 splats/states, 8 full acquisition frames, then 50,000 splat updates/frame plus 15,000 reservoir updates/pass/frame at depth 8 measured 1.011 ms/frame / 988.8 FPS equivalent and 84.85% CPU-slice distribution parity. The same steady budget without acquisition scored 32.64%, so persistent caches must report cold-start versus maintenance explicitly.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","src/Aquarium.Engine/Render/D3D12Renderer.cs","tools/Aquarium.Fractal.Receipt/Program.cs","scripts/fractal-splat-receipt.ps1","research/rendering/fractal-reference-oracles.md","state/map.yaml","state/memory.json"],"source":"user demanded the Perfect Machine stop replaying crayon flames and keep building toward GPU-resident stochastic fractal rendering"}

View file

@ -139,8 +139,8 @@ 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. The fallback hash-fractal receipt updates 50,000 entries per reservoir layer per frame with 2 candidates/update and runs at 4.471 ms/frame, 223.7 FPS equivalent. The authored IFS-program path now uses precomposed selected-cut rows instead of replaying ancestry per splat; a depth-48 authored receipt with 4 compact transforms and 15,000 updates per reservoir layer runs at 4.908 ms/frame, 203.7 FPS equivalent, with full reservoir coverage in 133.3 frames. Receipts use only tiny checksum readback and compile the shared engine shader asset src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl.
- 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, stochastic updates per pass, authored program transforms, and an explicit world center/radius. This is a budgeted GPU field request, not a CPU splat list.
- D3D12Renderer owns the first live fractal reservoir compute hook: a separate root signature, four compute pipelines from D3D12FractalReservoirCompute.hlsl, lazy UAV buffers for splats/SDF/PBR/radiosity reservoirs, a UAV barrier after splat population, and per-frame dispatch when AquariumFractalReservoirField is present. Zyphos requests the 2M-splat, 50k-updates/pass field by default.
- AquariumSceneState now carries AquariumFractalReservoirField as the narrow client-to-renderer request for GPU-resident fractal reservoirs: resident splat count, stochastic splat updates per frame, IFS depth/seed, candidates per reservoir update, stochastic updates per pass, authored program transforms, and an explicit world center/radius. This is a budgeted GPU field request, not a CPU splat list.
- D3D12Renderer owns the first live fractal reservoir compute hook: a separate root signature, four compute pipelines from D3D12FractalReservoirCompute.hlsl, lazy UAV buffers for splats/SDF/PBR/radiosity/flame-state reservoirs, a UAV barrier after splat population, and per-frame dispatch when AquariumFractalReservoirField is present. The first frame seeds every resident splat; later frames dispatch only SplatUpdatesPerFrame. Zyphos requests the 2M-splat, 50k-splat-updates/frame, 20k-reservoir-updates/pass field by default.
- Fractal reservoir population can now be driven by authored `.aquageo` structure: FractalGpuProgramCompiler lowers selected DSL claims into compact, precomposed AquariumPackedFractalIfsTransform support rows, Zyphos passes those rows through AquariumFractalReservoirField.ProgramTransforms, and D3D12 uploads the small program buffer as a compute SRV so D3D12FractalReservoirCompute.hlsl can generate splats from authored selected-cut supports in O(1) per splat instead of replaying nested domain ancestry.
- The renderer now has a first visible layered-reservoir consumption path for computed fractal splats: D3D12FractalSplatRender.hlsl binds separate GPU SRVs for raw splats, SDF envelope reservoirs, PBR material reservoirs, and radiosity reservoirs, then draws a capped 524,288-instance tangent-frame surface subset into the scene after compute updates. This is an observability/render-consumption proof for the three-pass reservoir contract, not the final terrain/material/radiosity shading path.
- Zyphos now uses the fractal reservoir surface as its primary planetary terrain test path. The old direct SDF planet and Umbros proxy shaders are removed from the Zyphos render plan; the remaining SDF proxy is the parent star. Zyphos binds the fractal reservoir field to the Zyphos world center/radius, and D3D12FractalSplatRender maps SDF/PBR/radiosity reservoir splats into that world frame instead of drawing camera-relative blobs.
@ -149,7 +149,7 @@ renderer_state:
- Fractal reference parity starts before the renderer: FractalOwnershipTree can carry affine IFS definitions from `.aquageo`, FractalAffineIfsChaosGame generates deterministic point sets, and ApophysisReferenceParityTests compares a minimal Apophysis/FLAM3-style `.flame` linear Sierpinski fixture against an equivalent `.aquageo` candidate. Apophysis/FLAM3 are test oracles, not runtime code.
- The Apophysis/FLAM3 reference subset now has a runtime parser/evaluator boundary: FractalFlameFileParser reads `.flame` xforms with weight, color, affine coefficients, and `linear`/`spherical`/`bubble` variation weights; FractalFlameChaosGame produces deterministic point sets; FractalPointHistogramBuilder produces fixed histogram checksums for parity receipts.
- tools/Aquarium.Fractal.Receipt can now run a CPU flame histogram receipt with `--flame`; scripts/fractal-flame-receipt.ps1 emits the default linear/spherical/bubble fixture checksum 0xAEB1C81B under artifacts/fractal-flame-receipts. It can also hash binary PPM renders with `--reference-ppm`; scripts/fractal-flame-reference-render.ps1 drives a local external `flam3-render` through FLAM3's documented env vars and records image-shape/non-black/checksum receipts under artifacts/fractal-flame-reference without vendoring GPL renderer code.
- D3D12FractalReservoirCompute has an explicit flame 2D program mode for the proven FLAM3-style subset. FractalGpuProgramCompiler lowers flame rows into packed affine/variation program rows, and tools/Aquarium.Fractal.Receipt can run them with `--program-flame`. The splat cache initializes all resident rows once, then stochastic frame updates touch a budgeted subset. Local GTX 1070 receipt: 2,000,000 resident splats, 2,000,000 SDF/PBR/radiosity reservoirs each, 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, 3 flame transforms, 1.030 ms/frame, 971.3 FPS equivalent, checksum 0x2647D8B08575B848.
- D3D12FractalReservoirCompute has an explicit flame 2D program mode for the proven FLAM3-style subset. FractalGpuProgramCompiler lowers flame rows into packed affine/variation program rows, and tools/Aquarium.Fractal.Receipt can run them with `--program-flame`. Flame mode now keeps 32-byte AquariumPackedFractalFlameState rows in a GPU UAV so touched splats advance persistent chaos-game state instead of replaying from the origin. Local GTX 1070 JWildfire selftest receipt after 8 full-population acquisition frames: 2,000,000 resident splats, 2,000,000 flame states, 2,000,000 SDF/PBR/radiosity reservoirs each, steady 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, 1.011 ms/frame, 988.8 FPS equivalent, 84.85% CPU-slice distribution parity, checksum 0xC633FADC3BD7E5BE.
- The first visual parity receipt compares GPU flame splat XY histograms against the CPU flame oracle. With 250,000 GPU readback splats and 1,000,000 CPU reference samples in 128x128 bounds -8,-8,8,8, the mixed flame fixture scores 84.05% distribution parity at frame 1, 84.10% at frame 5, 84.20% at frame 20, and 84.24% after the 60-frame/10-warmup receipt, with cosine similarity around 0.9955. This is a stable sampler score, not proof of learned convergence; visual-error feedback is still future work.
- View-conditioned visual parity now scores named camera windows instead of trusting one global histogram. For the depth-16 flame receipt, global -8..8 scores 97.09%, mid -1..1 scores 91.93%, close -0.5..0.5 scores 88.97%, and micro -0.25..0.25 scores 82.05% with 2,656 starved reference bins and 17.95% underrepresented mass. This is the current hard loss: the reservoir is not yet spending work based on camera-conditioned underrepresentation.
- High-reference flame contact sheets should use at least 20M CPU oracle samples for visual judgment. The current artifact is artifacts/fractal-contact-sheet-hq/flame-parity-contact-sheet-hq.png, comparing 20M CPU oracle histograms against 250k Aquarium GPU readback samples for global frame 1/10 and zoom frame 1/10. The 1M-sample oracle was too noisy and should be treated as a scalar smoke check only.

View file

@ -107,14 +107,14 @@
"Do not use Zyphos as the first proof of fractal DSL correctness. Start with reference fractals. Apophysis/FLAM3-style `.flame` fixtures are the parity pressure for Aquarium `.aquageo`; GPL/open-source renderers stay external/test-only. The first gate is linear Sierpinski: exact fixed-xform sequence parity and chaos-game moment bounds before any GPU visualization claim.",
"The local Apophysis/FLAM3 subset parser owns only a small proven flame shape: xform weight/color, affine coefficients, and `linear`, `spherical`, and `bubble` variation weights. `FractalFlameChaosGame` and `FractalPointHistogramBuilder` provide deterministic CPU receipts. External renderer proof stays optional and outside runtime through FLAM3-compatible PPM receipt hashing.",
"Use `scripts/fractal-flame-receipt.ps1` for the local CPU flame receipt. The default mixed linear/spherical/bubble fixture uses 8192 samples, 64 burn-in, 64x64 bounds -8,-8,8,8, seed 0x0BADC0DE, and checksum 0xAEB1C81B. Use `scripts/fractal-flame-reference-render.ps1` with a local `flam3-render` executable to produce external PPM image receipts under artifacts/fractal-flame-reference; Aquarium does not vendor Apophysis or FLAM3.",
"FractalGpuProgramCompiler can lower the proven FLAM3-style flame subset into GPU program rows for D3D12FractalReservoirCompute's explicit flame 2D program mode. The receipt path initializes the full resident splat cache once, then stochastically updates a splat subset per frame; on 2026-05-20 the GTX 1070 ran the mixed flame fixture with 2,000,000 resident splats, three 2,000,000-row reservoir layers, 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, and 3 flame transforms at 1.030 ms/frame / 971.3 FPS equivalent, checksum 0x2647D8B08575B848.",
"FractalGpuProgramCompiler can lower the proven FLAM3-style flame subset into GPU program rows for D3D12FractalReservoirCompute's explicit flame 2D program mode. Flame mode owns a 32-byte AquariumPackedFractalFlameState UAV row per resident splat; touched rows advance persistent chaos-game state instead of replaying from the origin. The cache has two phases: full-population acquisition, then budgeted stochastic maintenance. On 2026-05-21 the GTX 1070 ran JWildfire FARender selftest.flame with 2,000,000 splats, 2,000,000 flame states, three 2,000,000-row reservoir layers, 8 full acquisition frames, steady 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, at 1.011 ms/frame / 988.8 FPS equivalent, 84.85% CPU-slice distribution parity, checksum 0xC633FADC3BD7E5BE. Without acquisition, the same steady budget scored only 32.64%; do not confuse a cold persistent cache with a bad sampler.",
"The first visual parity metric compares GPU flame splat XY histograms against the local CPU flame oracle. With 250,000 GPU readback splats, 1,000,000 CPU reference samples, 128x128 bounds -8,-8,8,8, and the mixed FLAM3-style fixture, distribution score is 84.05% at frame 1, 84.10% at frame 5, 84.20% at frame 20, and 84.24% after the 60-frame/10-warmup receipt; cosine similarity stays about 0.9955. This is high distribution similarity but not learned convergence: the current reservoir path initializes splats and stochastically replaces them, without visual-error feedback or ReSTIR/MIS target correction yet.",
"Global flame parity is not enough. View-conditioned parity now scores named viewport bounds and reports GPU/reference hits, starved reference bins, and underrepresented mass. First depth-16 GTX 1070 receipt with 250k GPU readback splats vs 1M CPU samples: global -8..8 scores 97.09%, mid -1..1 scores 91.93%, close -0.5..0.5 scores 88.97%, micro -0.25..0.25 scores 82.05% with 2,656 starved bins and 17.95% underrepresented mass. This proves the current reservoir is fast but not view-adaptive; next work needs camera-conditioned target weights and underrepresented-region feedback.",
"Do not use the quick 1M-sample flame oracle image for visual judgment; it is too noisy. The high-reference contact sheet uses 20,000,000 CPU oracle samples and 250,000 Aquarium GPU readback splats per panel at artifacts/fractal-contact-sheet-hq/flame-parity-contact-sheet-hq.png. It makes the zoom failure legible: the CPU oracle smooths out while Aquarium remains under-sampled after zoom because the current reservoir is not view-adaptive.",
"Aquarium's CPU flame histogram is a math oracle, not visual ground truth. The visual reference ladder is: Chaotica as gold market-quality reference when available/imported, JWildfire/FARender as scriptable visual reference, FLAM3/Apophysis as portable baseline compatibility, Aquarium CPU as deterministic unit-test/debug oracle only. On 2026-05-20 Chaotica and flam3-render were not on PATH, but scripts/install-flame-reference-tools.ps1 hydrated JWildfire 9.00 plus Temurin JRE 17 under ignored artifacts, and scripts/fractal-flame-jwildfire-reference.ps1 rendered JWildfire's bundled FARenderJWF selftest flame at 1024x1024 quality 2000 in 7.69 sec on the GTX 1070. JWildfire/FARender is an external visual reference artifact lane, not Aquarium runtime code. Do not claim best-in-market flame parity until imported Chaotica renders or fully matched JWildfire flame dialect metrics are wired into residual scoring.",
"JWildfire selftest is now the flame renderer faceplant target. The current dialect slice supports JWildfire coefficient layout, variationGroup, disc, julian, gaussian_blur, and post transforms. After post lowering, the depth-64 GTX 1070 receipt scores 84.19% against Aquarium's CPU slice oracle in bounds -8..8 and 88.01% in bounds -128..128, but costs about 129 ms/frame. This is not external JWildfire visual parity; it is CPU/GPU agreement on the supported slice. Aquarium still needs richer dialect semantics, palette/density/render-filter parity, weighting-field handling, and persistent per-sample GPU iteration-state reservoirs instead of replaying deep chaos-game ancestry from zero for every splat.",
"Flame imports must report translation loss. FractalFlameFileParser.ParseFirstWithReport returns accepted, approximated, ignored, and rejected fields per transform, and receipt runs write fractal-flame-import-report-*.json. The JWildfire selftest report currently shows 15 accepted fields, 3 approximations, 45 ignored render/presentation fields, and 11 rejected geometry/sampling fields: wfield_* weighting-field attributes. Treat successful XML parsing as insufficient until rejected geometry fields are either implemented as DSL/operator nodes or explicitly accepted as out-of-scope diagnostics.",
"Persistent flame iteration now has a CPU parity contract, not a runtime CPU renderer: FractalFlameIterationState plus FractalFlameIterationStepper prove that chunked advancement of a sample matches one-shot advancement from the same state. The GPU flame path should mirror this state in a UAV and advance resident samples over frames instead of replaying all chaos-game depth from zero per splat.",
"Persistent flame iteration now has both a CPU parity contract and a GPU realization. FractalFlameIterationState plus FractalFlameIterationStepper prove chunked CPU advancement; AquariumPackedFractalFlameState mirrors the point/support/material/RNG/step packet in D3D12FractalReservoirCompute as a UAV so flame splats advance over frames. Keep the acquisition/maintenance split explicit in receipts and renderer budgets.",
"Zyphos' primary planetary terrain test path is now the fractal reservoir surface. The direct SDF planet and Umbros proxy shaders are removed from the render plan; only the parent star remains as a direct SDF body/light. If the planet looks wrong, fix the reservoir lowering/shading path instead of letting the old SDF terrain hide it.",
"The GPU splat receipt harness lives at tools/Aquarium.Fractal.Receipt and scripts/fractal-splat-receipt.ps1. The live receipt allocates one 80-byte packed SDF splat UAV plus three distinct 64-byte reservoir UAVs for SDF envelopes, PBR material envelopes, and radiosity; those reservoirs are sampled in independent compute passes under a stochastic update budget. On the local NVIDIA GTX 1070 it kept 2,000,000 splats and 2,000,000 reservoirs per layer resident. The fallback hash-fractal receipt updated 50,000 entries per layer with 2 candidates/update at 4.471 ms/frame, 223.7 FPS equivalent. The authored precomposed selected-cut receipt used depth 48, 4 compact transforms, and 15,000 updates per layer at 4.908 ms/frame, 203.7 FPS equivalent, with full reservoir coverage in 133.3 frames. D3D12FractalSplatRender consumes the raw splat, SDF, PBR, and radiosity buffers through separate graphics SRVs for the visible debug subset. This proves compute-side GPU residency, budgeted temporal convergence, authored-program splat population decoupled from domain ancestry depth, and first layered GPU consumption; final terrain/material/radiosity shading is still future work.",
"FractalProjectedSdfSplatCompiler is the Phase G 2D-projected-to-3D lowering seam: it converts resident SignedDistance2D page payload samples into compact 3D SDF splats through an explicit page-local Vector2 -> Vector3 mapping, surface normal, support radius, and splat budget. Zyphos caches a bounded first set with a flat local mapping until cube-sphere/torus mappers are added.",

View file

@ -10,6 +10,7 @@ public sealed class FractalReservoirFieldContractTests
var field = new AquariumFractalReservoirField
{
SplatCount = 2_000_000,
SplatUpdatesPerFrame = 50_000,
ReservoirUpdatesPerPass = 50_000,
};
var scene = new AquariumSceneState
@ -20,6 +21,7 @@ public sealed class FractalReservoirFieldContractTests
Assert.True(scene.FractalReservoirField.HasInput);
Assert.Equal(8, scene.FractalReservoirField.Depth);
Assert.Equal(2, scene.FractalReservoirField.CandidatesPerReservoirUpdate);
Assert.Equal(50_000, scene.FractalReservoirField.SplatUpdatesPerFrame);
Assert.Equal(0xA17EA11u, scene.FractalReservoirField.Seed);
}
@ -27,9 +29,10 @@ public sealed class FractalReservoirFieldContractTests
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);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, SplatUpdatesPerFrame = 4, ReservoirUpdatesPerPass = 0 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, SplatUpdatesPerFrame = 4, ReservoirUpdatesPerPass = 17 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, SplatUpdatesPerFrame = 17, ReservoirUpdatesPerPass = 4 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, SplatUpdatesPerFrame = 4, ReservoirUpdatesPerPass = 4, CandidatesPerReservoirUpdate = 0 }.HasInput);
Assert.False(new AquariumFractalReservoirField { SplatCount = 16, SplatUpdatesPerFrame = 4, ReservoirUpdatesPerPass = 4, Depth = 0 }.HasInput);
}
}

View file

@ -87,6 +87,7 @@ public sealed class ZyphosFractalTerrainTests
Assert.True(scene.FractalReservoirField.HasInput);
Assert.Equal(2_000_000, scene.FractalReservoirField.SplatCount);
Assert.Equal(50_000, scene.FractalReservoirField.SplatUpdatesPerFrame);
Assert.Equal(20_000, scene.FractalReservoirField.ReservoirUpdatesPerPass);
Assert.Equal(2, scene.FractalReservoirField.CandidatesPerReservoirUpdate);
Assert.Equal(ZyphosUmbrosSystem.ZyphosSurfaceRadius, scene.FractalReservoirField.WorldCenterRadius.W);

View file

@ -39,8 +39,10 @@ Console.WriteLine($"splats: {receipt.SplatCount:N0}");
Console.WriteLine($"sdf reservoirs: {receipt.SdfReservoirCount:N0}");
Console.WriteLine($"pbr reservoirs: {receipt.PbrReservoirCount:N0}");
Console.WriteLine($"radiosity reservoirs: {receipt.RadiosityReservoirCount:N0}");
Console.WriteLine($"flame states: {receipt.FlameStateCount:N0}");
Console.WriteLine($"ifs program transforms: {receipt.ProgramTransformCount:N0}");
Console.WriteLine($"program mode: {DescribeProgramMode(receipt.ProgramMode)}");
Console.WriteLine($"warmup splat updates/frame: {receipt.WarmupSplatUpdatesPerFrame:N0}");
Console.WriteLine($"splat updates/frame: {receipt.SplatUpdatesPerFrame:N0}");
Console.WriteLine($"candidates/pass: {receipt.CandidatesPerPass}");
Console.WriteLine($"reservoir updates/pass/frame: {receipt.ReservoirUpdatesPerPass:N0}");
@ -49,6 +51,7 @@ Console.WriteLine($"frames: {receipt.MeasuredFrames}");
Console.WriteLine("shader: D3D12 compute, independent GPU-resident SDF/PBR/radiosity reservoir passes");
Console.WriteLine($"packed bytes/splat: {receipt.BytesPerSplat}");
Console.WriteLine($"packed bytes/reservoir: {receipt.BytesPerReservoir}");
Console.WriteLine($"packed bytes/flame state: {receipt.BytesPerFlameState}");
Console.WriteLine($"gpu ms/frame total: {receipt.GpuMillisecondsPerFrame:0.000}");
Console.WriteLine($"gpu equivalent fps: {receipt.GpuEquivalentFps:0.0}");
Console.WriteLine($"gpu splats/sec: {receipt.GpuSplatsPerSecond:N0}");
@ -227,6 +230,7 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
var resolvedProgramMode = resolvedProgramTransforms.Length > 0 ? options.ProgramMode : 0;
var splatStride = Marshal.SizeOf<AquariumPackedFractalSdfSplat3D>();
var reservoirStride = Marshal.SizeOf<AquariumPackedSdfEnvelopeReservoir>();
var flameStateStride = Marshal.SizeOf<AquariumPackedFractalFlameState>();
var framePlan = FractalGpuReservoirBudgetPlanner.Plan(
options.SplatCount,
options.ReservoirUpdatesPerPass,
@ -235,10 +239,12 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
reservoirStride);
var splatBytes = checked((ulong)splatStride * (ulong)options.SplatCount);
var reservoirBytes = checked((ulong)reservoirStride * (ulong)options.SplatCount);
var flameStateBytes = checked((ulong)flameStateStride * (ulong)options.SplatCount);
using var splats = CreateUavBuffer(splatBytes, "Aquarium Fractal Receipt GPU Splat Buffer");
using var sdfReservoirs = CreateUavBuffer(reservoirBytes, "Aquarium Fractal Receipt SDF Reservoir Buffer");
using var pbrReservoirs = CreateUavBuffer(reservoirBytes, "Aquarium Fractal Receipt PBR Reservoir Buffer");
using var radiosityReservoirs = CreateUavBuffer(reservoirBytes, "Aquarium Fractal Receipt Radiosity Reservoir Buffer");
using var flameStates = CreateUavBuffer(flameStateBytes, "Aquarium Fractal Receipt Flame Iteration State Buffer");
using var programTransforms = CreateProgramTransformBuffer(resolvedProgramTransforms);
var readbackSplatBytes = (ulong)Math.Min(options.ReadbackSplats, options.SplatCount) * (ulong)splatStride;
@ -255,17 +261,20 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
for (var frame = 0; frame < options.WarmupFrames + options.MeasuredFrames; frame++)
{
var splatDispatchCount = frame == 0
? options.SplatCount
: frame < options.WarmupFrames ? options.WarmupSplatUpdatesPerFrame : options.SplatUpdatesPerFrame;
allocator.Reset();
commandList.Reset(allocator, splatPipelineState);
commandList.SetComputeRootSignature(rootSignature);
BindConstants(options, frame, resolvedProgramTransforms.Length, resolvedProgramMode);
BindConstants(options, frame, resolvedProgramTransforms.Length, resolvedProgramMode, splatDispatchCount);
commandList.SetComputeRootUnorderedAccessView(1, splats.GPUVirtualAddress);
commandList.SetComputeRootUnorderedAccessView(2, sdfReservoirs.GPUVirtualAddress);
commandList.SetComputeRootUnorderedAccessView(3, pbrReservoirs.GPUVirtualAddress);
commandList.SetComputeRootUnorderedAccessView(4, radiosityReservoirs.GPUVirtualAddress);
commandList.SetComputeRootShaderResourceView(5, programTransforms.GPUVirtualAddress);
commandList.SetComputeRootUnorderedAccessView(5, flameStates.GPUVirtualAddress);
commandList.SetComputeRootShaderResourceView(6, programTransforms.GPUVirtualAddress);
commandList.EndQuery(queryHeap, QueryType.Timestamp, 0);
var splatDispatchCount = frame == 0 ? options.SplatCount : options.SplatUpdatesPerFrame;
Dispatch(splatPipelineState, splatDispatchCount);
commandList.ResourceBarrier(ResourceBarrier.BarrierUnorderedAccessView(splats));
Dispatch(sdfPipelineState, options.ReservoirUpdatesPerPass);
@ -312,8 +321,10 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
options.SplatCount,
options.SplatCount,
options.SplatCount,
options.SplatCount,
resolvedProgramTransforms.Length,
resolvedProgramMode,
options.WarmupSplatUpdatesPerFrame,
options.SplatUpdatesPerFrame,
options.CandidatesPerPass,
options.ReservoirUpdatesPerPass,
@ -321,6 +332,7 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
measuredFrames,
splatStride,
reservoirStride,
flameStateStride,
gpuMsPerFrame,
1000.0 / Math.Max(gpuMsPerFrame, 1.0e-12),
splatsPerSecond,
@ -427,7 +439,7 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
return transforms;
}
private void BindConstants(ReceiptOptions options, int frame, int programTransformCount, int programMode)
private void BindConstants(ReceiptOptions options, int frame, int programTransformCount, int programMode, int splatDispatchCount)
{
commandList.SetComputeRoot32BitConstant(0, (uint)options.SplatCount, 0);
commandList.SetComputeRoot32BitConstant(0, (uint)frame, 1);
@ -437,6 +449,7 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
commandList.SetComputeRoot32BitConstant(0, (uint)options.ReservoirUpdatesPerPass, 5);
commandList.SetComputeRoot32BitConstant(0, (uint)programTransformCount, 6);
commandList.SetComputeRoot32BitConstant(0, (uint)programMode, 7);
commandList.SetComputeRoot32BitConstant(0, (uint)splatDispatchCount, 8);
}
private void CopyReceiptReadback(ID3D12Resource splats, ID3D12Resource sdf, ID3D12Resource pbr, ID3D12Resource radiosity, ID3D12Resource readback, ulong splatBytes, ulong reservoirBytes)
@ -701,11 +714,12 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
{
var rootParameters = new[]
{
new RootParameter(new RootConstants(0, 0, 8), ShaderVisibility.All),
new RootParameter(new RootConstants(0, 0, 9), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(0, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(1, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(2, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(3, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.UnorderedAccessView, new RootDescriptor(4, 0), ShaderVisibility.All),
new RootParameter(RootParameterType.ShaderResourceView, new RootDescriptor(0, 0), ShaderVisibility.All),
};
var description = new RootSignatureDescription(RootSignatureFlags.None, rootParameters, []);
@ -736,6 +750,7 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
internal sealed record ReceiptOptions(
int SplatCount,
int WarmupSplatUpdatesPerFrame,
int SplatUpdatesPerFrame,
int WarmupFrames,
int MeasuredFrames,
@ -765,6 +780,7 @@ internal sealed record ReceiptOptions(
public static ReceiptOptions Parse(string[] args)
{
var options = new ReceiptOptions(
2_000_000,
2_000_000,
2_000_000,
30,
@ -798,6 +814,7 @@ internal sealed record ReceiptOptions(
options = arg switch
{
"--splats" => options with { SplatCount = int.Parse(Next()) },
"--warmup-splat-updates" => options with { WarmupSplatUpdatesPerFrame = int.Parse(Next()) },
"--splat-updates" => options with { SplatUpdatesPerFrame = int.Parse(Next()) },
"--warmup" => options with { WarmupFrames = int.Parse(Next()) },
"--frames" => options with { MeasuredFrames = int.Parse(Next()) },
@ -872,7 +889,7 @@ internal sealed record ReceiptOptions(
throw new ArgumentException("Visual parity requires --program-flame so the GPU distribution has a CPU flame oracle.");
}
if (options.SplatCount <= 0 || options.SplatUpdatesPerFrame <= 0 || options.SplatUpdatesPerFrame > options.SplatCount || options.WarmupFrames < 0 || options.MeasuredFrames <= 0 || options.Depth <= 0 || options.CandidatesPerPass <= 0 || options.ReservoirUpdatesPerPass <= 0 || options.ReservoirUpdatesPerPass > options.SplatCount || options.ProgramTransformCount < 0 || options.ProgramMode < 0 || options.ProgramMode > 2 || options.ReadbackSplats < 0 || options.VisualParityReferenceSamples <= 0)
if (options.SplatCount <= 0 || options.WarmupSplatUpdatesPerFrame <= 0 || options.WarmupSplatUpdatesPerFrame > options.SplatCount || options.SplatUpdatesPerFrame <= 0 || options.SplatUpdatesPerFrame > options.SplatCount || options.WarmupFrames < 0 || options.MeasuredFrames <= 0 || options.Depth <= 0 || options.CandidatesPerPass <= 0 || options.ReservoirUpdatesPerPass <= 0 || options.ReservoirUpdatesPerPass > options.SplatCount || options.ProgramTransformCount < 0 || options.ProgramMode < 0 || options.ProgramMode > 2 || options.ReadbackSplats < 0 || options.VisualParityReferenceSamples <= 0)
{
throw new ArgumentOutOfRangeException(nameof(args), "Splats, splat updates, frames, depth, candidates, and reservoir updates must be positive; splat/reservoir updates must not exceed splats; program transforms, warmup, and readback must not be negative.");
}
@ -1014,8 +1031,10 @@ internal sealed record GpuFractalSplatReceipt(
int SdfReservoirCount,
int PbrReservoirCount,
int RadiosityReservoirCount,
int FlameStateCount,
int ProgramTransformCount,
int ProgramMode,
int WarmupSplatUpdatesPerFrame,
int SplatUpdatesPerFrame,
int CandidatesPerPass,
int ReservoirUpdatesPerPass,
@ -1023,6 +1042,7 @@ internal sealed record GpuFractalSplatReceipt(
int MeasuredFrames,
int BytesPerSplat,
int BytesPerReservoir,
int BytesPerFlameState,
double GpuMillisecondsPerFrame,
double GpuEquivalentFps,
double GpuSplatsPerSecond,