Merge //UE5/Release-Engine-Staging @14903491 to //UE5/Main

[CL 14906022 by Marc Audy in ue5-main branch]
This commit is contained in:
Marc Audy
2020-12-11 14:21:20 -04:00
parent f9a451bd76
commit ada7c144fa
1051 changed files with 59785 additions and 19123 deletions
@@ -91,6 +91,14 @@ static TAutoConsoleVariable<FString> CVarAndroidCPUThermalSensorFilePath(
TEXT("Overrides CPU Thermal sensor file path")
);
static float GAndroidMemoryStateChangeThreshold = 0.1f;
static FAutoConsoleVariableRef CAndroidMemoryStateChangeThreshold(
TEXT("android.AndroidMemoryStateChangeThreshold"),
GAndroidMemoryStateChangeThreshold,
TEXT("The memory state change threshold after which memory state is reported to memory warning callback"),
ECVF_Default
);
#if STATS || ENABLE_STATNAMEDEVENTS
int32 FAndroidMisc::TraceMarkerFileDescriptor = -1;
@@ -108,6 +116,8 @@ static bool bUseNativeSystrace = false;
// run time compatibility information
FString FAndroidMisc::AndroidVersion; // version of android we are running eg "4.0.4"
int32 FAndroidMisc::AndroidMajorVersion = 0; // integer major version of Android we are running, eg 10
int32 FAndroidMisc::TargetSDKVersion = 0; // Target SDK version, eg 29.
FString FAndroidMisc::DeviceMake; // make of the device we are running on eg. "samsung"
FString FAndroidMisc::DeviceModel; // model of the device we are running on eg "SAMSUNG-SGH-I437"
FString FAndroidMisc::DeviceBuildNumber; // platform image build number of device "R16NW.G960NKSU1ARD6"
@@ -1600,9 +1610,11 @@ bool FAndroidMisc::FileExistsInPlatformPackage(const FString& RelativePath)
return false;
}
void FAndroidMisc::SetVersionInfo( FString InAndroidVersion, FString InDeviceMake, FString InDeviceModel, FString InDeviceBuildNumber, FString InOSLanguage )
void FAndroidMisc::SetVersionInfo( FString InAndroidVersion, int32 InTargetSDKVersion, FString InDeviceMake, FString InDeviceModel, FString InDeviceBuildNumber, FString InOSLanguage )
{
AndroidVersion = InAndroidVersion;
AndroidMajorVersion = FCString::Atoi(*InAndroidVersion);
TargetSDKVersion = InTargetSDKVersion;
DeviceMake = InDeviceMake;
DeviceModel = InDeviceModel;
DeviceBuildNumber = InDeviceBuildNumber;
@@ -1616,6 +1628,16 @@ const FString FAndroidMisc::GetAndroidVersion()
return AndroidVersion;
}
int32 FAndroidMisc::GetAndroidMajorVersion()
{
return AndroidMajorVersion;
}
int32 FAndroidMisc::GetTargetSDKVersion()
{
return TargetSDKVersion;
}
const FString FAndroidMisc::GetDeviceMake()
{
return DeviceMake;
@@ -2912,26 +2934,9 @@ int32 FAndroidMisc::GetNativeDisplayRefreshRate()
static FAndroidMemoryWarningContext GAndroidMemoryWarningContext;
void (*GMemoryWarningHandler)(const FGenericMemoryWarningContext& Context) = NULL;
void FAndroidMisc::UpdateOSMemoryStatus(EOSMemoryStatusCategory OSMemoryStatusCategory, int value)
{
switch (OSMemoryStatusCategory)
{
case EOSMemoryStatusCategory::OSTrim:
GAndroidMemoryWarningContext.LastTrimMemoryState = value;
break;
case EOSMemoryStatusCategory::MemoryAdvisorState:
GAndroidMemoryWarningContext.LastNativeMemoryAdvisorState = value;
break;
case EOSMemoryStatusCategory::MemoryAdvisorEstimateMB:
GAndroidMemoryWarningContext.MemoryAdvisorEstimatedAvailableMemoryMB = value;
break;
case EOSMemoryStatusCategory::OomScore:
GAndroidMemoryWarningContext.OomScore = value;
break;
default:
checkNoEntry();
}
static void SendMemoryWarningContext()
{
if (FTaskGraphInterface::IsRunning())
{
// Run on game thread to avoid mem handler callback getting confused.
@@ -2952,6 +2957,41 @@ void FAndroidMisc::UpdateOSMemoryStatus(EOSMemoryStatusCategory OSMemoryStatusCa
}
}
void FAndroidMisc::UpdateOSMemoryStatus(EOSMemoryStatusCategory OSMemoryStatusCategory, int Value)
{
switch (OSMemoryStatusCategory)
{
case EOSMemoryStatusCategory::OSTrim:
GAndroidMemoryWarningContext.LastTrimMemoryState = Value;
break;
default:
checkNoEntry();
}
SendMemoryWarningContext();
}
FORCEINLINE bool ValueOutsideThreshold(float Value, float BaseLine, float Threshold)
{
return Value > BaseLine * (1.0f + Threshold)
|| Value < BaseLine * (1.0f - Threshold);
}
void FAndroidMisc::UpdateMemoryAdvisorState(int State, int EstimateAvailableMB, int OOMScore)
{
bool bUpdate = GAndroidMemoryWarningContext.LastNativeMemoryAdvisorState != State;
bUpdate |= ValueOutsideThreshold(EstimateAvailableMB, GAndroidMemoryWarningContext.MemoryAdvisorEstimatedAvailableMemoryMB, GAndroidMemoryStateChangeThreshold);
bUpdate |= ValueOutsideThreshold(OOMScore, GAndroidMemoryWarningContext.OomScore, GAndroidMemoryStateChangeThreshold);
if (bUpdate)
{
GAndroidMemoryWarningContext.LastNativeMemoryAdvisorState = State;
GAndroidMemoryWarningContext.MemoryAdvisorEstimatedAvailableMemoryMB = EstimateAvailableMB;
GAndroidMemoryWarningContext.OomScore = OOMScore;
SendMemoryWarningContext();
}
}
void FAndroidMisc::SetMemoryWarningHandler(void (*InHandler)(const FGenericMemoryWarningContext& Context))
{
check(IsInGameThread());
@@ -145,6 +145,21 @@ extern int32 unwind_backtrace_signal(void* sigcontext, uint64* Backtrace, int32
uint32 FAndroidPlatformStackWalk::CaptureStackBackTrace(uint64* BackTrace, uint32 MaxDepth, void* Context)
{
#if PLATFORM_ANDROID_ARM64
if (FAndroidMisc::GetTargetSDKVersion() >= 29 && FAndroidMisc::GetAndroidMajorVersion() == 10)
{
// UE-103382
// due to execute-only memory (xom) we cannot currently walk the stack on Android 10 devices when targeting Android 29 or greater.
static int32 OnceOnly = 0;
if (Context == nullptr && OnceOnly == 0)
{
__android_log_print(ANDROID_LOG_DEBUG, "UE4", "FAndroidPlatformStackWalk::CaptureStackBackTrace disabled on Android 10 with TargetSDK >= 29 due to XOM.");
OnceOnly = 1;
}
return 0;
}
#endif
// Make sure we have place to store the information
if (BackTrace == NULL || MaxDepth == 0)
{
@@ -161,23 +161,27 @@ CSV_DEFINE_STAT(AndroidMemory, TrimMemoryForegroundLevel);
static int GMemoryWarningStatus = 0;
CSV_DEFINE_STAT(AndroidMemory, MemoryWarningState);
void FAndroidStats::Init()
void FAndroidStats::Init(bool bEnableHWCPipe)
{
(void)bEnableHWCPipe;
#if HWCPIPE_SUPPORTED
static hwcpipe::HWCPipe HWCPipe({}, {hwcpipe::GpuCounter::GpuCycles,
hwcpipe::GpuCounter::VertexComputeCycles,
hwcpipe::GpuCounter::FragmentCycles,
hwcpipe::GpuCounter::Pixels,
hwcpipe::GpuCounter::ShaderCycles,
hwcpipe::GpuCounter::ShaderArithmeticCycles,
hwcpipe::GpuCounter::ShaderLoadStoreCycles,
hwcpipe::GpuCounter::ShaderTextureCycles,
hwcpipe::GpuCounter::ExternalMemoryReadBytes,
hwcpipe::GpuCounter::ExternalMemoryWriteBytes,});
if (hwcpipe::get_last_error() == nullptr)
if (bEnableHWCPipe)
{
GHWCPipe = &HWCPipe;
GHWCPipe->run();
static hwcpipe::HWCPipe HWCPipe({}, {hwcpipe::GpuCounter::GpuCycles,
hwcpipe::GpuCounter::VertexComputeCycles,
hwcpipe::GpuCounter::FragmentCycles,
hwcpipe::GpuCounter::Pixels,
hwcpipe::GpuCounter::ShaderCycles,
hwcpipe::GpuCounter::ShaderArithmeticCycles,
hwcpipe::GpuCounter::ShaderLoadStoreCycles,
hwcpipe::GpuCounter::ShaderTextureCycles,
hwcpipe::GpuCounter::ExternalMemoryReadBytes,
hwcpipe::GpuCounter::ExternalMemoryWriteBytes,});
if (hwcpipe::get_last_error() == nullptr)
{
GHWCPipe = &HWCPipe;
GHWCPipe->run();
}
}
#endif
}
@@ -235,7 +239,7 @@ void FAndroidStats::OnTrimMemory(int TrimLevel)
}
}
void FAndroidStats::OnMemoryWarningChanged(int Status)
void FAndroidStats::SetMemoryWarningState(int Status)
{
GMemoryWarningStatus = Status;
}
@@ -409,9 +413,9 @@ void FAndroidStats::UpdateAndroidStats()
static const FName ThermalStatus = GET_STATFNAME(STAT_ThermalStatus);
SET_FLOAT_STAT_BY_FNAME(CPUStatName, CPUTemp);
SET_FLOAT_STAT_BY_FNAME(ThermalStatus, GThermalStatus);
#endif
UpdateGPUStats();
#endif
}
static void UpdateGPUStats()