Close planetary patch performance and arrival gates
This commit is contained in:
parent
c1d250c351
commit
c3a78af2f3
9 changed files with 92 additions and 16 deletions
|
|
@ -43,9 +43,9 @@ erased the same surface, and consumed most of the former frame budget.
|
|||
| 3. Physical bands | Complete | Wavelength selection, fractional terminal octave, unresolved bound |
|
||||
| 4. GPU pages | Complete | Spherical borders, sibling seam tests, GPU summary reduction |
|
||||
| 5. Page-backed intersection | Complete | Persistent page and summary buffers, conservative bounds/steps, bracketed refinement, radial hit parity |
|
||||
| 6. Quadtree transitions | In progress | Residual atlas and lifecycle probes complete; visible no-pop capture remains |
|
||||
| 6. Quadtree transitions | In progress | Exact 0/0.5/1 arrival captures and lifecycle probes complete; visible edge/eviction traversal remains |
|
||||
| 7. Unified differentials/materials | Complete | World-gradient pages, composed radial normals, shared ridge/gully material evidence |
|
||||
| 8. Profiling/backend decision | In progress | Raster-patch lowering visible at 0.071 ms; 1.37 ms recorded GPU frame and 83.3 KiB roots; page-generation and traversal captures remain |
|
||||
| 8. Profiling/backend decision | Complete | Orbit-to-ground raster path, page generation, residency, and total frame fit named budgets |
|
||||
|
||||
“Complete” here means the phase exit criterion has evidence. It does not mean
|
||||
planetary-scale rendering as a whole is complete.
|
||||
|
|
@ -179,6 +179,12 @@ Cube-face UV differences are not the visible-normal authority. Authored
|
|||
residuals publish compatible derivatives or use the same bounded sampling
|
||||
contract.
|
||||
|
||||
The raster lowering derives its visible normal from screen derivatives of the
|
||||
four-step refined world position, oriented toward the camera with a radial
|
||||
fallback. This differentiates the final composed surface without repeating five
|
||||
base-field evaluations per pixel. CPU queries and the direct oracle retain the
|
||||
analytic planet-space differential contract.
|
||||
|
||||
## LOD and frequency bands
|
||||
|
||||
The terrain is one spectrum evaluated through different filters, not separate
|
||||
|
|
@ -295,10 +301,13 @@ for a 60 Hz frame. The first six-root measurement is 2,646 page samples,
|
|||
approximately 83.3 KiB resident, and about 0.04--0.05 ms for the patch draw.
|
||||
The visible six-root capture measures approximately 0.071 ms for patch raster
|
||||
and refinement, 0.932 ms for the complete candidate pass, and 1.37 ms recorded
|
||||
GPU work, with 2,646 samples occupying about 83.3 KiB. The earlier 24--26 ms
|
||||
GPU work, with 2,646 samples occupying about 83.3 KiB. At the exterior ground
|
||||
camera, eleven pages occupy 152.6 KiB, repeated page generation measures 0.624
|
||||
ms, the 64 by 64 patch measures 0.799 ms, and recorded GPU work is 1.649 ms.
|
||||
The earlier 24--26 ms
|
||||
frame and black capture came from the obsolete fractal-splat planet writer,
|
||||
which repainted the patch and is no longer published by Zyphos. Page generation
|
||||
and descent/transition captures still require acceptance evidence.
|
||||
and the selected raster lowering therefore fit the named budgets.
|
||||
|
||||
## Verification matrix
|
||||
|
||||
|
|
@ -335,8 +344,8 @@ Measure the actual visible path.
|
|||
Finish the raster-patch proof before expanding the quadtree or polishing the
|
||||
surface:
|
||||
|
||||
1. Capture orbit, LOD midpoint, arrival, eviction, and ground views using the
|
||||
deterministic camera-distance control.
|
||||
1. Capture cube-edge lateral traversal and a frozen residual-eviction sequence;
|
||||
arrival, orbit, and exterior-ground evidence are complete.
|
||||
2. Compare the four-step page-backed hit against the direct CPU/GPU oracle at
|
||||
patch interiors, silhouettes, cube edges, and transition midpoints.
|
||||
3. Complete the patch-stage compiler run and record its result separately from
|
||||
|
|
|
|||
|
|
@ -564,6 +564,7 @@ public sealed class AquariumPlanetarySurfacePageSet
|
|||
public long PresentationVersion { get; init; }
|
||||
public IReadOnlyList<AquariumPlanetarySurfacePage> Pages { get; init; } = [];
|
||||
public bool RenderCoarsePatches { get; init; }
|
||||
public int PatchCells { get; init; } = 16;
|
||||
public int SampleCount => Pages.Sum(page => page.Samples.Count);
|
||||
public bool HasInput => ContentVersion != 0 && Pages.Count > 0 && Pages.All(page => page.HasInput);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -327,6 +327,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private AquariumPlanetarySurfacePageSet activePlanetarySurfacePages = AquariumPlanetarySurfacePageSet.Empty;
|
||||
private long residentPlanetarySurfacePageContentVersion;
|
||||
private long residentPlanetarySurfacePagePresentationVersion;
|
||||
private int residentPlanetarySurfacePatchCells;
|
||||
private D3D12StructuredBuffer fieldReservoirCandidateBuffer = null!;
|
||||
private D3D12StructuredBuffer fieldReservoirLockBuffer = null!;
|
||||
private readonly List<D3D12TubeFieldDrawBatch> tubeFieldDrawBatches = [];
|
||||
|
|
@ -433,6 +434,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private readonly D3D12ShaderPaths shaderPaths;
|
||||
private readonly CompiledRenderGraph renderGraph;
|
||||
private readonly bool hasSceneRenderingPass;
|
||||
private readonly bool profilePlanetarySurfacePages;
|
||||
private readonly Stopwatch shaderReloadClock = Stopwatch.StartNew();
|
||||
private readonly Dictionary<string, DateTime> shaderWriteTimesUtc = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly double[] accumulatedGpuTimingMilliseconds = new double[(int)D3D12GpuTimingPass.Count];
|
||||
|
|
@ -476,6 +478,10 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
renderGraph = D3D12RenderGraphCompiler.Compile(activeRenderPlan);
|
||||
hasSceneRenderingPass = renderGraph.Passes.Any(static pass =>
|
||||
pass.Kind is AquariumPassKind.Fullscreen or AquariumPassKind.Proxy or AquariumPassKind.Instanced or AquariumPassKind.Compute);
|
||||
profilePlanetarySurfacePages = string.Equals(
|
||||
Environment.GetEnvironmentVariable("AQUARIUM_PROFILE_PLANETARY_PAGES"),
|
||||
"1",
|
||||
StringComparison.Ordinal);
|
||||
shaderSourceRoot = ResolveShaderSourceRoot(shaderPath, activeRenderPlan.Shaders);
|
||||
shaderPaths = D3D12ShaderPaths.FromManifest(shaderSourceRoot, activeRenderPlan.Shaders);
|
||||
sdfProxyPipelineStates = new ID3D12PipelineState?[shaderPaths.SdfShaders.Count];
|
||||
|
|
@ -3175,7 +3181,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
context.CommandList.SetGraphicsRootShaderResourceView(RootPlanetarySurfacePageSummary, planetarySurfacePageSummaryBuffer.Resource.GPUVirtualAddress);
|
||||
context.CommandList.SetGraphicsRootShaderResourceView(RootPlanetarySurfacePageSet, planetarySurfacePageSetBuffer.Resource.GPUVirtualAddress);
|
||||
context.CommandList.SetPipelineState(planetarySurfacePatchPipelineState!);
|
||||
context.CommandList.DrawInstanced(16u * 16u * 6u, 6, 0, 0);
|
||||
var patchCells = (uint)Math.Clamp(activePlanetarySurfacePages.PatchCells, 1, 256);
|
||||
context.CommandList.DrawInstanced(patchCells * patchCells * 6u, 6, 0, 0);
|
||||
EndGpuTiming(context.CommandList, frameResources, D3D12GpuTimingPass.PlanetarySurfacePatches);
|
||||
}
|
||||
|
||||
|
|
@ -3938,6 +3945,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
planetarySurfacePageSetBuffer = new D3D12StructuredBuffer(device, 1, 16, "Aquarium Planetary Page Set");
|
||||
residentPlanetarySurfacePageContentVersion = 0;
|
||||
residentPlanetarySurfacePagePresentationVersion = 0;
|
||||
residentPlanetarySurfacePatchCells = 0;
|
||||
}
|
||||
|
||||
private void DispatchPlanetarySurfacePage(ID3D12GraphicsCommandList activeCommandList, FrameResources frameResources)
|
||||
|
|
@ -3951,6 +3959,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
planetarySurfacePageSetBuffer.Upload(activeCommandList, frameResources.UploadRing, new[] { Vector4.Zero });
|
||||
residentPlanetarySurfacePageContentVersion = 0;
|
||||
residentPlanetarySurfacePagePresentationVersion = 0;
|
||||
residentPlanetarySurfacePatchCells = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -3965,13 +3974,15 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
metadata[pageIndex] = page.Metadata with { Layout = new Vector4(sampleOffset, page.Metadata.Layout.Y, page.Metadata.Layout.Z, page.Metadata.Layout.W) };
|
||||
sampleOffset += page.Samples.Count;
|
||||
}
|
||||
if (residentPlanetarySurfacePagePresentationVersion != activePlanetarySurfacePages.PresentationVersion)
|
||||
var patchCells = Math.Clamp(activePlanetarySurfacePages.PatchCells, 1, 256);
|
||||
if (residentPlanetarySurfacePagePresentationVersion != activePlanetarySurfacePages.PresentationVersion || residentPlanetarySurfacePatchCells != patchCells)
|
||||
{
|
||||
planetarySurfacePageMetadataBuffer.Upload(activeCommandList, frameResources.UploadRing, metadata);
|
||||
planetarySurfacePageSetBuffer.Upload(activeCommandList, frameResources.UploadRing, new[] { new Vector4(pages.Count, 0, 0, 1) });
|
||||
planetarySurfacePageSetBuffer.Upload(activeCommandList, frameResources.UploadRing, new[] { new Vector4(pages.Count, patchCells, 0, 1) });
|
||||
residentPlanetarySurfacePagePresentationVersion = activePlanetarySurfacePages.PresentationVersion;
|
||||
residentPlanetarySurfacePatchCells = patchCells;
|
||||
}
|
||||
if (residentPlanetarySurfacePageContentVersion == activePlanetarySurfacePages.ContentVersion) return;
|
||||
if (residentPlanetarySurfacePageContentVersion == activePlanetarySurfacePages.ContentVersion && !profilePlanetarySurfacePages) return;
|
||||
BeginGpuTiming(activeCommandList, frameResources, D3D12GpuTimingPass.PlanetarySurfacePages);
|
||||
planetarySurfacePageInputBuffer.Upload(activeCommandList, frameResources.UploadRing, samples);
|
||||
planetarySurfacePageOutputBuffer.Transition(activeCommandList, ResourceStates.UnorderedAccess);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
#include "D3D12ZyphosPlanet.hlsl"
|
||||
|
||||
static const uint ZY_PATCH_CELLS = 16u;
|
||||
static const uint ZY_PATCH_VERTICES = ZY_PATCH_CELLS * ZY_PATCH_CELLS * 6u;
|
||||
|
||||
struct ZyPatchVertexOut
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
|
|
@ -26,9 +23,10 @@ float3 zyPatchDirection(uint face,float2 local)
|
|||
|
||||
ZyPatchVertexOut D3D12ZyphosTerrainPatchVS(uint vertexId:SV_VertexID,uint instanceId:SV_InstanceID)
|
||||
{
|
||||
uint cell=vertexId/6u,corner=vertexId%6u; uint x=cell%ZY_PATCH_CELLS,y=cell/ZY_PATCH_CELLS;
|
||||
uint patchCells=(uint)max(zy_planet_page_set[0].state.y,1.0);
|
||||
uint cell=vertexId/6u,corner=vertexId%6u; uint x=cell%patchCells,y=cell/patchCells;
|
||||
uint2 offsets[6]={uint2(0,0),uint2(1,0),uint2(1,1),uint2(0,0),uint2(1,1),uint2(0,1)};
|
||||
float2 local=(float2(x,y)+offsets[corner])/(float)ZY_PATCH_CELLS;
|
||||
float2 local=(float2(x,y)+offsets[corner])/(float)patchCells;
|
||||
ZyPlanetPageMetadata root=zy_planet_page_metadata[instanceId]; float3 dir=zyPatchDirection((uint)root.address.x,local);
|
||||
SdfObject planet=sdfObjects[0]; float height=zyTerrainOffset(dir,planet); if(!isfinite(height))height=0.0;
|
||||
float captureMargin=zyTerrainPatchCaptureMargin(dir);
|
||||
|
|
@ -52,7 +50,10 @@ ZyPatchSceneOut D3D12ZyphosTerrainPatchPS(ZyPatchVertexOut input)
|
|||
}
|
||||
if(!all(isfinite(p)))p=coarsePosition;
|
||||
float travel=length(p-cameraPosition); if(!isfinite(travel)||travel<=0.0||travel>farDistance)discard;
|
||||
float3 radial=normalize(p-planet.centerRadius.xyz); float3 normal=zyPlanetSurfaceNormal(p,0); if(!all(isfinite(normal))||dot(normal,normal)<0.25)normal=radial;
|
||||
float3 radial=normalize(p-planet.centerRadius.xyz);
|
||||
float3 normal=cross(ddy(p),ddx(p));
|
||||
if(!all(isfinite(normal))||dot(normal,normal)<1.0e-10)normal=radial; else normal=normalize(normal);
|
||||
if(dot(normal,cameraPosition-p)<0.0)normal=-normal;
|
||||
SdfSurface surface=sdfSurface(p,0);
|
||||
ZyPatchSceneOut output; output.colorTravel=float4(shadeSdf(0.0,travel,p,normal,0,surface),min(travel,farDistance+1.0));
|
||||
output.metadata=float4(FIELD_ID_SDF_OBJECT_BASE,normal); output.control=float4(1,4.0/384.0,saturate(surface.temporalDetail),saturate(surface.reservoirConfidence));
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ internal static class ZyphosPlanetarySurfacePages
|
|||
lastTimeSeconds=float.NegativeInfinity;
|
||||
}
|
||||
|
||||
internal static void PrimeForCapture(Vector3 cameraPosition, float pageAgeSeconds)
|
||||
{
|
||||
Reset();
|
||||
_ = ForCamera(cameraPosition, -Math.Max(pageAgeSeconds, 0.0f));
|
||||
}
|
||||
|
||||
public static AquariumPlanetarySurfacePageSet ForCamera(Vector3 cameraPosition, float timeSeconds)
|
||||
{
|
||||
if (timeSeconds < lastTimeSeconds)
|
||||
|
|
@ -69,6 +75,7 @@ internal static class ZyphosPlanetarySurfacePages
|
|||
PresentationVersion = presentationVersion,
|
||||
Pages = pages,
|
||||
RenderCoarsePatches = true,
|
||||
PatchCells = 64,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,17 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
|
||||
public ZyphosRuntime()
|
||||
{
|
||||
var captureDomain = Environment.GetEnvironmentVariable("AQUARIUM_ZYPHOS_DOMAIN");
|
||||
if (!string.IsNullOrWhiteSpace(captureDomain))
|
||||
{
|
||||
var domain = ZyphosSpatialDomainCatalog.Domains.FirstOrDefault(candidate =>
|
||||
string.Equals(candidate.Key.Value, captureDomain, StringComparison.OrdinalIgnoreCase));
|
||||
if (domain is not null)
|
||||
{
|
||||
selectedDomainKey = domain.Key;
|
||||
autoOrbit = false;
|
||||
}
|
||||
}
|
||||
if (float.TryParse(
|
||||
Environment.GetEnvironmentVariable("AQUARIUM_ZYPHOS_ORBIT_DISTANCE"),
|
||||
NumberStyles.Float,
|
||||
|
|
@ -86,6 +97,16 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
orbitDistance = ClampOrbitDistance(captureDistance);
|
||||
autoOrbit = false;
|
||||
}
|
||||
if (float.TryParse(
|
||||
Environment.GetEnvironmentVariable("AQUARIUM_ZYPHOS_PAGE_AGE_SECONDS"),
|
||||
NumberStyles.Float,
|
||||
CultureInfo.InvariantCulture,
|
||||
out var pageAgeSeconds))
|
||||
{
|
||||
timeScale = 0.0f;
|
||||
autoOrbit = false;
|
||||
ZyphosPlanetarySurfacePages.PrimeForCapture(CurrentShot().CameraPosition, pageAgeSeconds);
|
||||
}
|
||||
var ui = new AquariumUiDocument()
|
||||
.Panel("Zyphos", 18.0f, 82.0f, 340.0f, panel =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -115,6 +115,14 @@ invariants:
|
|||
page-backed candidate. Fractal grammar and authored brushes remain inputs
|
||||
to terrain composition; `PlanetarySurfacePages` plus the patch lowering own
|
||||
the visible surface and corrected pixel depth.
|
||||
- Patch density is explicit page-set policy, carried to GPU in page-set state
|
||||
rather than hardcoded independently in C# and HLSL. Zyphos currently uses a
|
||||
64 by 64 grid per root face; fine relief remains a four-step per-pixel page
|
||||
refinement. Raster normals use derivatives of the refined world position,
|
||||
while CPU/direct queries retain the analytic planet-space differential.
|
||||
`AQUARIUM_PROFILE_PLANETARY_PAGES=1` deliberately regenerates unchanged
|
||||
pages so their one-shot GPU cost can be measured; production content-version
|
||||
caching remains authoritative.
|
||||
- Planetary page residency separates content from presentation state.
|
||||
ContentVersion changes only when the resident tile set changes;
|
||||
PresentationVersion carries arrival/departure weights without regenerating
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ public sealed class ZyphosFractalTerrainTests
|
|||
|
||||
Assert.False(scene.FractalReservoirField.HasInput);
|
||||
Assert.True(scene.PlanetarySurfacePages.RenderCoarsePatches);
|
||||
Assert.Equal(64, scene.PlanetarySurfacePages.PatchCells);
|
||||
Assert.NotEmpty(scene.PlanetarySurfacePages.Pages);
|
||||
Assert.NotEmpty(scene.HeightFieldBrushes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,23 @@ public sealed class D3D12PlanetarySurfacePageTests
|
|||
Assert.All(reloaded.Pages.Skip(6),page=>Assert.Equal(0.0f,page.Metadata.State.Y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CapturePrimingProducesAnExactResidualArrivalMidpoint()
|
||||
{
|
||||
var camera=ZyphosUmbrosSystem.ZyphosCenter+Vector3.Normalize(new Vector3(0.2f,-0.4f,0.9f))*4.1f;
|
||||
try
|
||||
{
|
||||
ZyphosPlanetarySurfacePages.PrimeForCapture(camera,0.175f);
|
||||
var pages=ZyphosPlanetarySurfacePages.ForCamera(camera,0.0f);
|
||||
Assert.All(pages.Pages.Take(6),page=>Assert.Equal(1.0f,page.Metadata.State.Y));
|
||||
Assert.All(pages.Pages.Skip(6),page=>Assert.Equal(0.5f,page.Metadata.State.Y,3));
|
||||
}
|
||||
finally
|
||||
{
|
||||
ZyphosPlanetarySurfacePages.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZyphosPlanetaryProxyShadersCompileWithPageBindings()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue