Enable AVX/SSE optimizations when building UE projects

在Engine\Source\Programs\UnrealBuildTool\Windows\VCToolChain.cs下:

//
			//	PC
			//
			if ((CompileEnvironment.Config.Target.Platform == CPPTargetPlatform.Win32) || 
				(CompileEnvironment.Config.Target.Platform == CPPTargetPlatform.Win64))
			{
				// SSE options are not allowed when using CLR compilation
				if (CompileEnvironment.Config.CLRMode == CPPCLRMode.CLRDisabled && WindowsPlatform.bUseVCCompilerArgs)
				{
					if (CompileEnvironment.Config.bUseAVX)
					{
						// Allow the compiler to generate AVX instructions.
						Arguments.Append(" /arch:AVX");
					}
					// SSE options are not allowed when using the 64 bit toolchain
					// (enables SSE2 automatically)
					else if (CompileEnvironment.Config.Target.Platform != CPPTargetPlatform.Win64)
					{
						// Allow the compiler to generate SSE2 instructions.
						Arguments.Append(" /arch:SSE2");
					}
				}

Under Engine\Source\UE4Game.Target.cs:

 public override void SetupGlobalEnvironment(
         TargetInfo Target,
         ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
         ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
         )
     {
OutCPPEnvironmentConfiguration.bUseAVX = true;
     }

Guess you like

Origin blog.csdn.net/qq_36653924/article/details/127730110