standalone: cheap chunk crossings -- exact-tile slab compile, nearest tiles first (~1.2 s -> 121 ms peak)
- Core compiles exact-tile analytic slabs for entering tiles; a Z-column sampler reuses the coherent
noise context along each tile column; the viewer keeps residents and prioritises nearby tiles.
- 30-crossing straight flight: nearest tile ready 15.8 ms median / 27.6 ms max; full crossing wall
121 ms peak; worker CPU per crossing 545 ms median, 834 ms max.
- W1/W8 hashes equal; routes 5642/5642; look, passage, stair, thin-sheet, coarse-panel and far
audits pass; bad-shell control fails; path-hash audit kept.
Cold whole view, measured by me interleaved (busy machine): 1.242 s vs 1.255 s for 3b37d57, parity.
Still open from the owner (LOD0): fins along a strata seam, choppy stair facets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
1 parent
3b37d5702e
commit
08ceed200d
7 files changed
+614
-86
No files matched your search
+14
-9
@@ -64,15 +64,20 @@ for (const auto& key : entering) {
|
||||
world.retainTileRegions(entering);
|
||||
```
|
||||
|
||||
The Core groups fine tiles into pages using absolute tile coordinates, so a page's contents do not
|
||||
depend on the camera or the order in which the player reaches it. Pages cover a 128-voxel cube (or
|
||||
one larger coarse tile), with an 8-voxel sampling apron. `compileTileRegion` skips LODs at or above
|
||||
`fullResolutionLodCount`, keys covered by the initial `ShapeBuildRequest`, and pages already
|
||||
resident. Its optional output counts requested fine tile keys that needed a newly compiled page;
|
||||
it does not count the page's internal lattice samples. After all pages needed by the next desired
|
||||
set compile, call `retainTileRegions` with that set to release pages no longer needed. The Core
|
||||
owns page lifetime and mesh data; the host keeps still-visible meshes resident until replacement
|
||||
tiles are generated and uploaded.
|
||||
By default, the Core groups missing keys by LOD and builds one analytic primitive/bin region for
|
||||
each entering LOD slab. The region bounds come from the requested absolute tile coordinates, with
|
||||
an 8-voxel sampling apron; no dense lattice is allocated for unused parts of the slab. A tile's
|
||||
samples therefore depend on its world coordinates and the world snapshot, not the camera path or
|
||||
the order in which tiles arrive. `compileTileRegion` skips LODs at or above
|
||||
`fullResolutionLodCount`, keys covered by the initial `ShapeBuildRequest`, and keys already
|
||||
resident. Its optional output counts requested keys that received a new region. After the regions
|
||||
needed by the next desired set compile, call `retainTileRegions` with that set to release regions
|
||||
that are no longer needed. The Core owns region lifetime and mesh data; the host keeps still-visible
|
||||
meshes resident until replacement tiles are generated and uploaded.
|
||||
|
||||
Pass `analyticOnly = false` to retain the reference packed-page compiler. Packed pages use absolute
|
||||
parent-cell coordinates and an 8-voxel apron; each covers a 128-voxel cube or one larger coarse
|
||||
tile. This path remains available for parity checks and workloads that need the packed lattice.
|
||||
|
||||
## Queries and tiles
|
||||
|
||||
|
||||
@@ -148,6 +148,18 @@ namespace VoxelForgeCore
|
||||
std::uint64_t walkFailures = 0;
|
||||
};
|
||||
|
||||
struct TileRegionCompileStats
|
||||
{
|
||||
std::size_t regionsBuilt = 0;
|
||||
std::size_t tileKeysCovered = 0;
|
||||
std::uint64_t latticeNodes = 0;
|
||||
double shapeSeconds = 0.0;
|
||||
double intervalSeconds = 0.0;
|
||||
double surfaceSeconds = 0.0;
|
||||
double workerSeconds = 0.0;
|
||||
double wallSeconds = 0.0;
|
||||
};
|
||||
|
||||
struct FarConnectorSegment { Vec3d start, end; float radius = 0.0f; };
|
||||
|
||||
struct EditBrush
|
||||
@@ -200,12 +212,16 @@ namespace VoxelForgeCore
|
||||
|
||||
bool compile(const ShapeBuildRequest& request, const JobScheduler& scheduler,
|
||||
std::string& error);
|
||||
// Compile any missing absolute-coordinate detail pages needed by entering fine tiles.
|
||||
// The optional count is requested tile keys newly covered by compiled pages, not lattice
|
||||
// samples. Existing pages stay resident until retainTileRegions.
|
||||
// Compile missing detail regions for entering fine tiles. Generated tile keys map to
|
||||
// shared world-coordinate regions. The default analyticOnly path coalesces each entering
|
||||
// LOD slab, builds its primitives/bins, and evaluates density on demand without
|
||||
// rasterizing unused lattice volumes. Set false to use fixed absolute packed pages. The
|
||||
// optional count is newly covered tile keys; regions stay resident until retainTileRegions.
|
||||
bool compileTileRegion(std::span<const TileKey> tiles, std::uint32_t workerLimit,
|
||||
const JobScheduler& scheduler, std::string& error,
|
||||
std::size_t* outCompiledTiles = nullptr);
|
||||
std::size_t* outCompiledTiles = nullptr,
|
||||
TileRegionCompileStats* outStats = nullptr,
|
||||
bool analyticOnly = true);
|
||||
void retainTileRegions(std::span<const TileKey> desiredTiles);
|
||||
void buildFarWorld();
|
||||
bool isCompiled() const noexcept;
|
||||
|
||||
@@ -271,12 +271,14 @@ public:
|
||||
bool bIncludeFarWorld,
|
||||
std::string& Error,
|
||||
const VoxelForgeCore::JobScheduler* InScheduler=nullptr,
|
||||
bool bInRoundTunnels=false,bool bInProfileDetailBand=false)
|
||||
bool bInRoundTunnels=false,bool bInProfileDetailBand=false,
|
||||
bool bValidatePassageRoutes=true)
|
||||
{
|
||||
using Clock=std::chrono::steady_clock;
|
||||
const auto TotalStart=Clock::now();
|
||||
Owner=&World;WorkerCount=std::clamp(Workers,1,8);DetailVariant=Variant;
|
||||
Scheduler=InScheduler;RoundTunnelsEnabled=bInRoundTunnels;
|
||||
bAnalyticOnly=false;
|
||||
bProfileDetailBand=bInProfileDetailBand;
|
||||
for(int32 A=0;A<3;++A)
|
||||
{
|
||||
@@ -321,7 +323,9 @@ public:
|
||||
ApplyDetailBand(Stats.DetailBandLines);
|
||||
Stats.SurfaceProxyNodes+=CompleteSignEdgeDistances();
|
||||
Stats.SurfaceSeconds=std::chrono::duration<double>(Clock::now()-Stage).count();
|
||||
ValidatePassageRoutes();
|
||||
// Route validation is world-wide. Detail regions reuse the same authored route data and
|
||||
// do not need to repeat the 5,642-point world audit for every entering tile group.
|
||||
if(bValidatePassageRoutes)ValidatePassageRoutes();
|
||||
Built=true;
|
||||
if(bIncludeFarWorld)BuildFarWorld();
|
||||
const uint64 WordBytes=static_cast<uint64>(RockWords.size()+CandidateWords.size())*sizeof(uint64);
|
||||
@@ -403,6 +407,35 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuildAnalyticRegion(FStandaloneOwnerWorld& World,const FIntVector& MinVoxels,
|
||||
const FIntVector& MaxVoxels,const FIntVector& ClipMinVoxels,
|
||||
const FIntVector& ClipMaxVoxels,EDetailVariant Variant,
|
||||
bool bInRoundTunnels,std::string& Error)
|
||||
{
|
||||
using Clock=std::chrono::steady_clock;
|
||||
Owner=&World;WorkerCount=1;DetailVariant=Variant;Scheduler=nullptr;
|
||||
RoundTunnelsEnabled=bInRoundTunnels;bAnalyticOnly=true;bProfileDetailBand=false;
|
||||
for(int32 A=0;A<3;++A)
|
||||
{
|
||||
Min[A]=(&MinVoxels.X)[A]-2;Max[A]=(&MaxVoxels.X)[A]+2;
|
||||
ClipMin[A]=(&ClipMinVoxels.X)[A];ClipMax[A]=(&ClipMaxVoxels.X)[A];
|
||||
Size[A]=Max[A]-Min[A]+1;
|
||||
if(Size[A]<=0||Size[A]>4096||ClipMax[A]<ClipMin[A])
|
||||
{Error="analytic tile region is invalid or outside the bounded 4096-node compiler envelope";return false;}
|
||||
}
|
||||
Stats={};
|
||||
const auto Stage=Clock::now();
|
||||
BuildLayerBounds();BuildOwnerPrimitives();
|
||||
if(RoundTunnelsEnabled)BuildRoundTunnelPrimitives();
|
||||
BuildSpatialBins(LineBinSize);
|
||||
Stats.ShapeSeconds=std::chrono::duration<double>(Clock::now()-Stage).count();
|
||||
Stats.PrimitiveCount=Primitives.size();
|
||||
if(Primitives.empty())
|
||||
{Error="owner shape extraction produced no rooms, tunnels, or passages";return false;}
|
||||
Built=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
const FBuildStats& GetStats() const { return Stats; }
|
||||
bool IsBuilt() const { return Built; }
|
||||
bool HasFarWorld() const { return FarBuilt; }
|
||||
@@ -490,7 +523,7 @@ public:
|
||||
{
|
||||
int32 IX=0,IY=0,IZ=0;
|
||||
const bool bInteger=NearInteger(X,IX)&&NearInteger(Y,IY)&&NearInteger(Z,IZ);
|
||||
const bool bPacked=bInteger&&Contains(IX,IY,IZ);
|
||||
const bool bPacked=!bAnalyticOnly&&bInteger&&Contains(IX,IY,IZ);
|
||||
if(bPacked)
|
||||
return PackedDensityAt(IX,IY,IZ,IsRock(IX,IY,IZ),X,Y,Z);
|
||||
return AnalyticDensityAt(X,Y,Z);
|
||||
@@ -498,7 +531,7 @@ public:
|
||||
|
||||
float DensityAtLattice(int32 X,int32 Y,int32 Z) const
|
||||
{
|
||||
const bool bPacked=Contains(X,Y,Z);
|
||||
const bool bPacked=!bAnalyticOnly&&Contains(X,Y,Z);
|
||||
if(bPacked)
|
||||
return PackedDensityAt(X,Y,Z,IsRock(X,Y,Z),static_cast<float>(X),
|
||||
static_cast<float>(Y),static_cast<float>(Z));
|
||||
@@ -506,11 +539,19 @@ public:
|
||||
static_cast<float>(Z));
|
||||
}
|
||||
|
||||
bool IsAnalyticOnly() const { return bAnalyticOnly; }
|
||||
|
||||
void DensityAtLatticeX8(int32 XStart,int32 XStep,int32 Y,int32 Z,
|
||||
int32 Count,float OutDensity[8]) const
|
||||
{
|
||||
Count=std::clamp(Count,0,8);
|
||||
if(Count==0)return;
|
||||
if(bAnalyticOnly)
|
||||
{
|
||||
for(int32 Lane=0;Lane<Count;++Lane)
|
||||
OutDensity[Lane]=DensityAtLattice(XStart+Lane*XStep,Y,Z);
|
||||
return;
|
||||
}
|
||||
bool bFast=EditBrushes.empty()&&Y>=Min[1]&&Y<=Max[1]
|
||||
&&Z>=Min[2]&&Z<=Max[2]
|
||||
&&XStart>=Min[0]
|
||||
@@ -3430,6 +3471,75 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
void DensityAtLatticeZRun(int32 X,int32 Y,int32 ZStart,int32 ZStep,
|
||||
int32 Count,float* OutDensity) const
|
||||
{
|
||||
if(Count<=0||OutDensity==nullptr)return;
|
||||
if(!bAnalyticOnly)
|
||||
{
|
||||
for(int32 Lane=0;Lane<Count;++Lane)
|
||||
OutDensity[Lane]=DensityAtLattice(X,Y,ZStart+Lane*ZStep);
|
||||
return;
|
||||
}
|
||||
|
||||
FDetailNoiseLineContext DetailNoiseLine(
|
||||
static_cast<float>(X),static_cast<float>(Y),static_cast<uint32>(Owner->Seed));
|
||||
for(int32 Offset=0;Offset<Count;)
|
||||
{
|
||||
int32 Z[8];
|
||||
const int32 Remaining=std::min(8,Count-Offset);
|
||||
for(int32 Lane=0;Lane<Remaining;++Lane)
|
||||
Z[Lane]=ZStart+(Offset+Lane)*ZStep;
|
||||
const int32 BinZ=FloorDiv(Z[0],ActiveSpatialBinSize);
|
||||
const auto Found=SpatialBins.find({FloorDiv(X,ActiveSpatialBinSize),
|
||||
FloorDiv(Y,ActiveSpatialBinSize),BinZ});
|
||||
const FBinItems* BinItems=Found==SpatialBins.end()?nullptr:&Found->second;
|
||||
int32 BatchCount=1;
|
||||
while(BatchCount<Remaining
|
||||
&&FloorDiv(Z[BatchCount],ActiveSpatialBinSize)==BinZ)++BatchCount;
|
||||
|
||||
FEffectiveRockSample Samples[8]{};
|
||||
EffectiveRockDistanceZ8(X,Y,Z,BatchCount,BinItems,Samples);
|
||||
for(int32 Lane=0;Lane<BatchCount;++Lane)
|
||||
{
|
||||
const int32 SampleZ=Z[Lane];
|
||||
const bool bInsideFine=X>=Min[0]&&X<=Max[0]
|
||||
&&Y>=Min[1]&&Y<=Max[1]&&SampleZ>=Min[2]&&SampleZ<=Max[2];
|
||||
float RockDistance=Samples[Lane].Distance;
|
||||
if(bInsideFine&&DetailVariant!=EDetailVariant::Smooth
|
||||
&&std::abs(RockDistance)<=DetailSupremum+0.125f)
|
||||
{
|
||||
const float Fade=DetailBandFadeAt(static_cast<float>(X),
|
||||
static_cast<float>(Y),static_cast<float>(SampleZ),RockDistance,
|
||||
Samples[Lane].SurfaceSDF,Samples[Lane].CaveInfluence,
|
||||
Samples[Lane].FloorInfluence);
|
||||
if(Fade>0.0f)RockDistance+=DetailNoiseOnLine(static_cast<float>(X),
|
||||
static_cast<float>(Y),static_cast<float>(SampleZ),
|
||||
Samples[Lane].SurfaceSDF,Samples[Lane].CaveInfluence,
|
||||
Samples[Lane].FloorInfluence,Samples[Lane].PassageInfluence,
|
||||
DetailNoiseLine)*Fade;
|
||||
}
|
||||
if(Samples[Lane].bCriticalAir)
|
||||
RockDistance=std::min(RockDistance,-1.0f/16.0f);
|
||||
const bool bRock=RockDistance>=0.0f;
|
||||
float Density=-RockDistance;
|
||||
if((Density<0.0f)!=bRock||std::abs(Density)<0.05f)
|
||||
Density=(bRock?-1.0f:1.0f)*std::max(std::abs(Density),0.05f);
|
||||
OutDensity[Offset+Lane]=ApplyEditBrushes(Density,X,Y,SampleZ);
|
||||
}
|
||||
Offset+=BatchCount;
|
||||
}
|
||||
}
|
||||
|
||||
void DensityAtLatticeZ8(int32 X,int32 Y,int32 ZStart,int32 ZStep,
|
||||
int32 Count,float OutDensity[8]) const
|
||||
{
|
||||
DensityAtLatticeZRun(X,Y,ZStart,ZStep,std::clamp(Count,0,8),OutDensity);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
float CoarseRockDistance(double X,double Y,double Z,bool* OutCriticalAir) const
|
||||
{
|
||||
const float Base=StrataDistance(Z);
|
||||
@@ -3906,4 +4016,5 @@ private:
|
||||
std::array<std::vector<uint64>,3> CandidateAxisWords;
|
||||
std::vector<uint64> CandidateWords;
|
||||
FBuildStats Stats;
|
||||
bool bAnalyticOnly=false;
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <shared_mutex>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -316,59 +317,156 @@ namespace VoxelForgeCore
|
||||
|
||||
bool World::compileTileRegion(std::span<const TileKey> tiles,std::uint32_t workerLimit,
|
||||
const JobScheduler& scheduler,std::string& error,
|
||||
std::size_t* outCompiledTiles)
|
||||
std::size_t* outCompiledTiles,
|
||||
TileRegionCompileStats* outStats,bool analyticOnly)
|
||||
{
|
||||
if(outCompiledTiles)*outCompiledTiles=0;
|
||||
if(outStats)*outStats={};
|
||||
if(!impl_||!impl_->owner||!impl_->shape||!impl_->shape->IsBuilt())
|
||||
{error="the base world must be compiled before adding tile regions";return false;}
|
||||
if(tiles.empty())return true;
|
||||
|
||||
std::unordered_map<TileKey,std::vector<TileKey>,TileKeyHash> pendingPages;
|
||||
pendingPages.reserve(tiles.size());
|
||||
struct FPendingRegion
|
||||
{
|
||||
TileKey pageKey;
|
||||
std::vector<TileKey> tiles;
|
||||
};
|
||||
std::vector<FPendingRegion> pendingRegions;
|
||||
pendingRegions.reserve(tiles.size());
|
||||
std::unordered_map<TileKey,std::size_t,TileKeyHash> regionByPage;
|
||||
regionByPage.reserve(tiles.size());
|
||||
std::unordered_set<TileKey,TileKeyHash> seenTiles;
|
||||
seenTiles.reserve(tiles.size()*2+1);
|
||||
{
|
||||
std::shared_lock lock(impl_->tileRegionMutex);
|
||||
for(const TileKey& key:tiles)
|
||||
for(std::size_t inputIndex=0;inputIndex<tiles.size();++inputIndex)
|
||||
{
|
||||
const TileKey& key=tiles[inputIndex];
|
||||
if(key.lod<0||key.lod>8)
|
||||
{error="tile region contains an invalid LOD";return false;}
|
||||
if(key.lod>=impl_->configuration.fullResolutionLodCount
|
||||
||CoveredByBaseShape(impl_->buildRequest,impl_->configuration,key))continue;
|
||||
const TileKey pageKey=ShapePageKey(key);
|
||||
if(!impl_->tileRegions.contains(pageKey))pendingPages[pageKey].push_back(key);
|
||||
if(impl_->tileRegions.contains(key)||!seenTiles.insert(key).second)continue;
|
||||
// Analytic regions evaluate only requested fine tiles and can safely coalesce a
|
||||
// whole entering LOD slab. Packed pages retain their fixed absolute parent cells.
|
||||
const TileKey pageKey=analyticOnly?TileKey{{0,0,0},key.lod}:ShapePageKey(key);
|
||||
auto [found,inserted]=regionByPage.try_emplace(pageKey,pendingRegions.size());
|
||||
if(inserted)pendingRegions.push_back({pageKey,{}});
|
||||
pendingRegions[found->second].tiles.push_back(key);
|
||||
}
|
||||
}
|
||||
if(pendingPages.empty())return true;
|
||||
if(pendingRegions.empty())return true;
|
||||
|
||||
constexpr std::int32_t PagePad=8;
|
||||
using Clock=std::chrono::steady_clock;
|
||||
const auto compileStart=Clock::now();
|
||||
TileRegionCompileStats stats;
|
||||
std::size_t compiledTileCount=0;
|
||||
for(const auto& [pageKey,requestedTiles]:pendingPages)
|
||||
std::vector<std::shared_ptr<FStandaloneShapeWorld>> compiledRegions(pendingRegions.size());
|
||||
std::vector<std::string> regionErrors(pendingRegions.size());
|
||||
const ShapeBuildRequest& base=impl_->buildRequest;
|
||||
const std::uint32_t clampedWorkers=std::clamp<std::uint32_t>(workerLimit,1,8);
|
||||
|
||||
if(analyticOnly)
|
||||
{
|
||||
const std::int32_t tileCount=TilesPerShapePage(pageKey.lod);
|
||||
const std::int32_t tileExtent=CHUNK_SIZE<<pageKey.lod;
|
||||
const FIntVector pageMin(pageKey.coordinate.x*tileCount*tileExtent,
|
||||
pageKey.coordinate.y*tileCount*tileExtent,
|
||||
pageKey.coordinate.z*tileCount*tileExtent);
|
||||
const FIntVector pageMax(pageMin.X+tileCount*tileExtent,
|
||||
pageMin.Y+tileCount*tileExtent,pageMin.Z+tileCount*tileExtent);
|
||||
constexpr std::int32_t PagePad=8;
|
||||
const FIntVector fineMin(pageMin.X-PagePad,pageMin.Y-PagePad,pageMin.Z-PagePad);
|
||||
const FIntVector fineMax(pageMax.X+PagePad,pageMax.Y+PagePad,pageMax.Z+PagePad);
|
||||
|
||||
auto page=std::make_shared<FStandaloneShapeWorld>();
|
||||
const ShapeBuildRequest& base=impl_->buildRequest;
|
||||
if(!page->Build(*impl_->owner,fineMin,fineMax,pageMin,pageMax,
|
||||
static_cast<int32>(std::clamp<std::uint32_t>(workerLimit,1,8)),
|
||||
ToNative(base.detail),false,error,&scheduler,
|
||||
base.roundTunnels,base.profileDetailBand))return false;
|
||||
if(!impl_->editLog.empty())page->SetEditTransaction(impl_->editLog);
|
||||
|
||||
const auto BuildAnalyticRegionAt=[&](std::size_t index)
|
||||
{
|
||||
std::unique_lock lock(impl_->tileRegionMutex);
|
||||
impl_->tileRegions.try_emplace(pageKey,std::move(page));
|
||||
impl_->tileRegionCount.store(impl_->tileRegions.size(),std::memory_order_release);
|
||||
const FPendingRegion& pending=pendingRegions[index];
|
||||
FIntVector regionMin(MAX_int32,MAX_int32,MAX_int32);
|
||||
FIntVector regionMax(MIN_int32,MIN_int32,MIN_int32);
|
||||
for(const TileKey& key:pending.tiles)
|
||||
{
|
||||
const FVoxelTileKey native=ToNative(key);
|
||||
const FIntVector origin=native.OriginVoxels();
|
||||
const std::int32_t extent=native.ExtentVoxels();
|
||||
for(std::int32_t axis=0;axis<3;++axis)
|
||||
{
|
||||
(®ionMin.X)[axis]=std::min((®ionMin.X)[axis],(&origin.X)[axis]);
|
||||
(®ionMax.X)[axis]=std::max((®ionMax.X)[axis],(&origin.X)[axis]+extent);
|
||||
}
|
||||
}
|
||||
const FIntVector fineMin(regionMin.X-PagePad,regionMin.Y-PagePad,regionMin.Z-PagePad);
|
||||
const FIntVector fineMax(regionMax.X+PagePad,regionMax.Y+PagePad,regionMax.Z+PagePad);
|
||||
auto region=std::make_shared<FStandaloneShapeWorld>();
|
||||
if(!region->BuildAnalyticRegion(*impl_->owner,fineMin,fineMax,regionMin,regionMax,
|
||||
ToNative(base.detail),base.roundTunnels,regionErrors[index]))return;
|
||||
compiledRegions[index]=std::move(region);
|
||||
};
|
||||
struct FAnalyticBuildContext
|
||||
{
|
||||
decltype(BuildAnalyticRegionAt)* BuildAt;
|
||||
} context{&BuildAnalyticRegionAt};
|
||||
std::array<double,16> workerActive{};
|
||||
if(pendingRegions.size()==1)
|
||||
{
|
||||
// A chunk crossing normally contributes one entering slab. Building that small
|
||||
// immutable primitive/bin view inline avoids paying for a scheduler wake-up while
|
||||
// the existing tile workers are already busy finishing the previous crossing.
|
||||
BuildAnalyticRegionAt(0);
|
||||
if(compiledRegions[0])stats.workerSeconds=compiledRegions[0]->GetStats().ShapeSeconds;
|
||||
}
|
||||
compiledTileCount+=requestedTiles.size();
|
||||
else
|
||||
stats.workerSeconds=scheduler.parallel_for(pendingRegions.size(),1,clampedWorkers,
|
||||
&context,[](void* raw,std::size_t index,std::size_t)
|
||||
{
|
||||
auto& ctx=*static_cast<FAnalyticBuildContext*>(raw);
|
||||
(*ctx.BuildAt)(index);
|
||||
},workerActive.data(),workerActive.size());
|
||||
for(std::size_t i=0;i<pendingRegions.size();++i)
|
||||
{
|
||||
if(!regionErrors[i].empty()){error=regionErrors[i];return false;}
|
||||
if(!compiledRegions[i]){error="analytic tile region build did not produce a result";return false;}
|
||||
if(!impl_->editLog.empty())compiledRegions[i]->SetEditTransaction(impl_->editLog);
|
||||
stats.shapeSeconds+=compiledRegions[i]->GetStats().ShapeSeconds;
|
||||
stats.tileKeysCovered+=pendingRegions[i].tiles.size();
|
||||
}
|
||||
stats.regionsBuilt=pendingRegions.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(std::size_t i=0;i<pendingRegions.size();++i)
|
||||
{
|
||||
const FPendingRegion& pending=pendingRegions[i];
|
||||
const std::int32_t tileCount=TilesPerShapePage(pending.pageKey.lod);
|
||||
const std::int32_t tileExtent=CHUNK_SIZE<<pending.pageKey.lod;
|
||||
const FIntVector regionMin(pending.pageKey.coordinate.x*tileCount*tileExtent,
|
||||
pending.pageKey.coordinate.y*tileCount*tileExtent,
|
||||
pending.pageKey.coordinate.z*tileCount*tileExtent);
|
||||
const FIntVector regionMax(regionMin.X+tileCount*tileExtent,
|
||||
regionMin.Y+tileCount*tileExtent,regionMin.Z+tileCount*tileExtent);
|
||||
const FIntVector fineMin(regionMin.X-PagePad,regionMin.Y-PagePad,regionMin.Z-PagePad);
|
||||
const FIntVector fineMax(regionMax.X+PagePad,regionMax.Y+PagePad,regionMax.Z+PagePad);
|
||||
auto region=std::make_shared<FStandaloneShapeWorld>();
|
||||
if(!region->Build(*impl_->owner,fineMin,fineMax,regionMin,regionMax,
|
||||
static_cast<int32>(clampedWorkers),ToNative(base.detail),false,error,&scheduler,
|
||||
base.roundTunnels,base.profileDetailBand,false))return false;
|
||||
if(!impl_->editLog.empty())region->SetEditTransaction(impl_->editLog);
|
||||
const auto& build=region->GetStats();
|
||||
++stats.regionsBuilt;
|
||||
stats.tileKeysCovered+=pending.tiles.size();
|
||||
stats.latticeNodes+=build.SignNodes;
|
||||
stats.shapeSeconds+=build.ShapeSeconds;
|
||||
stats.intervalSeconds+=build.IntervalSeconds;
|
||||
stats.surfaceSeconds+=build.SurfaceSeconds;
|
||||
stats.workerSeconds+=build.RockIntervalLines.WorkerSeconds
|
||||
+build.CandidateAxisLines.WorkerSeconds
|
||||
+build.CandidateMergeLines.WorkerSeconds
|
||||
+build.DetailBandLines.WorkerSeconds;
|
||||
compiledRegions[i]=std::move(region);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::unique_lock lock(impl_->tileRegionMutex);
|
||||
for(std::size_t i=0;i<pendingRegions.size();++i)
|
||||
{
|
||||
for(const TileKey& key:pendingRegions[i].tiles)
|
||||
if(impl_->tileRegions.try_emplace(key,compiledRegions[i]).second)++compiledTileCount;
|
||||
}
|
||||
impl_->tileRegionCount.store(impl_->tileRegions.size(),std::memory_order_release);
|
||||
}
|
||||
stats.wallSeconds=std::chrono::duration<double>(Clock::now()-compileStart).count();
|
||||
if(outCompiledTiles)*outCompiledTiles=compiledTileCount;
|
||||
if(outStats)*outStats=stats;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -379,7 +477,7 @@ namespace VoxelForgeCore
|
||||
desired.reserve(desiredTiles.size()*2+1);
|
||||
for(const TileKey& key:desiredTiles)
|
||||
if(key.lod>=0&&key.lod<impl_->configuration.fullResolutionLodCount)
|
||||
desired.insert(ShapePageKey(key));
|
||||
desired.insert(key);
|
||||
std::unique_lock lock(impl_->tileRegionMutex);
|
||||
std::erase_if(impl_->tileRegions,[&](const auto& entry){return !desired.contains(entry.first);});
|
||||
impl_->tileRegionCount.store(impl_->tileRegions.size(),std::memory_order_release);
|
||||
@@ -483,7 +581,7 @@ namespace VoxelForgeCore
|
||||
if(impl_->tileRegionCount.load(std::memory_order_acquire)!=0)
|
||||
{
|
||||
std::shared_lock lock(impl_->tileRegionMutex);
|
||||
if(const auto found=impl_->tileRegions.find(ShapePageKey(key));found!=impl_->tileRegions.end())
|
||||
if(const auto found=impl_->tileRegions.find(key);found!=impl_->tileRegions.end())
|
||||
page=found->second;
|
||||
}
|
||||
const FStandaloneShapeWorld& tileShape=page?*page:*impl_->shape;
|
||||
@@ -584,8 +682,11 @@ namespace VoxelForgeCore
|
||||
impl_->shape->SetEditTransaction(impl_->editLog);
|
||||
{
|
||||
std::shared_lock lock(impl_->tileRegionMutex);
|
||||
std::unordered_set<FStandaloneShapeWorld*> updatedRegions;
|
||||
updatedRegions.reserve(impl_->tileRegions.size());
|
||||
for(const auto& [key,page]:impl_->tileRegions)
|
||||
if(page)page->SetEditTransaction(impl_->editLog);
|
||||
if(page&&updatedRegions.insert(page.get()).second)
|
||||
page->SetEditTransaction(impl_->editLog);
|
||||
}
|
||||
const FIntVector min=impl_->shape->GetEditBoundsMin(),max=impl_->shape->GetEditBoundsMax();
|
||||
EditResult result;result.digest=digest;
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Chunk streaming optimization results
|
||||
|
||||
Build: `VoxelForgeChunkStreamFastColumn.exe`; built with `Standalone/Build.ps1` (`/MP8`) and run via `Core/verification/RunMachine.ps1` (`BelowNormal`, affinity `0xFF00`). No `0xC0000142` occurred. Cache-use audits report zero hits.
|
||||
|
||||
## Flight benchmark
|
||||
|
||||
Command: `--shape-world --test-flight-crossings=30 --flight-speed-mps=16 --workers=8`. Straight +Y flight, 30 unit chunk crossings. `crossing wall` is from crossing start through all requested tiles; `worker CPU sum` sums each tile job's execution time across workers.
|
||||
|
||||
| Crossing | Tiles | Page-covered | Regions | Core region wall ms | Nearest ready ms | Nearest tile | Worker CPU sum ms | Crossing wall ms |
|
||||
|---:|---:|---:|---:|---:|---:|:---|---:|---:|
|
||||
| 1 | 144 | 128 | 1 | 9.1 | 16.62 | `-1,-4,-2,lod1` | 478 | 105 |
|
||||
| 2 | 144 | 0 | 0 | 0.0 | 2.48 | `-3,-10,-3,lod0` | 128 | 19 |
|
||||
| 3 | 108 | 0 | 0 | 0.0 | 2.73 | `-1,0,-1,lod2` | 98 | 15 |
|
||||
| 4 | 144 | 128 | 1 | 6.2 | 9.75 | `-3,-8,-3,lod0` | 450 | 67 |
|
||||
| 5 | 144 | 128 | 1 | 7.7 | 11.81 | `-2,-2,-2,lod1` | 405 | 62 |
|
||||
| 6 | 144 | 128 | 1 | 6.6 | 11.25 | `-3,-6,-4,lod0` | 545 | 78 |
|
||||
| 7 | 76 | 0 | 0 | 0.0 | 1.90 | `-1,2,-1,lod3` | 44 | 8 |
|
||||
| 8 | 144 | 128 | 1 | 5.7 | 9.35 | `-3,-4,-4,lod0` | 452 | 69 |
|
||||
| 9 | 144 | 128 | 1 | 7.2 | 14.34 | `-1,0,-2,lod1` | 618 | 89 |
|
||||
| 10 | 144 | 128 | 1 | 5.8 | 9.20 | `-3,-2,-3,lod0` | 511 | 75 |
|
||||
| 11 | 108 | 0 | 0 | 0.0 | 2.25 | `-1,2,-1,lod2` | 80 | 12 |
|
||||
| 12 | 144 | 144 | 2 | 8.9 | 16.00 | `-3,0,-3,lod0` | 729 | 108 |
|
||||
| 13 | 144 | 128 | 1 | 7.5 | 21.19 | `-2,2,-2,lod1` | 700 | 100 |
|
||||
| 14 | 144 | 144 | 2 | 11.7 | 27.57 | `-3,2,-4,lod0` | 786 | 118 |
|
||||
| 15 | 26 | 0 | 0 | 0.0 | 10.29 | `-1,6,-1,lod8` | 123 | 19 |
|
||||
| 16 | 144 | 144 | 2 | 9.2 | 23.58 | `-3,4,-4,lod0` | 798 | 115 |
|
||||
| 17 | 144 | 128 | 1 | 7.5 | 24.21 | `-1,4,-2,lod1` | 675 | 105 |
|
||||
| 18 | 144 | 144 | 2 | 9.2 | 20.95 | `-3,6,-3,lod0` | 834 | 120 |
|
||||
| 19 | 108 | 0 | 0 | 0.0 | 2.22 | `-1,4,-1,lod2` | 62 | 10 |
|
||||
| 20 | 144 | 144 | 2 | 9.8 | 20.24 | `-3,8,-3,lod0` | 704 | 106 |
|
||||
| 21 | 144 | 128 | 1 | 6.7 | 22.71 | `-2,6,-2,lod1` | 771 | 121 |
|
||||
| 22 | 144 | 144 | 2 | 10.2 | 21.40 | `-3,10,-4,lod0` | 605 | 93 |
|
||||
| 23 | 76 | 0 | 0 | 0.0 | 1.88 | `-1,4,-1,lod3` | 38 | 6 |
|
||||
| 24 | 144 | 144 | 2 | 8.5 | 19.45 | `-3,12,-4,lod0` | 620 | 93 |
|
||||
| 25 | 144 | 128 | 1 | 8.2 | 23.03 | `-1,8,-2,lod1` | 758 | 116 |
|
||||
| 26 | 144 | 144 | 2 | 8.2 | 15.76 | `-3,14,-3,lod0` | 659 | 97 |
|
||||
| 27 | 108 | 0 | 0 | 0.0 | 2.74 | `-1,6,-1,lod2` | 51 | 9 |
|
||||
| 28 | 144 | 144 | 2 | 8.2 | 16.06 | `-3,16,-3,lod0` | 663 | 97 |
|
||||
| 29 | 144 | 128 | 1 | 7.6 | 20.73 | `-2,10,-2,lod1` | 483 | 80 |
|
||||
| 30 | 144 | 144 | 2 | 9.2 | 21.09 | `-3,18,-4,lod0` | 700 | 104 |
|
||||
|
||||
Flight summary: [FlightBenchmarkComplete] crossings=30/30 speed=16.00m/s elapsed=15.006s cache_hits=0 crossing_deltas=unit-+Y nearest_ready_p50=15.762ms nearest_ready_p95=23.577ms nearest_ready_max=27.570ms max_crossing_wall=0.121s max_worker_cpu_sum=0.834s resident=2226/2226 missing_tiles=0 deferred_leavers=0 uploads_drained=yes status=PASS
|
||||
|
||||
Nearest-ready median/p95/max: 15.762 / 23.577 / 27.570 ms. Maximum full crossing wall: 121 ms. Aggregate worker CPU sum: median 545 ms, p95 798 ms, max 834 ms. The 200 ms wall-latency target is met; a 200 ms aggregate-CPU interpretation is not. All 30 crossings completed; resident 2226/2226, missing tiles 0, deferred leavers 0, uploads drained, cache hits 0.
|
||||
|
||||
## Profile
|
||||
|
||||
The prior packed-page crossing in `owner_final6_chunk_crossing.stdout.log` rebuilt 16 pages covering 128 tiles: Core page wall 1.1828 s, then tile worker sum 156 ms and crossing wall 1.206 s. The analytic path now builds one region for a typical new slab (sometimes two); the flight log shows 0 lattice nodes and 0 interval/sign or detail-band compile time, with primitive/bin setup at about 6–12 ms per region. Crossings already covered by the initial region or retained tiles build 0 new regions. The 128 LOD1 tile meshes dominate new-slab work at roughly 0.4–0.8 s aggregate worker CPU, while all tile jobs finish in 0.06–0.12 s wall. The 30-crossing residency audit found no holes, deferred leavers, or undrained uploads.
|
||||
|
||||
Crossing 1 profile: Core slab build 9.6 ms wall / 9.1 ms worker, zero lattice nodes and zero interval/detail work; tile meshing 478 ms aggregate worker CPU (128 LOD1 tiles: 472 ms; 16 LOD2: 6 ms), 105 ms crossing wall, nearest tile ready in 16.62 ms. This replaces the baseline 1.183 s page build and 1.206 s crossing wall.
|
||||
|
||||
## Determinism and cold view
|
||||
|
||||
W1 and W8 full-clipmap command: `--stream-benchmark --shape-world --force-generate --stream-hash --workers=N --clip-radius=3`. Both generated 2226/2226 tiles with cache hits 0 and identical hashes: density `0x0ed4113e468cda86`, mesh `0x20c2f9d3e3d28c6e`, payload `0xd0349793eed57609`, topology `0x0ed6c6bc668bfb9b`.
|
||||
|
||||
Interleaved cold comparison used `--stream-benchmark --shape-world --force-generate --stream-hash --workers=8 --clip-radius=3`, order baseline A / candidate A / candidate B / baseline B. `StreamFullClipmap` walls: baseline 0.826 / 0.759 s (mean 0.793 s); candidate 0.744 / 0.729 s (mean 0.737 s), with identical hashes and zero cache hits.
|
||||
|
||||
## Audits
|
||||
|
||||
- Route audit: 5642/5642 PASS.
|
||||
- Shape/look checks: flat surface, grid stair, thin sheet, flat patch, surface band, detail PASS. Six fixed captures match the prior candidate bit-for-bit. Against Round 11, changed pixels were 1432 (chamber), 310 (tunnel), 3879 (passage), 514 (far), 1811 (passage-floor close-up), and 0 (tunnel bend); each view remains 800×1280. Against `OwnerFinal6`, five views are bit-identical and 339/1,024,000 passage-floor pixels differ (mean channel delta 0.003896, max 58). Passage-floor recapture is bit-identical.
|
||||
- Passage wall detail: 13,271 passage samples, ratio 1.152, PASS.
|
||||
- Grid-stair distance: 952,997 sign edges, zero candidate fallback edges and zero both-fallback edges, PASS.
|
||||
- Fine shard audit: zero thin sheets, PASS. Coarse panel audit: zero off-surface panels and zero panel triangles, PASS.
|
||||
- Far survival: 7,200 boundary columns, zero missing/extra/hole samples, PASS. Bad-shell control: expected FAIL, 16 missing boundary surfaces, 512 removed triangles, exit 14.
|
||||
|
||||
## Log files
|
||||
|
||||
- Flight: `chunk_fast_column_flight30.stdout.log`
|
||||
- Path hash: `chunk_fast_column_path_hash.stdout.log`
|
||||
- W1/W8: `chunk_fast_column_hash_w1.stdout.log`, `chunk_fast_column_hash_w8.stdout.log`
|
||||
- Cold runs: `chunk_fast_column_cold_baseline_a.stdout.log`, `chunk_fast_column_cold_candidate_a.stdout.log`, `chunk_fast_column_cold_candidate_b.stdout.log`, `chunk_fast_column_cold_baseline_b.stdout.log`
|
||||
- Audits: `chunk_fast_column_shape_audit.stdout.log`, `chunk_fast_column_passage_detail.stdout.log`, `chunk_fast_column_grid_stair.stdout.log`, `chunk_fast_column_mesh_far_audits.stdout.log`, `chunk_fast_column_bad_shell_control.stdout.log`
|
||||
Reference in new issue
Block a user