虚幻4 引擎主循环

本文深入探讨了虚幻4引擎的主循环机制,通过分析EngineSourceRuntimeLaunchPrivateLaunchEngineLoop.cpp源代码,揭示了游戏运行过程中的核心流程和关键组件,帮助开发者理解引擎内部工作原理。
摘要由CSDN通过智能技术生成
void FEngineLoop::Tick()
{
#if !UE_BUILD_SHIPPING && !UE_BUILD_TEST
	FScopedSampleMallocChurn ChurnTracker;
#endif
	// Ensure we aren't starting a frame while loading or playing a loading movie
	ensure(GetMoviePlayer()->IsLoadingFinished() && !GetMoviePlayer()->IsMovieCurrentlyPlaying());

	FExternalProfiler* ActiveProfiler = FActiveExternalProfilerBase::GetActiveProfiler();
	if (ActiveProfiler)
	{
		ActiveProfiler->FrameSync();
	}

	SCOPED_NAMED_EVENT(FEngineLoopTick, FColor::Red);

	// early in the Tick() to get the callbacks for cvar changes called
	{
		QUICK_SCOPE_CYCLE_COUNTER(STAT_FEngineLoop_Tick_CallAllConsoleVariableSinks);
		IConsoleManager::Get().CallAllConsoleVariableSinks();
	}

	{ 
		SCOPE_CYCLE_COUNTER( STAT_FrameTime );	

		ENQUEUE_UNIQUE_RENDER_COMMAND(
			BeginFrame,
		{
			GRHICommandList.LatchBypass();
			GFrameNumberRenderThread++;
			RHICmdList.PushEvent(*FString::Printf(TEXT("Frame%d"),GFrameNumberRenderThread));
			RHICmdList.BeginFrame();
		});

		{
			QUICK_SCOPE_CYCLE_COUNTER(STAT_FEngineLoop_FlushThreadedLogs);
			// Flush debug output which has been buffered by other threads.
			GLog->FlushThreadedLogs();
		}

		// Exit if frame limit is reached in benchmark mode.
		if( (FApp::IsBenchmarking() && MaxFrameCounter && (GFrameCounter > MaxFrameCounter))
			// or time limit is reached if set.
			|| (MaxTickTime && (TotalTickTime > MaxTickTime)) )
		{
			FPlatformMisc::RequestExit(0);
		}

		{
			QUICK_SCOPE_CYCLE_COUNTER(STAT_FEngineLoop_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值