Files
VoxelForge/Source/VoxelForgeEditor/Private/VoxelForgeRegionEvalExperiment.h
T
Fr0zkaandClaude Opus 5.5 41a9265ebd measure(step2a): candidate bins alone are slower -- the per-sample GetDensityAt call must go
Editor-only ablation (explore commandlet, -regioneval, default off): 8^3 bins for rooms,
room-floor joins and tunnel chains, but every point still goes through GetDensityAt.
259^3 ring, seed 1337, six workers:
  live  : 6.776 s wall, 29.16 s worker CPU, 1.679 us/sample, 21.2 candidate visits/sample
  binned: 19.54 s wall, 50.02 s worker CPU, 2.879 us/sample, 16.4 candidate visits/sample
Correctness: zero Q16 (x16, ties away from zero) disagreements on the full ring and ~284k probes
on 4 more seeds (composer recipes, warped rooms, passages, landings, strate edges, edits);
shrinking room reach to 0.5 -> 18,107 Q16 / 735 sign differences (the check bites).
Not the planned region program: the step-2 question is still open. Baseline for the next attempt:
1.68 us CPU per sample on the live path.

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

85 lines
3.0 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;
double WallSeconds = 0.0;
double WorkerCpuSeconds = 0.0;
double NanosecondsPerSample = 0.0;
bool bWorkerCpuFromOsThreadTimes = 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);
/** 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);
}