Editor-only, default off. 259^3 ring split into 1,000 aligned 32^3 chunks; cache/index builds bounded by chunks (948 room/SDF caches, 800 active-op lists, 8,532 index tables); 800 block setups + 201,243 scalar fallback points (1.16%); no per-point GetDensityAt on supported routes. Six workers: live 7.07 s wall / 1.678 us per sample; prepared 7.92 s / 1.595 us. Candidate visits 21.2 -> 15.8 per sample, evaluations 6.31 -> 5.75; room / tunnel / tunnel-core evaluations unchanged (48.1 M / 5.0 M / 38.4 M for 17.4 M samples). Passage evals 18.1 M -> 8.4 M. Exact: 0 Q16/sign disagreements, five seeds, same hash on 1 and 6 workers, reach shrink caught. Luna's verdict: 600 ms is not reachable while every lattice point evaluates the exact current density; 27.7 worker-CPU seconds need >= 7.7x less work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
138 lines
5.2 KiB
C++
138 lines
5.2 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
class UVoxelGenerator;
|
|
|
|
namespace VoxelForgeRegionEval
|
|
{
|
|
constexpr int32 WorkerCount = 6;
|
|
constexpr int32 RingDimension = 259;
|
|
// 1/16 voxel resolution covers the full prepared test field without clipping ordinary
|
|
// interior/exterior distances into indistinguishable int16 saturation values.
|
|
constexpr double QuantizationScale = 16.0;
|
|
|
|
struct FTiming
|
|
{
|
|
int32 Workers = WorkerCount;
|
|
int32 ObservedWorkerThreads = 0;
|
|
int64 SampleCount = 0;
|
|
int64 EvaluatedSamples = 0;
|
|
int64 RegionCount = 0;
|
|
int64 FallbackSamples = 0;
|
|
uint64 GeneralPathEntries = 0;
|
|
uint64 SupportedBlockSetupEntries = 0;
|
|
double FallbackShare = 0.0;
|
|
double GeneralPathEntriesPerSample = 0.0;
|
|
double WallSeconds = 0.0;
|
|
double WorkerCpuSeconds = 0.0;
|
|
double NanosecondsPerSample = 0.0;
|
|
bool bWorkerCpuFromOsThreadTimes = false;
|
|
bool bRegionProgram = false;
|
|
bool bHasWholeRunCounters = false;
|
|
uint64 QuantizedHash = 0;
|
|
uint64 RawFloatHash = 0;
|
|
uint64 SaturatedSamples = 0;
|
|
uint64 NonFiniteSamples = 0;
|
|
uint64 SdfCacheBuilds = 0;
|
|
uint64 ActiveOpListBuilds = 0;
|
|
uint64 BroadPhaseIndexBuilds = 0;
|
|
uint64 SdfSpatialIndexBuilds = 0;
|
|
uint64 SdfBrickIndexBuilds = 0;
|
|
uint64 RoomCandidateVisits = 0;
|
|
uint64 RoomEvaluations = 0;
|
|
uint64 TunnelCandidateVisits = 0;
|
|
uint64 TunnelEvaluations = 0;
|
|
uint64 TunnelCoreCandidateVisits = 0;
|
|
uint64 TunnelCoreEvaluations = 0;
|
|
uint64 PassageCandidateVisits = 0;
|
|
uint64 PassageEvaluations = 0;
|
|
uint64 TotalCandidateVisits = 0;
|
|
uint64 TotalCandidateEvaluations = 0;
|
|
double CandidateVisitsPerSample = 0.0;
|
|
double CandidateEvaluationsPerSample = 0.0;
|
|
double GetDensityAtNsPerSample = 0.0;
|
|
double OperatorBlockNsPerSample = 0.0;
|
|
double RoomGraphSourceNsPerSample = 0.0;
|
|
double RoomGraphBuildNsPerSample = 0.0;
|
|
double RoomGraphSdfNsPerSample = 0.0;
|
|
double FusedEvaluatorNsPerSample = 0.0;
|
|
double TunnelCoreSdfNsPerSample = 0.0;
|
|
double TunnelCoreWorldNsPerSample = 0.0;
|
|
double TunnelCorePostsNsPerSample = 0.0;
|
|
double PassageModifierNsPerSample = 0.0;
|
|
double PassageStructuralPostsNsPerSample = 0.0;
|
|
double PassageFloorNsPerSample = 0.0;
|
|
double StructuralPostsNsPerSample = 0.0;
|
|
double DensityPrologueNsPerSample = 0.0;
|
|
double DensityCoreNsPerSample = 0.0;
|
|
double DisturbancesNsPerSample = 0.0;
|
|
double DensityBoundarySealNsPerSample = 0.0;
|
|
double DiffLayerNsPerSample = 0.0;
|
|
double DensityTailNsPerSample = 0.0;
|
|
};
|
|
|
|
struct FCandidateVisits
|
|
{
|
|
int64 SampleCount = 0;
|
|
uint64 Room = 0;
|
|
uint64 RoomEvaluated = 0;
|
|
uint64 Tunnel = 0;
|
|
uint64 TunnelEvaluated = 0;
|
|
uint64 TunnelCore = 0;
|
|
uint64 TunnelCoreEvaluated = 0;
|
|
uint64 Passage = 0;
|
|
uint64 PassageEvaluated = 0;
|
|
uint64 TunnelCacheLookups = 0;
|
|
uint64 TunnelCacheHits = 0;
|
|
uint64 TunnelCacheMisses = 0;
|
|
uint64 SdfCacheBuilds = 0;
|
|
uint64 Total = 0;
|
|
uint64 TotalEvaluated = 0;
|
|
double PerSample = 0.0;
|
|
double EvaluatedPerSample = 0.0;
|
|
uint32 AttributionSampleInterval = 0;
|
|
double GetDensityAtAttributedNsPerSample = 0.0;
|
|
double DensityPrologueAttributedNsPerSample = 0.0;
|
|
double DensityCoreAttributedNsPerSample = 0.0;
|
|
double DensityDisturbancesAttributedNsPerSample = 0.0;
|
|
double DensityStructuralPostsAttributedNsPerSample = 0.0;
|
|
double DensityBoundarySealAttributedNsPerSample = 0.0;
|
|
double DensityDiffLayerAttributedNsPerSample = 0.0;
|
|
double DensityTailAttributedNsPerSample = 0.0;
|
|
};
|
|
|
|
/**
|
|
* Evaluate a deterministic lattice through the live final-field API. The prepared mode uses
|
|
* the commandlet-only 8^3 SDF candidate bins and chunk-sized operator blocks. FullRing assigns
|
|
* each chunk to one worker and writes every lattice density exactly once. SampleIndices are
|
|
* sorted lattice offsets for the statistical correctness / candidate-counter sweeps.
|
|
*/
|
|
bool Evaluate(
|
|
const UVoxelGenerator& Generator,
|
|
FIntVector OriginVoxels,
|
|
int32 Dimension,
|
|
const TArray<int64>* SampleIndices,
|
|
bool bFullRing,
|
|
bool bPrepared,
|
|
float ReachScale,
|
|
TArray<float>* OutDensities,
|
|
FTiming& OutTiming,
|
|
bool bRegionProgram = false,
|
|
int32 RequestedWorkerCount = WorkerCount,
|
|
bool bCollectWholeRunCounters = false);
|
|
|
|
/** Count exact room/tunnel/core/passage candidate visits with instrumentation enabled. */
|
|
FCandidateVisits CountCandidates(
|
|
const UVoxelGenerator& Generator,
|
|
FIntVector OriginVoxels,
|
|
int32 Dimension,
|
|
const TArray<int64>& SampleIndices,
|
|
bool bPrepared,
|
|
float ReachScale);
|
|
|
|
int16 QuantizeDensity(float Density, bool& bOutSaturated, bool& bOutFinite);
|
|
uint64 HashQuantized(const TArray<float>& Densities);
|
|
int64 LinearIndex(int32 X, int32 Y, int32 Z, int32 Dimension);
|
|
}
|