Decouple GPU splat generation from domain depth

This commit is contained in:
Meta Vens 2026-05-20 08:33:20 +01:00
commit c599310195
6 changed files with 24 additions and 6 deletions

View file

@ -1783,7 +1783,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)activeFractalReservoirField.CandidatesPerReservoirUpdate, 4);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)activeFractalReservoirField.ReservoirUpdatesPerPass, 5);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, (uint)activeFractalProgramTransforms.Length, 6);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, 0u, 7);
activeCommandList.SetComputeRoot32BitConstant(RootFractalConstants, activeFractalProgramTransforms.Length > 0 ? 1u : 0u, 7);
}
private void CreateGpuSensorTextureViews(AquariumGpuSensorFrame sensorFrame, D3D12DescriptorSlot firstDescriptor)

View file

@ -74,6 +74,22 @@ float Random01(uint value)
float3 FractalPoint(uint index, out float radius)
{
if (ProgramTransformCount > 0u && ProgramMode == 1u)
{
uint h = Hash(index ^ Seed);
uint transformIndex = h % ProgramTransformCount;
FractalIfsTransform transform = ProgramTransforms[transformIndex];
float rx = Random01(h + FrameIndex * 17u) * 2.0 - 1.0;
float ry = Random01(h + 7919u) * 2.0 - 1.0;
float c = transform.rotationDomain.x;
float s = transform.rotationDomain.y;
float2 local = float2(rx * transform.radiiRotationFalloff.x, ry * transform.radiiRotationFalloff.y) * 0.65;
float2 rotated = float2((local.x * c) - (local.y * s), (local.x * s) + (local.y * c));
radius = max(max(transform.radiiRotationFalloff.x, transform.radiiRotationFalloff.y) * (0.34 + Random01(h + 104729u) * 0.16), 0.0001);
float z = transform.offsetScaleAmplitude.w + (Random01(h + 1299721u) - 0.5) * radius * 0.2;
return float3(transform.offsetScaleAmplitude.xy + rotated, z + transform.materialSeedShape.x * 0.05);
}
if (ProgramTransformCount > 0u)
{
uint n = index ^ Seed;

View file

@ -184,3 +184,4 @@
{"timestamp":"2026-05-20T07:47:00+01:00","topic":"layered-fractal-reservoir-consumption","lesson":"The visible fractal splat draw must consume the same independent reservoir layers produced by compute. Reusing the temporal Gaussian descriptor slot for raw splats hid the SDF/PBR/radiosity contract. The renderer now binds raw splats plus SDF envelope, PBR material, and radiosity reservoirs as separate graphics SRVs; the debug draw uses SDF reservoirs for support, PBR reservoirs for color, radiosity reservoirs for energy, and writes per-layer confidence into the reservoir guide MRT. This is still a capped debug view, but it proves the three-layer reservoir machine reaches visible pixels without CPU readback or buffer collapse.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl","state/map.yaml","state/memory.json"],"source":"user insisted SDF splats, PBR splats, and radiosity splats are different sampled types and the Perfect Machine must not flatten them"}
{"timestamp":"2026-05-20T08:04:00+01:00","topic":"authored-ifs-program-gpu-splat-population","lesson":"The GPU splat producer now has a compact authored-program path. `FractalGpuProgramCompiler` lowers selected `.aquageo` claims into `AquariumPackedFractalIfsTransform` rows, Zyphos passes those rows through `AquariumFractalReservoirField.ProgramTransforms`, and D3D12 uploads them as a small compute SRV before dispatch. `D3D12FractalReservoirCompute.hlsl` uses those transforms when present and keeps the old hash fractal only as fallback/receipt mode. This keeps million-splat population GPU-resident while making the source fractal structure come from the DSL instead of private shader folklore.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","src/Aquarium.Engine.Fractal/Lod/FractalGpuProgramCompiler.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","src/Aquarium.Zyphos/ZyphosSceneBuilder.cs","tests/Aquarium.Engine.Fractal.Tests/FractalGpuProgramCompilerTests.cs"],"source":"continued Perfect Machine build: replace hardcoded GPU splat generation with a DSL-driven program seam"}
{"timestamp":"2026-05-20T08:16:00+01:00","topic":"authored-ifs-program-gpu-receipt","lesson":"The receipt harness now has a nonzero authored-program mode via `-ProgramTransforms`. On the GTX 1070, 2,000,000 splats plus 2,000,000 SDF, PBR, and radiosity reservoirs per layer with 4 IFS transforms, depth 1, 20,000 stochastic updates per reservoir layer, and 2 candidates/update measured 4.438 ms/frame, 225.3 FPS equivalent, with full reservoir coverage in 100 frames. Depth 2 and 4 are below the hundreds-FPS bar at this budget, so deeper authored IFS generation needs a better shader strategy or adaptive depth/cut scheduling instead of pretending the simple receipt covers all fractal detail depths.","files":["tools/Aquarium.Fractal.Receipt/Program.cs","scripts/fractal-splat-receipt.ps1","src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","state/map.yaml","state/memory.json"],"source":"user demanded a receipt showing millions of splats populating a simple fractal at hundreds of FPS"}
{"timestamp":"2026-05-20T08:32:00+01:00","topic":"precomposed-selected-cut-splat-generation","lesson":"Nested domain ancestry must not be replayed inside the million-splat compute kernel. Authored program mode now treats `AquariumPackedFractalIfsTransform` rows as precomposed selected-cut support packets and samples one row per splat in O(1); the CPU/compiler/planner owns collapsing planetary/cave/mushroom/rib ancestry into selected supports before GPU dispatch. A depth-48 receipt with 2,000,000 splats, 2,000,000 reservoirs per SDF/PBR/radiosity layer, 4 program rows, 15,000 updates per layer, and 2 candidates/update measured 4.908 ms/frame, 203.7 FPS equivalent on the GTX 1070. Depth is now semantic lineage/planner pressure, not a hot-loop multiplier.","files":["src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","src/Aquarium.Engine/Render/D3D12Renderer.cs","tools/Aquarium.Fractal.Receipt/Program.cs","state/map.yaml","state/memory.json"],"source":"user pointed out real scenes will regularly render nested domains dozens of layers deep"}

