perf(generation): inline exact IsFinite -- LOD0 ~11-12% faster, field-exact
The sampler's last "unknown" LOD0 bucket (~13.8%) was ucrtbase.dll!_finite: FMath::IsFinite is an
out-of-line CRT call on the MSVC game path, hit from the innermost tunnel, passage, density,
spatial-index and meshing loops.
- VoxelMath::IsFiniteFast(float/double) in VoxelTypes.h: memcpy to uint32/uint64,
(Bits & ExpMask) != ExpMask. It is the same predicate for every bit pattern, with no FP
comparison for fast-math to fold. The disassembly shows it inlined (movd/movq, mask, compare).
- VoxelMath::IsFinite routes through a plain global, voxel.FastIsFinite (default 1), for the A/B.
The CRT call remains only on the switch-off branch. Hot generation-path uses are replaced; no
_finite / std::isfinite remains in Source/VoxelForge. Tool/editor/test code keeps FMath.
- A test that can fail: VoxelForge.Math.IsFiniteExact compares against FMath::IsFinite over 22
explicit float/double patterns (+-0, denormals, min/max normal, +-Inf, quiet and signalling NaN
payloads) plus 2,000,000 hashed patterns each: 0 mismatches. The explicit NaNs make a NaN-wrong
helper fail.
Field exact: 841/841 keyed tiles identical to NextHeadStaticTrace_20260913 (verdict/empty/
triangles), export OBJ unchanged (b3e5f4c3..9b377), capability 20,830 / 10,909.
Within-round A/B, game path, two interleaved runs each, sampler off (off -> on):
static LOD0 request p50 95.5 -> 84.8 ms generation p50/p95 70.3/114.1 -> 62.3/100.6 ms
worker 35.4 -> 31.6 s (-10.5%)
moving LOD0 request p50/p95 70.8/144.2 -> 62.0/126.1 ms
generation p50/p95 62.6/113.4 -> 55.1/101.0 ms
worker 102.6 -> 91.3 s (-11.0%)
Sampler-on moving: the _finite/CRT cluster is gone.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaFdXhTdYMkW1xrV6ApT6Y
This commit is contained in:
1 parent
22186473f9
commit
5489b5e311
11 files changed
+816
-558
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "VoxelTypes.h"
|
||||
|
||||
namespace VoxelPassageGeometry
|
||||
{
|
||||
@@ -85,13 +86,13 @@ namespace VoxelPassageGeometry
|
||||
+ FloorThickness + SealSafetyMarginVoxels;
|
||||
const float MaximumFloor = InteriorTopZ
|
||||
- PlayerHeightVoxels - SealSafetyMarginVoxels;
|
||||
if (!FMath::IsFinite(StrateBottomZ)
|
||||
|| !FMath::IsFinite(InteriorBottomZ)
|
||||
|| !FMath::IsFinite(InteriorTopZ)
|
||||
|| !FMath::IsFinite(LedgeSpacing)
|
||||
|| !FMath::IsFinite(LedgeDepth)
|
||||
|| !FMath::IsFinite(MinimumFloor)
|
||||
|| !FMath::IsFinite(MaximumFloor)
|
||||
if (!VoxelMath::IsFinite(StrateBottomZ)
|
||||
|| !VoxelMath::IsFinite(InteriorBottomZ)
|
||||
|| !VoxelMath::IsFinite(InteriorTopZ)
|
||||
|| !VoxelMath::IsFinite(LedgeSpacing)
|
||||
|| !VoxelMath::IsFinite(LedgeDepth)
|
||||
|| !VoxelMath::IsFinite(MinimumFloor)
|
||||
|| !VoxelMath::IsFinite(MaximumFloor)
|
||||
|| !(MaximumFloor > MinimumFloor))
|
||||
{
|
||||
return 0.5f * (InteriorBottomZ + InteriorTopZ);
|
||||
@@ -153,12 +154,12 @@ namespace VoxelPassageGeometry
|
||||
const float FloorRadius = FMath::Max(0.5f, SafeRadius - 0.5f);
|
||||
if (!(SafeRadius > 0.0f)
|
||||
|| !(BaseDensity > 0.0f)
|
||||
|| !FMath::IsFinite(WorldX)
|
||||
|| !FMath::IsFinite(WorldY)
|
||||
|| !FMath::IsFinite(WorldZ)
|
||||
|| !FMath::IsFinite(FloorZ)
|
||||
|| !FMath::IsFinite(Start.X) || !FMath::IsFinite(Start.Y)
|
||||
|| !FMath::IsFinite(End.X) || !FMath::IsFinite(End.Y))
|
||||
|| !VoxelMath::IsFinite(WorldX)
|
||||
|| !VoxelMath::IsFinite(WorldY)
|
||||
|| !VoxelMath::IsFinite(WorldZ)
|
||||
|| !VoxelMath::IsFinite(FloorZ)
|
||||
|| !VoxelMath::IsFinite(Start.X) || !VoxelMath::IsFinite(Start.Y)
|
||||
|| !VoxelMath::IsFinite(End.X) || !VoxelMath::IsFinite(End.Y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -218,14 +219,14 @@ namespace VoxelPassageGeometry
|
||||
const float CoreRadius = FMath::Max(0.5f, SafeRadius - 1.0f);
|
||||
if (!(SafeRadius > 0.0f)
|
||||
|| !(BaseDensity > 0.0f)
|
||||
|| !FMath::IsFinite(WorldX)
|
||||
|| !FMath::IsFinite(WorldY)
|
||||
|| !FMath::IsFinite(WorldZ)
|
||||
|| !FMath::IsFinite(FloorZ)
|
||||
|| !FMath::IsFinite(Start.X) || !FMath::IsFinite(Start.Y)
|
||||
|| !FMath::IsFinite(Start.Z)
|
||||
|| !FMath::IsFinite(End.X) || !FMath::IsFinite(End.Y)
|
||||
|| !FMath::IsFinite(End.Z))
|
||||
|| !VoxelMath::IsFinite(WorldX)
|
||||
|| !VoxelMath::IsFinite(WorldY)
|
||||
|| !VoxelMath::IsFinite(WorldZ)
|
||||
|| !VoxelMath::IsFinite(FloorZ)
|
||||
|| !VoxelMath::IsFinite(Start.X) || !VoxelMath::IsFinite(Start.Y)
|
||||
|| !VoxelMath::IsFinite(Start.Z)
|
||||
|| !VoxelMath::IsFinite(End.X) || !VoxelMath::IsFinite(End.Y)
|
||||
|| !VoxelMath::IsFinite(End.Z))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -360,8 +361,8 @@ namespace VoxelPassageGeometry
|
||||
}
|
||||
|
||||
return bFoundSegment
|
||||
&& FMath::IsFinite(OutFloorZ)
|
||||
&& FMath::IsFinite(OutSupportRadius)
|
||||
&& VoxelMath::IsFinite(OutFloorZ)
|
||||
&& VoxelMath::IsFinite(OutSupportRadius)
|
||||
&& OutSupportRadius > 0.0f
|
||||
&& BestDistanceSquared <= FMath::Square(OutSupportRadius);
|
||||
}
|
||||
@@ -405,10 +406,10 @@ namespace VoxelPassageGeometry
|
||||
{
|
||||
FOriginLandingGeometry Result;
|
||||
if (!(OriginRadius > 0.0f)
|
||||
|| !FMath::IsFinite(StrateTopZ)
|
||||
|| !FMath::IsFinite(StrateBottomZ)
|
||||
|| !FMath::IsFinite(SealThickness)
|
||||
|| !FMath::IsFinite(OriginRadius))
|
||||
|| !VoxelMath::IsFinite(StrateTopZ)
|
||||
|| !VoxelMath::IsFinite(StrateBottomZ)
|
||||
|| !VoxelMath::IsFinite(SealThickness)
|
||||
|| !VoxelMath::IsFinite(OriginRadius))
|
||||
{
|
||||
return Result;
|
||||
}
|
||||
@@ -429,10 +430,10 @@ namespace VoxelPassageGeometry
|
||||
+ Result.FloorThickness + SealSafetyMarginVoxels;
|
||||
const float MaximumFloor = InnerTop
|
||||
- DesiredHeight - SealSafetyMarginVoxels;
|
||||
if (!FMath::IsFinite(InnerBottom) || !FMath::IsFinite(InnerTop)
|
||||
if (!VoxelMath::IsFinite(InnerBottom) || !VoxelMath::IsFinite(InnerTop)
|
||||
|| !(InnerTop > InnerBottom)
|
||||
|| !FMath::IsFinite(MinimumFloor)
|
||||
|| !FMath::IsFinite(MaximumFloor)
|
||||
|| !VoxelMath::IsFinite(MinimumFloor)
|
||||
|| !VoxelMath::IsFinite(MaximumFloor)
|
||||
|| MaximumFloor < MinimumFloor)
|
||||
{
|
||||
Result.HalfWidth = 0.0f;
|
||||
@@ -455,8 +456,8 @@ namespace VoxelPassageGeometry
|
||||
FORCEINLINE bool LatticeAxisHasSampleInInterval(
|
||||
float Min, float Max, float Origin, int32 Step)
|
||||
{
|
||||
if (Step <= 0 || !FMath::IsFinite(Min) || !FMath::IsFinite(Max)
|
||||
|| !FMath::IsFinite(Origin) || Min > Max)
|
||||
if (Step <= 0 || !VoxelMath::IsFinite(Min) || !VoxelMath::IsFinite(Max)
|
||||
|| !VoxelMath::IsFinite(Origin) || Min > Max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user