perf(gen): interval propagation -- blocks can finally be PROVEN empty. 1.55s -> 1.21s
Task 4 ran 11 hours and was killed by system memory pressure before it could file a report. The work survived, builds clean (0 errors), and is verified faster with byte-identical output. This commit is my verification, not its summary -- it never got to write one. THE STRUCTURAL FIX0e9df9eestablished why no block could ever be skipped: OriginSpineOp, PassageCarveOp and the active seals Lerp/Min/Max against the CURRENT density, so with an unknown incoming density their supremum is genuinely unbounded. Not a missing bound -- the operator semantics. The answer is to propagate a density INTERVAL through the stack, and that is what landed: FVoxelBoxSdfInterval + PropagateSdfOverBox on the operator interface, an interval fold through every converter and modifier, interval arithmetic down into the noise primitives themselves (gradient corners, warp, worm frequencies), and a BlockSkip lattice the mesher consults per 8^3 block. Its own guiding comment, which is the right default: "no finite interval is a proof. Unknown costs the skip and protects the geometry." 128^3 TunnelNetwork seed 1337 slot 1, freshly built binary, 3 runs each: before 1.515 / 1.554 / 1.569 s after 1.213 / 1.258 / 1.171 s -22.5%, 1.28x -- clears the 17% floor Geometry SHA-256 98eaad61..d3c4f IDENTICAL to0e9df9e. 153,740 triangles either way. It skips only provably-empty work; nothing about the world changed. It also fixed one cause of the 5.6 s empty tiles found in0e9df9e: an LOD4 tile legitimately spans 19^3 = 6,859 chunk keys and was rebuilding per-chunk state thousands of times within a single tile. A shared cache removed that failure mode; remaining slow empties were LOD0 and are a separate fast-classifier bail, still open. Partially landed, unfinished when killed: RequestStartCycles on FChunkResult, to report request-to-ready latency rather than worker generation time. Harmless as is. ⚠️ WHAT KILLED IT, AND IT IS OURS A single UnrealEditor-Cmd commandlet grew to 19.5 GB, leaving 1.3 GB free on a 32 GB machine, and the OS killed the agent. Freeing it restored 21.6 GB. The owner said twice that his machine should not be under memory pressure and he was right both times: first the 411 MiB worker caches, now a 19.5 GB commandlet. A generation run must not need 19.5 GB. Next task. Cumulative on this region: 342.2 -> 16.2 -> 2.62 -> 1.49 -> 1.21 s (~283x). 3,374 insertions / 342 deletions across 12 files. Build 0 errors. Nothing outside Plugins/VoxelForge; RealtimeMeshComponent untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aheo2crrZmHuYtPpdY2Cb
This commit is contained in:
1 parent
0e9df9e5a7
commit
d38d4cabef
12 files changed
+3375
-343
No files matched your search
@@ -227,6 +227,85 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
|
||||
|
||||
MesherSetupTimer.End();
|
||||
|
||||
// Optional 8x8x8-cell block proof. The tile classifier has already returned Mixed, but
|
||||
// that is a conservative answer over the whole tile. A tile can still be uniformly solid
|
||||
// (or uniformly air) when its smaller blocks are each provable. Do this before allocating
|
||||
// or filling the density grid: the grid is only needed when at least one block can contain
|
||||
// a surface. A whole-tile early return is allowed only when every relevant block has the
|
||||
// SAME verdict; adjacent uniform blocks with opposite signs can contain a surface between
|
||||
// them. This is a proof-only optimization: ClassifyTile is conservative and no samples or
|
||||
// resolution are removed from a tile that reaches the mesher.
|
||||
TArray<uint8> BlockSkip;
|
||||
int32 BlocksPerAxis = 0;
|
||||
if (bUseBlockEarlyOut && !OutCaptureGrid && Step == 1)
|
||||
{
|
||||
constexpr int32 BlockCells = 8;
|
||||
BlocksPerAxis = (CellsPerAxis + BlockCells - 1) / BlockCells;
|
||||
BlockSkip.Init(0, BlocksPerAxis * BlocksPerAxis * BlocksPerAxis);
|
||||
bool bHaveUniformBlock = false;
|
||||
EVoxelTileClass FirstUniformVerdict = EVoxelTileClass::Mixed;
|
||||
bool bAllRelevantBlocksUniform = true;
|
||||
bool bAllRelevantBlocksSame = true;
|
||||
|
||||
for (int32 BlockZ = 0; BlockZ < BlocksPerAxis; ++BlockZ)
|
||||
{
|
||||
const int32 BlockMinZ = BlockZ * BlockCells;
|
||||
const int32 BlockMaxZ = FMath::Min(CellsPerAxis - 1,
|
||||
BlockMinZ + BlockCells - 1);
|
||||
if (BlockMaxZ < CzLo || BlockMinZ > CzHi)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int32 BlockY = 0; BlockY < BlocksPerAxis; ++BlockY)
|
||||
{
|
||||
for (int32 BlockX = 0; BlockX < BlocksPerAxis; ++BlockX)
|
||||
{
|
||||
const FIntVector BlockOrigin = OriginVoxels + FIntVector(
|
||||
BlockX * BlockCells * Step,
|
||||
BlockY * BlockCells * Step,
|
||||
BlockMinZ * Step);
|
||||
if (VoxelDensityProfile::AreCountersEnabled())
|
||||
{
|
||||
VoxelDensityProfile::AddCounter(
|
||||
VoxelDensityProfile::ECounter::MesherBlockTests);
|
||||
}
|
||||
const EVoxelTileClass Verdict = Generator->ClassifyTile(
|
||||
BlockOrigin, Step, BlockCells);
|
||||
if (Verdict == EVoxelTileClass::AllSolid
|
||||
|| Verdict == EVoxelTileClass::AllAir)
|
||||
{
|
||||
BlockSkip[((BlockZ * BlocksPerAxis) + BlockY) * BlocksPerAxis + BlockX] = 1;
|
||||
if (VoxelDensityProfile::AreCountersEnabled())
|
||||
{
|
||||
VoxelDensityProfile::AddCounter(
|
||||
Verdict == EVoxelTileClass::AllSolid
|
||||
? VoxelDensityProfile::ECounter::MesherBlockAllSolid
|
||||
: VoxelDensityProfile::ECounter::MesherBlockAllAir);
|
||||
}
|
||||
if (!bHaveUniformBlock)
|
||||
{
|
||||
FirstUniformVerdict = Verdict;
|
||||
bHaveUniformBlock = true;
|
||||
}
|
||||
else if (FirstUniformVerdict != Verdict)
|
||||
{
|
||||
bAllRelevantBlocksSame = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bAllRelevantBlocksUniform = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bHaveUniformBlock && bAllRelevantBlocksUniform && bAllRelevantBlocksSame)
|
||||
{
|
||||
return MeshData;
|
||||
}
|
||||
}
|
||||
|
||||
// Réutilise le tampon entre tuiles (thread_local) : SetNumUninitialized garde la
|
||||
// capacité, donc plus de malloc/free de ~170 Ko (35³ floats) par tuile.
|
||||
static thread_local TArray<float> DensityGrid;
|
||||
@@ -285,58 +364,6 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
|
||||
}
|
||||
MesherDensityGridTimer.End();
|
||||
|
||||
// Optional 8x8x8-cell block early-out. ClassifyTile uses the same one-point halo and the
|
||||
// same cave/disturbance/diff-layer guards as production tile loading. It is deliberately
|
||||
// performed after the density grid is complete: skipping only the Marching Cubes work keeps
|
||||
// the grid, capture buffer, geometry, normals, and all density-side effects identical.
|
||||
TArray<uint8> BlockSkip;
|
||||
int32 BlocksPerAxis = 0;
|
||||
if (bUseBlockEarlyOut)
|
||||
{
|
||||
constexpr int32 BlockCells = 8;
|
||||
BlocksPerAxis = (CellsPerAxis + BlockCells - 1) / BlockCells;
|
||||
BlockSkip.Init(0, BlocksPerAxis * BlocksPerAxis * BlocksPerAxis);
|
||||
for (int32 BlockZ = 0; BlockZ < BlocksPerAxis; ++BlockZ)
|
||||
{
|
||||
const int32 BlockMinZ = BlockZ * BlockCells;
|
||||
const int32 BlockMaxZ = FMath::Min(CellsPerAxis - 1,
|
||||
BlockMinZ + BlockCells - 1);
|
||||
if (BlockMaxZ < CzLo || BlockMinZ > CzHi)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int32 BlockY = 0; BlockY < BlocksPerAxis; ++BlockY)
|
||||
{
|
||||
for (int32 BlockX = 0; BlockX < BlocksPerAxis; ++BlockX)
|
||||
{
|
||||
const FIntVector BlockOrigin = OriginVoxels + FIntVector(
|
||||
BlockX * BlockCells * Step,
|
||||
BlockY * BlockCells * Step,
|
||||
BlockMinZ * Step);
|
||||
if (VoxelDensityProfile::AreCountersEnabled())
|
||||
{
|
||||
VoxelDensityProfile::AddCounter(
|
||||
VoxelDensityProfile::ECounter::MesherBlockTests);
|
||||
}
|
||||
const EVoxelTileClass Verdict = Generator->ClassifyTile(
|
||||
BlockOrigin, Step, BlockCells);
|
||||
if (Verdict == EVoxelTileClass::AllSolid
|
||||
|| Verdict == EVoxelTileClass::AllAir)
|
||||
{
|
||||
BlockSkip[((BlockZ * BlocksPerAxis) + BlockY) * BlocksPerAxis + BlockX] = 1;
|
||||
if (VoxelDensityProfile::AreCountersEnabled())
|
||||
{
|
||||
VoxelDensityProfile::AddCounter(
|
||||
Verdict == EVoxelTileClass::AllSolid
|
||||
? VoxelDensityProfile::ECounter::MesherBlockAllSolid
|
||||
: VoxelDensityProfile::ECounter::MesherBlockAllAir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── CAPTURE-DURING-MESHING ──
|
||||
// Si demandé et que la tuile est pleine résolution (CellsPerAxis==CHUNK_SIZE ⇒ Step==1<<Level,
|
||||
// donc chaque point de grille = exactement une cellule du clipmap de densité), on recopie les
|
||||
@@ -396,7 +423,7 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
|
||||
if (ShouldAbortWork()) return FVoxelMeshData();
|
||||
for (int32 cx = 0; cx < CellsPerAxis; cx++)
|
||||
{
|
||||
if (bUseBlockEarlyOut
|
||||
if (bUseBlockEarlyOut && Step == 1
|
||||
&& BlockSkip[((cz / 8) * BlocksPerAxis + (cy / 8)) * BlocksPerAxis + (cx / 8)] != 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user