View file

@ -136,11 +136,11 @@ renderer_state:
- Fractal resource planning is explicit: one plan coordinates CPU contribution updates, GPU selected-cut estimated cost, RAM resident payload budget, and SSD request pressure before backend packet compilation. This same budget language should generalize to Mimir-style sensor fusion because both fractal SDF probes and camera/microphone feature detections accumulate confidence-weighted spatial samples into temporal reservoirs.
- Fractal residency uses score-per-cost retention under RAM pressure and emits evicted node keys as planner output; real storage mutation waits for a page/payload store boundary.
- 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 receipt binds 4 compact transforms, updates 20,000 entries per reservoir layer per frame, and runs at 4.438 ms/frame, 225.3 FPS equivalent, with full reservoir coverage in 100 frames. Both receipts use only tiny checksum readback and compile the shared engine shader asset src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl.
- 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, and stochastic updates per pass. 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.
- Fractal reservoir population can now be driven by authored `.aquageo` structure: FractalGpuProgramCompiler lowers selected DSL claims into compact AquariumPackedFractalIfsTransform 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 IFS transforms instead of only its hash-fractal fallback.
- 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 131,072-instance debug 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.
- D3D12 capacity logging now reports active fractal reservoir resident MiB, splat count, visible debug splat count, updates/pass, and candidates/update so the GPU cache has a receipt in normal runtime logs, not just in the standalone benchmark.
- 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.

View file

