Files
Fr0zkaandClaude Opus 5.5 c0596c5f24 wip(assembler): round S5 -- streaming gates + trace; coarse-first order kept opt-in (no win)
Walkable/enclosed/refined gates defined; JSONL trace joins request, worker start,
build/apply and discards. Coarse-first + dynamic near reserve behind
voxel.StreamingCoarseFirst / voxel.StreamingDynamicNearReserve (default 0 =
S4 order): matched runs showed no walkability or full-view win and slower
LOD0/1 refinement. Instruments settled: 3.1 s standalone reproduced (16.7 s was
another generation route); black early captures were clear-only frames.
Hashes equal S4; Core-off, M2, SurfaceWorld/FloatingIslands BuildHost pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
2026-10-19 04:42:41 +02:00

160 lines
8.0 KiB
PowerShell

[CmdletBinding()]
param(
[string]$OutputName = 'VoxelForgeCoreStandalone.exe',
[ValidateSet('All','Core')][string]$Target = 'All',
[ValidateRange(1,12)][int]$CompileWorkers = 12,
[ValidateSet('Normal','BelowNormal')][string]$BuildPriority = 'Normal'
)
$ErrorActionPreference = 'Stop'
$BuildHostProcess = Get-Process -Id $PID
$BuildHostProcess.PriorityClass = $BuildPriority
$BuildHostProcess.ProcessorAffinity = [IntPtr]0xFFF
$Root = [IO.Path]::GetFullPath($PSScriptRoot)
$BuildDir = Join-Path $Root 'Build\VoxelForgeCore'
$BinDir = Join-Path $Root 'bin'
[IO.Directory]::CreateDirectory($BuildDir) | Out-Null
[IO.Directory]::CreateDirectory($BinDir) | Out-Null
if ($Target -eq 'All' -and ([IO.Path]::GetFileName($OutputName) -ne $OutputName -or [IO.Path]::GetExtension($OutputName) -ne '.exe')) {
throw "OutputName must be an executable filename, not a path: $OutputName"
}
$OutputPath = Join-Path $BinDir $OutputName
$CoreLibrary = Join-Path $BuildDir 'VoxelForgeCore.lib'
$VcVars = 'E:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat'
if (-not (Test-Path -LiteralPath $VcVars -PathType Leaf)) { throw "MSVC environment script not found: $VcVars" }
if (-not ('VoxelForgeStandaloneBuildMemoryProbe' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public static class VoxelForgeStandaloneBuildMemoryProbe {
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct MEMORYSTATUSEX {
public uint dwLength, dwMemoryLoad;
public ulong ullTotalPhys, ullAvailPhys, ullTotalPageFile, ullAvailPageFile;
public ulong ullTotalVirtual, ullAvailVirtual, ullAvailExtendedVirtual;
}
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX status);
public static ulong AvailablePhysicalBytes() {
var status = new MEMORYSTATUSEX();
status.dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX));
if (!GlobalMemoryStatusEx(ref status)) throw new InvalidOperationException("GlobalMemoryStatusEx failed.");
return status.ullAvailPhys;
}
}
'@
}
while ([VoxelForgeStandaloneBuildMemoryProbe]::AvailablePhysicalBytes() -lt 4GB) {
Write-Warning 'Standalone build is waiting for at least 4 GiB of free physical memory.'
Start-Sleep -Seconds 20
}
$SourceManifest = Join-Path $Root 'Core\core_sources.txt'
if (-not (Test-Path -LiteralPath $SourceManifest -PathType Leaf)) { throw "Core source manifest not found: $SourceManifest" }
$CoreSourceNames = @(Get-Content -LiteralPath $SourceManifest | ForEach-Object { $_.Trim() } |
Where-Object { $_ -and -not $_.StartsWith('#') })
if ($CoreSourceNames.Count -eq 0) { throw "Core source manifest is empty: $SourceManifest" }
$CoreSources = @($CoreSourceNames | ForEach-Object {
$SourcePath = [IO.Path]::GetFullPath((Join-Path $Root $_))
if (-not $SourcePath.StartsWith($Root,[StringComparison]::OrdinalIgnoreCase)) {
throw "Core source path escapes Standalone: $_"
}
$SourcePath
})
foreach ($Source in $CoreSources) {
if (-not (Test-Path -LiteralPath $Source -PathType Leaf)) { throw "Required core source is missing: $Source" }
}
# Keep the canonical source manifest shared with UBT, but compile every copied implementation
# source through a generated one-source shim that places its Unreal-shaped internals in a private
# namespace. The public API implementation owns its boundary and is compiled directly.
$WrapperDir = Join-Path $BuildDir 'wrappers'
[IO.Directory]::CreateDirectory($WrapperDir) | Out-Null
$CompileSources = [Collections.Generic.List[string]]::new()
foreach ($Index in 0..($CoreSources.Count-1)) {
$ManifestName = $CoreSourceNames[$Index].Replace('\','/')
if ($ManifestName -eq 'Core/src/VoxelForgeCore.cpp') {
$CompileSources.Add($CoreSources[$Index])
continue
}
$WrapperName = 'vfcore_' + ($ManifestName -replace '[^A-Za-z0-9]+','_')
$WrapperPath = Join-Path $WrapperDir ($WrapperName + '.cpp')
$SourceInclude = $CoreSources[$Index].Replace('\','/')
$WrapperText = @"
#include "CoreNamespacePreamble.h"
namespace vfcore::detail
{
#include "$SourceInclude"
}
"@
[IO.File]::WriteAllText($WrapperPath,$WrapperText,[Text.UTF8Encoding]::new($false))
$CompileSources.Add($WrapperPath)
}
$IncludeArgs = @(
('/I"{0}"' -f (Join-Path $Root 'Core\include')),
('/I"{0}"' -f (Join-Path $Root 'Core\src')),
('/I"{0}"' -f (Join-Path $Root 'Compat')),
('/I"{0}"' -f (Join-Path $Root 'Source')),
('/I"{0}"' -f (Join-Path $Root 'Source\VoxelForge\Public')),
('/I"{0}"' -f (Join-Path $Root 'Source\VoxelForge\Private'))
)
$CommonFlags = @('/nologo','/std:c++20','/O2','/arch:AVX2','/fp:precise','/EHsc',("/MP{0}" -f $CompileWorkers),'/D_CRT_SECURE_NO_WARNINGS') + $IncludeArgs
$CoreRsp = Join-Path $BuildDir 'core-compile.rsp'
$CoreRspLines = $CommonFlags + @('/c') + @($CompileSources | ForEach-Object { '"{0}"' -f $_ })
[IO.File]::WriteAllLines($CoreRsp,$CoreRspLines,[Text.UTF8Encoding]::new($false))
$Objects = @($CompileSources | ForEach-Object { '"{0}.obj"' -f [IO.Path]::GetFileNameWithoutExtension($_) })
$LibRsp = Join-Path $BuildDir 'core-library.rsp'
[IO.File]::WriteAllLines($LibRsp,@('/nologo',('/OUT:"{0}"' -f $CoreLibrary)) + $Objects,[Text.UTF8Encoding]::new($false))
$LegacySources = @()
$LegacyObjects = @()
$LegacyRsp = Join-Path $BuildDir 'viewer-reference-compile.rsp'
if ($Target -eq 'All') {
for ($Index=0; $Index -lt $CoreSources.Count; ++$Index) {
if ($CoreSourceNames[$Index].Replace('\','/') -eq 'Core/src/VoxelForgeCore.cpp') { continue }
$LegacySources += $CoreSources[$Index]
}
$LegacySources += (Join-Path $Root 'Source\GpuFarViewerLinkStubs.cpp')
$LegacyObjects = @($LegacySources | ForEach-Object { '"{0}.obj"' -f [IO.Path]::GetFileNameWithoutExtension($_) })
$LegacyRspLines = $CommonFlags + @('/c') + @($LegacySources | ForEach-Object { '"{0}"' -f $_ })
[IO.File]::WriteAllLines($LegacyRsp,$LegacyRspLines,[Text.UTF8Encoding]::new($false))
}
$ViewerRsp = Join-Path $BuildDir 'viewer-link.rsp'
$ViewerRspLines = $CommonFlags + @('/Fe"{0}"' -f $OutputPath) + $LegacyObjects + @(
('"{0}"' -f (Join-Path $Root 'Source\StandaloneViewer.cpp')),
('"{0}"' -f $CoreLibrary),
'/link','d3d11.lib','dxgi.lib','d3dcompiler.lib','user32.lib','gdi32.lib'
)
[IO.File]::WriteAllLines($ViewerRsp,$ViewerRspLines,[Text.UTF8Encoding]::new($false))
Push-Location $BuildDir
try {
# MSVC's /MP count and the build host's Normal-priority 16-CPU mask are configurable for
# isolated BuildHost work; the viewer process uses its own run-time worker setting.
$CommandLine = 'call "{0}" >nul && cl.exe @"{1}" && lib.exe @"{2}"' -f $VcVars,$CoreRsp,$LibRsp
& $env:ComSpec /d /s /c $CommandLine
if ($LASTEXITCODE -eq -1073741502) { throw 'A build process exited with 0xC0000142; stopping as required.' }
if ($LASTEXITCODE -ne 0) { throw "VoxelForgeCore build failed with exit code $LASTEXITCODE" }
if (-not (Test-Path -LiteralPath $CoreLibrary -PathType Leaf)) { throw "Core library was not produced: $CoreLibrary" }
$SymbolCheck = Join-Path $Root 'Core\CheckCoreSymbols.ps1'
& $SymbolCheck -LibraryPath $CoreLibrary
if ($Target -eq 'All') {
# The standalone viewer retains a global compatibility build only for legacy comparison
# and audits. Those objects are linked into the viewer executable, never into Core.lib.
$CommandLine = 'call "{0}" >nul && cl.exe @"{1}" && cl.exe @"{2}"' -f $VcVars,$LegacyRsp,$ViewerRsp
& $env:ComSpec /d /s /c $CommandLine
if ($LASTEXITCODE -eq -1073741502) { throw 'A build process exited with 0xC0000142; stopping as required.' }
if ($LASTEXITCODE -ne 0) { throw "Standalone viewer build failed with exit code $LASTEXITCODE" }
}
if ($Target -eq 'All' -and -not (Test-Path -LiteralPath $OutputPath -PathType Leaf)) { throw "Viewer was not produced: $OutputPath" }
} finally {
Pop-Location
}
Write-Host "Built $CoreLibrary"
if ($Target -eq 'All') { Write-Host "Built $OutputPath" }