wip(standalone): GPU step 10 -- first-submit stall bisected to cold shader use under 8 workers

Top-down A/B/A controls: dispatching the 11 real compute shaders once removes
the 1.3-1.7 s first GPU Present (resource creation alone does not); 1 worker
also removes it and 8 workers bring it back. Default --gpu-far now prewarms
shaders asynchronously during shape compile (--gpu-far-no-prewarm = control).
The warm-up queue itself takes ~2.75 s, so whole view is unchanged:
CPU 1.354 s vs GPU 3.559 s (viewer clock), 1.473 vs 3.731 s (host clock).
Audits: 0 sign/topology diffs vs CPU/WARP, hashes + walk 5,642/5,642, survival.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-07 05:38:14 +02:00
1 parent b0da995978
commit 10580650cb
10 files changed
+738 -6

No files matched your search

+84 -2
View File
@@ -1488,6 +1488,11 @@ namespace
bool bFarShapeStagePending=false;
bool bGpuFarEnabled=false;
bool bGpuFarAuditEnabled=false;
bool bGpuFarShaderPrewarm=false,bDisableGpuWarmupPresentHold=false;
bool bGpuFarWarmupResourcesOnly=false;
std::thread GpuShaderWarmupThread;
bool bGpuShaderWarmupQueueSucceeded=false;
std::string GpuShaderWarmupQueueError;
bool bGpuFarAuditReported=false;
bool bGpuSkirtEmitEnabled=true,bGpuConnectorRepairEnabled=true;
bool bDisableVSync=false;
@@ -1536,6 +1541,7 @@ namespace
bool bFullDetailReported=false;
bool bInitialClipmapReported=false;
bool bWholeViewPresented=false;
bool bGpuFirstBackedPresentReported=false;
bool bProfileAttribution=false;
bool bProfileDetailBand=false;
bool bCompareEvaluators=false;
@@ -1585,6 +1591,7 @@ namespace
double BatchUploadBudgetMilliseconds=2.0;
~FApp(){
if(GpuShaderWarmupThread.joinable())GpuShaderWarmupThread.join();
StopGeneration(true);ReleaseMeshes();
if(SolidRasterizer)SolidRasterizer->Release();if(WireRasterizer)WireRasterizer->Release();
if(Constants)Constants->Release();if(InputLayout)InputLayout->Release();
@@ -1849,7 +1856,38 @@ float3 Lit=Rock*(Ambient+0.88*Diffuse)+float3(0.50,0.69,0.82)*Head*0.75;
D3D11_RASTERIZER_DESC Raster{};Raster.FillMode=D3D11_FILL_SOLID;Raster.CullMode=D3D11_CULL_NONE;
Raster.DepthClipEnable=TRUE;if(FAILED(Device->CreateRasterizerState(&Raster,&SolidRasterizer)))return false;
Raster.FillMode=D3D11_FILL_WIREFRAME;if(FAILED(Device->CreateRasterizerState(&Raster,&WireRasterizer)))return false;
return Resize(Width,Height);
if(!Resize(Width,Height))return false;
if(bGpuFarEnabled)
{
std::string GpuInitError;
const auto GpuPipelineStart=std::chrono::steady_clock::now();
if(!VoxelForgeGpuFarViewer::InitializeFarPipeline(Device,Context,GpuFarShaderPath,
GpuInitError))
{
std::fprintf(stderr,"[GpuPipelineInitError] %s\n",GpuInitError.c_str());
return false;
}
std::printf("[ColdTimeline] stage=gpu_pipeline_init end_ms=%.3f duration_ms=%.3f prewarm=%s\n",
std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-ColdProcessStart).count(),
std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-GpuPipelineStart).count(),
bGpuFarShaderPrewarm?(bGpuFarWarmupResourcesOnly?"async_resources_only":"async_dispatch")
:"disabled");
}
return true;
}
void StartGpuShaderWarmupAsync()
{
if(!bGpuFarShaderPrewarm||GpuShaderWarmupThread.joinable())return;
bGpuShaderWarmupQueueSucceeded=false;GpuShaderWarmupQueueError.clear();
GpuShaderWarmupThread=std::thread([this]()
{
bGpuShaderWarmupQueueSucceeded=VoxelForgeGpuFarViewer::QueueFarShaderWarmup(
Device,Context,GpuFarShaderPath,!bGpuFarWarmupResourcesOnly,
GpuShaderWarmupQueueError);
});
std::printf("[GpuShaderWarmup] queue_thread=started overlap=CPU_shape_compile\n");
std::fflush(stdout);
}
size_t PrintParity()
@@ -2455,6 +2493,25 @@ float3 Lit=Rock*(Ambient+0.88*Diffuse)+float3(0.50,0.69,0.82)*Head*0.75;
GpuFarQueue.clear();GpuFarQueued.clear();GpuFarEligibleTiles.clear();
GpuFarPreparedInputs.clear();GpuFarPreparationErrors.clear();
if(!bGpuFarEnabled||!ShapeWorld||!ShapeWorld->hasFarWorld())return;
if(bGpuFarShaderPrewarm)
{
if(GpuShaderWarmupThread.joinable())GpuShaderWarmupThread.join();
if(!bGpuShaderWarmupQueueSucceeded)
{
std::fprintf(stderr,"[GpuShaderWarmupError] queue: %s\n",
GpuShaderWarmupQueueError.empty()?"warmup queue failed":GpuShaderWarmupQueueError.c_str());
bGpuFarEnabled=false;
return;
}
std::string WarmupError;
if(!VoxelForgeGpuFarViewer::CompleteFarShaderWarmup(Device,Context,
GpuFarShaderPath,WarmupError))
{
std::fprintf(stderr,"[GpuShaderWarmupError] %s\n",WarmupError.c_str());
bGpuFarEnabled=false;
return;
}
}
std::vector<FVoxelTileKey> CpuTiles;CpuTiles.reserve(Keys.size());
std::vector<FVoxelTileKey> Eligible;Eligible.reserve(Keys.size());
uint64 SkirtTransitionFallbackTiles=0;
@@ -3636,6 +3693,17 @@ float3 Lit=Rock*(Ambient+0.88*Diffuse)+float3(0.50,0.69,0.82)*Head*0.75;
const auto PresentCallStart=std::chrono::steady_clock::now();
const HRESULT PresentResult=SwapChain->Present(PresentSyncInterval,PresentFlags);
const auto PresentCallEnd=std::chrono::steady_clock::now();
if(GpuFarTilesSubmitted>0&&!bGpuFirstBackedPresentReported)
{
bGpuFirstBackedPresentReported=true;
std::printf("[GpuFirstBackedPresent] at_ms=%.3f call_ms=%.3f sync=%u flags=0x%08x hr=0x%08lx submitted_tiles=%llu batches=%llu\n",
std::chrono::duration<double,std::milli>(PresentCallEnd-ColdProcessStart).count(),
std::chrono::duration<double,std::milli>(PresentCallEnd-PresentCallStart).count(),
PresentSyncInterval,PresentFlags,static_cast<unsigned long>(PresentResult),
static_cast<unsigned long long>(GpuFarTilesSubmitted),
static_cast<unsigned long long>(GpuFarSubmissionBatches));
std::fflush(stdout);
}
if(bInitialClipmapReported&&!bWholeViewPresented)
{
bWholeViewPresented=true;
@@ -5506,8 +5574,20 @@ int main(int Argc,char** Argv)
else if(Arg=="--density-hash")App.bDensityHash=true;
else if(Arg=="--shape-world")App.bShapeWorld=true;
else if(Arg=="--gpu-far")
App.bGpuFarEnabled=true,App.bShapeWorld=true,App.bForceGenerate=true,
App.bGpuFarEnabled=true,App.bGpuFarShaderPrewarm=true,App.bShapeWorld=true,App.bForceGenerate=true,
App.bPresentCpuFrameBeforeGpu=true,App.bHoldCpuFrameDuringGpuWarmup=true;
else if(Arg=="--gpu-far-prewarm")
App.bGpuFarEnabled=true,App.bGpuFarShaderPrewarm=true,App.bShapeWorld=true,
App.bForceGenerate=true,App.bPresentCpuFrameBeforeGpu=true,
App.bHoldCpuFrameDuringGpuWarmup=true;
else if(Arg=="--gpu-far-warmup-resources-only")
App.bGpuFarEnabled=true,App.bGpuFarShaderPrewarm=true,App.bGpuFarWarmupResourcesOnly=true,
App.bShapeWorld=true,App.bForceGenerate=true,App.bPresentCpuFrameBeforeGpu=true,
App.bHoldCpuFrameDuringGpuWarmup=true;
else if(Arg=="--gpu-far-no-present-hold")
App.bDisableGpuWarmupPresentHold=true;
else if(Arg=="--gpu-far-no-prewarm")
App.bGpuFarShaderPrewarm=false;
else if(Arg=="--cpu-far")App.bGpuFarEnabled=false,App.bShapeWorld=true,App.bForceGenerate=true;
else if(Arg=="--gpu-far-audit")
{App.bGpuFarEnabled=true;App.bGpuFarAuditEnabled=true;App.bShapeWorld=true;App.bForceGenerate=true;App.bQuitAfterClipmap=true;}
@@ -5635,6 +5715,7 @@ int main(int Argc,char** Argv)
App.bPresentCpuFrameBeforeGpu=false;
App.bHoldCpuFrameDuringGpuWarmup=false;
}
if(App.bDisableGpuWarmupPresentHold)App.bHoldCpuFrameDuringGpuWarmup=false;
App.bProfileDetailBand=bProfileDetailBand;
std::string Error;
std::printf("[ColdTimeline] stage=owner_data_load begin_ms=%.3f\n",
@@ -5760,6 +5841,7 @@ int main(int Argc,char** Argv)
std::printf("Owner data: %s; starting at first-strate open-space sample (%.2f, %.2f, %.2f) m.\n",
App.DataPath.c_str(),App.Position.X,App.Position.Y,App.Position.Z);
std::fflush(stdout);
App.StartGpuShaderWarmupAsync();
App.StartGeneration();
MSG Message{};
while(Message.message!=WM_QUIT)