Files
VoxelForge/Source/VoxelForgeEditor/Private/VoxelForgeRegionEvalExperiment.h
T
Fr0zkaandClaude Opus 5.5 fd9f809c1c measure(step2b): per-brick setup rebuilds the chunk caches -- 10x slower; live cost attributed
Editor-only brick API (<= 8^3 points per call, TunnelNetwork/Underwater op-stack routes, 1.16%
scalar fallback). Exact: 0 Q16/sign disagreements on the full 259^3 ring and the five-seed probe
set, same hash on 1 and 6 workers, reach shrink still caught (18,107 Q16 / 735 sign).
Speed: 69.19 s wall, 17.6 us/sample vs live 7.04 s, 1.65 us/sample. Stack sampler (inclusive):
BuildChunkCache 93.5%, PropagateSdfOverBox 92.5%, BuildActiveOpList 92.6% -- each brick rebuilds
the cache windows and active-op lists; EvalBlock itself is 3.6%.
Live path attribution (inclusive, 68,934 stacks): op-stack RoomGraph EvalBlock 54.4%, SDF and
spatial candidate scans ~28%, tunnel core 18.4%, passage floor segment 15.0%, structural posts
14.6%, noise octaves 2.6%, disturbances 0.6%, diff layer 0.3%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
2026-09-30 03:10:22 +02:00

92 lines
3.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 BrickCount = 0;
int64 FallbackSamples = 0;
double FallbackShare = 0.0;
double WallSeconds = 0.0;
double WorkerCpuSeconds = 0.0;
double NanosecondsPerSample = 0.0;
bool bWorkerCpuFromOsThreadTimes = false;
bool bBrickProgram = false;
uint64 QuantizedHash = 0;
uint64 RawFloatHash = 0;
uint64 SaturatedSamples = 0;
uint64 NonFiniteSamples = 0;
};
struct FCandidateVisits
{
int64 SampleCount = 0;
uint64 Room = 0;
uint64 Tunnel = 0;
uint64 TunnelCore = 0;
uint64 Passage = 0;
uint64 TunnelCacheLookups = 0;
uint64 TunnelCacheHits = 0;
uint64 TunnelCacheMisses = 0;
uint64 SdfCacheBuilds = 0;
uint64 Total = 0;
double PerSample = 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 only
* enables the commandlet-only 8^3 SDF candidate bins; all field writers and their order remain
* the live GetDensityAt implementation. FullRing uses brick-grouped output ownership 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 bBrickProgram = false,
int32 RequestedWorkerCount = WorkerCount);
/** 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);
}