I create a simple 3D scene(with only one cube) on My MBP16’ , the top FPS is only 60FPS, but the sample scene can reach 400FPS on my Win PC. Most important of all, the GPU of Mac is about 2x times better than my old PC.
I tried many methods, such as closing the vsync, or use the code to control FPS. It worked when the Rate is set bellow 60Hz(such as 50Hz), but it doesn’t work if I set the Rate higher than 60Hz(such as 120Hz). Can anyone help me?
public float Rate = 120f;
float currentFrameTime;
void Start()
{
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 300;
currentFrameTime = Time.realtimeSinceStartup;
StartCoroutine(“WaitForNextFrame”);
}
IEnumerator WaitForNextFrame()
{
while (true)
{
yield return new WaitForEndOfFrame();
currentFrameTime += 1.0f / Rate;
var t = Time.realtimeSinceStartup;
var sleepTime = currentFrameTime - t - 0.01f;
if (sleepTime > 0)
Thread.Sleep((int)(sleepTime * 1000));
while (t < currentFrameTime)
t = Time.realtimeSinceStartup;
}
}