in RealityMaterialExplorer/Assets/Oculus/VR/Editor/OVRSystemProfilerPanel.cs [59:255]
void OnGUI()
{
showAndroidOptions = EditorGUILayout.Foldout(showAndroidOptions, "Android Tools");
if (showAndroidOptions)
{
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Android SDK root path: ", androidSdkRootPath);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button("Start Server"))
{
if (adbTool == null)
{
adbTool = new OVRADBTool(androidSdkRootPath);
}
if (adbTool.isReady)
{
int exitCode = adbTool.StartServer(null);
EditorUtility.DisplayDialog("ADB StartServer", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
}
else
{
EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
}
}
if (GUILayout.Button("Kill Server"))
{
if (adbTool == null)
{
adbTool = new OVRADBTool(androidSdkRootPath);
}
if (adbTool.isReady)
{
int exitCode = adbTool.KillServer(null);
EditorUtility.DisplayDialog("ADB KillServer", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
}
else
{
EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
}
}
if (GUILayout.Button("Forward Port"))
{
if (adbTool == null)
{
adbTool = new OVRADBTool(androidSdkRootPath);
}
if (adbTool.isReady)
{
int exitCode = adbTool.ForwardPort(remoteListeningPort, null);
EditorUtility.DisplayDialog("ADB ForwardPort", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
OVRPlugin.SendEvent("device_metrics_profiler", (exitCode == 0 ? "adb_forward_success" : "adb_forward_failure"));
}
else
{
EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
}
}
if (GUILayout.Button("Release Port"))
{
if (adbTool == null)
{
adbTool = new OVRADBTool(androidSdkRootPath);
}
if (adbTool.isReady)
{
int exitCode = adbTool.ReleasePort(remoteListeningPort, null);
EditorUtility.DisplayDialog("ADB ReleasePort", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
}
else
{
EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
}
}
GUILayout.EndHorizontal();
}
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
GUILayout.BeginHorizontal();
remoteListeningPort = EditorGUILayout.DelayedIntField("Remote Port", remoteListeningPort);
if (tcpClient.connectionState == OVRNetwork.OVRNetworkTcpClient.ConnectionState.Disconnected)
{
if (GUILayout.Button("Connect"))
{
ConnectPerfMetricsTcpServer();
pauseReceiveMetrics = false;
OVRPlugin.SendEvent("device_metrics_profiler", "connect");
}
}
else
{
if (tcpClient.connectionState == OVRNetwork.OVRNetworkTcpClient.ConnectionState.Connecting)
{
if (GUILayout.Button("Connecting ... Click again to Cancel"))
{
DisconnectPerfMetricsTcpServer();
OVRPlugin.SendEvent("device_metrics_profiler", "cancel");
}
}
else
{
if (GUILayout.Button("Disconnect"))
{
DisconnectPerfMetricsTcpServer();
OVRPlugin.SendEvent("device_metrics_profiler", "disconnect");
}
if (GUILayout.Button(pauseReceiveMetrics ? "Continue" : "Pause"))
{
pauseReceiveMetrics = !pauseReceiveMetrics;
}
}
}
GUILayout.EndHorizontal();
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
lock (receivedMetricsList)
{
PresentIntProperty("Frame Count", "frameCount");
PresentIntProperty("Dropped Frame Count", "compositorDroppedFrameCount");
float? avgFrameTime = GetAveragePerfValueFloat("deltaFrameTime");
if (avgFrameTime.HasValue)
{
float fps = 1.0f / avgFrameTime.Value;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("FPS", GUILayout.Width(labelWidth));
EditorGUILayout.LabelField(string.Format("{0:F1}", fps));
EditorGUILayout.EndHorizontal();
}
int? deviceCpuClockLevel = GetLatestPerfValueInt("deviceCpuClockLevel");
int? deviceGpuClockLevel = GetLatestPerfValueInt("deviceGpuClockLevel");
float? deviceCpuClockFrequencyInMHz = GetLatestPerfValueFloat("deviceCpuClockFrequencyInMHz");
float? deviceGpuClockFrequencyInMHz = GetLatestPerfValueFloat("deviceGpuClockFrequencyInMHz");
if (deviceCpuClockLevel.HasValue || deviceCpuClockFrequencyInMHz.HasValue)
{
string cpuLabel;
string cpuText;
if (deviceCpuClockLevel.HasValue && deviceCpuClockFrequencyInMHz.HasValue)
{
cpuLabel = "CPU Level (Freq)";
cpuText = string.Format("{0} ({1:F0} MHz)", deviceCpuClockLevel, deviceCpuClockFrequencyInMHz);
}
else if (deviceCpuClockLevel.HasValue)
{
cpuLabel = "CPU Level";
cpuText = string.Format("{0}", deviceCpuClockLevel);
}
else
{
cpuLabel = "CPU Frequency";
cpuText = string.Format("{0:F0} MHz", deviceCpuClockFrequencyInMHz);
}
PresentText(cpuLabel, cpuText);
}
if (deviceGpuClockLevel.HasValue || deviceGpuClockFrequencyInMHz.HasValue)
{
string cpuLabel;
string cpuText;
if (deviceGpuClockLevel.HasValue && deviceGpuClockFrequencyInMHz.HasValue)
{
cpuLabel = "GPU Level (Freq)";
cpuText = string.Format("{0} ({1:F0} MHz)", deviceGpuClockLevel, deviceGpuClockFrequencyInMHz);
}
else if (deviceGpuClockLevel.HasValue)
{
cpuLabel = "GPU Level";
cpuText = string.Format("{0}", deviceGpuClockLevel);
}
else
{
cpuLabel = "GPU Frequency";
cpuText = string.Format("{0:F0} MHz", deviceGpuClockFrequencyInMHz);
}
PresentText(cpuLabel, cpuText);
}
PresentColumnTitles("Current", "Average", "Peak");
PresentFloatTimeInMs("Frame Time", "deltaFrameTime", 0.020f, true, true);
PresentFloatTimeInMs("App CPU Time", "appCpuTime", 0.020f, true, true);
PresentFloatTimeInMs("App GPU Time", "appGpuTime", 0.020f, true, true);
PresentFloatTimeInMs("Compositor CPU Time", "compositorCpuTime", 0.020f, true, true);
PresentFloatTimeInMs("Compositor GPU Time", "compositorGpuTime", 0.020f, true, true);
PresentFloatPercentage("CPU Util (Average)", "systemCpuUtilAveragePercentage", false, false);
PresentFloatPercentage("CPU Util (Worst Core)", "systemCpuUtilWorstPercentage", false, false);
PresentFloatPercentage("GPU Util", "systemGpuUtilPercentage", false, false);
}
}