@ -99,8 +99,8 @@
"FractalStructuralProbeReservoir builds a reservoir snapshot from an ownership tree, selected cut, summaries, and projected pixels per world unit. ZyphosFractalRenderPlan now carries this structural probe reservoir, so the planet path exposes reservoir-shaped structural evidence beside brushes/resource plans before GPU reuse exists.",
"AquariumFractalSdfSplat3D is the compact 3D SDF splat packet contract for Phase F. FractalSdfSplat3DCompiler lowers FractalProbeSample evidence into stable domain/node/payload-keyed splats, and FractalSdfSplat3DKernel owns CPU compact-weight/signed-distance parity math. Zyphos exposes a first structural splat from its probe reservoir before D3D12 lowering.",
"Hot fractal splat storage must be GPU-resident packed buffers manipulated by compute shaders. Stable string-keyed splat contracts are metadata/debug boundaries, not million-instance hot buffers. `AquariumPackedFractalSdfSplat3D` is the numeric 80-byte packet shape; C# staging/readback paths use unsafe `FractalNativeBuffer<T>` when CPU memory is genuinely needed.",
"Fractal reservoir compute can now take a compact authored IFS program. `FractalGpuProgramCompiler` lowers selected `.aquageo` brush claims into `AquariumPackedFractalIfsTransform` rows; Zyphos passes those rows through `AquariumFractalReservoirField.ProgramTransforms`; D3D12 uploads the small program as a compute SRV. The hash fractal remains a fallback/receipt mode, not the only live generator.",
"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 IFS-program receipt used 4 compact transforms and 20,000 updates per layer at 4.438 ms/frame, 225.3 FPS equivalent, with full reservoir coverage in 100 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, and first layered GPU consumption; final terrain/material/radiosity shading is still future work.",
"Fractal reservoir compute can now take a compact authored IFS program. `FractalGpuProgramCompiler` lowers selected `.aquageo` brush claims into precomposed `AquariumPackedFractalIfsTransform` support rows; Zyphos passes those rows through `AquariumFractalReservoirField.ProgramTransforms`; D3D12 uploads the small program as a compute SRV. The shader samples one selected-cut row in O(1) for authored programs; nested domain ancestry belongs in the compiler/planner, not the million-splat kernel. The hash fractal remains a fallback/receipt mode, not the live authored generator.",
"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.",
"Zyphos camera distance limits belong to the selected spatial domain, not one global planetary clamp. Leaf/pebble domains must be able to zoom below whole-body distances, and the parent star must be a visible SDF body when it is also the primary light source.",
"The consolidated fractal brush architecture lives in research/rendering/fractal-brush-architecture-plan.md. Its pipeline is client intent -> domain roots -> semantic IFS brush grammar -> ownership tree -> node summaries -> contribution cache/residency scheduler -> backend packets -> renderer passes -> debug/evidence. Its credibility depends on module boundaries and tests: contracts, pure CPU fractal core, D3D12 backend, client adapters, mock payload/probe/random/clock seams, shader parity tests, and deterministic performance fixtures.",

View file

@ -25,6 +25,7 @@ Console.WriteLine($"sdf reservoirs: {receipt.SdfReservoirCount:N0}");
Console.WriteLine($"pbr reservoirs: {receipt.PbrReservoirCount:N0}");
Console.WriteLine($"radiosity reservoirs: {receipt.RadiosityReservoirCount:N0}");
Console.WriteLine($"ifs program transforms: {receipt.ProgramTransformCount:N0}");
Console.WriteLine($"program mode: {(receipt.ProgramTransformCount > 0 ? "precomposed selected cut" : "fallback hash IFS")}");
Console.WriteLine($"candidates/pass: {receipt.CandidatesPerPass}");
Console.WriteLine($"reservoir updates/pass/frame: {receipt.ReservoirUpdatesPerPass:N0}");
Console.WriteLine($"reservoir full-coverage frames: {receipt.ReservoirFullCoverageFrames:0.0}");
@ -270,7 +271,7 @@ internal sealed class GpuFractalSplatReceiptRunner : IDisposable
commandList.SetComputeRoot32BitConstant(0, (uint)options.CandidatesPerPass, 4);
commandList.SetComputeRoot32BitConstant(0, (uint)options.ReservoirUpdatesPerPass, 5);
commandList.SetComputeRoot32BitConstant(0, (uint)options.ProgramTransformCount, 6);
commandList.SetComputeRoot32BitConstant(0, 0u, 7);
commandList.SetComputeRoot32BitConstant(0, options.ProgramTransformCount > 0 ? 1u : 0u, 7);
}
private void CopyReceiptReadback(ID3D12Resource splats, ID3D12Resource sdf, ID3D12Resource pbr, ID3D12Resource radiosity, ID3D12Resource readback, ulong splatBytes, ulong reservoirBytes)