ajsmith8

Unlocking FPS

Recommended Posts

I'm working on using Babylon.js to create a gaming benchmark.  The primary test will measure the total time it takes to complete a game on different systems with an unlocked FPS.  I've done some research and looked into the source code / docs and I could not find anyway to do this other than a few hacks

 

My first attempt was to experiment with engine.fps and engine.fpsLimit.  I tried to set engine.fpsLimit to an extremely high number, which I had hoped would unlock the frame rate, but it did not seem to do anything.  

 

Next I attempted to use this hack:

www.chandlerprall.com/2011/06/beating-60fps-in-javascript/.

In short, window.postMessage('','*') is added to the end of the render loop.  Then you add an event listener that calls the render loop upon receiving the message, like this:

window.addEventListener('message', runRenderLoop, false);
 
This only worked somewhat.  The logic within my runRenderLoop method was run at a much higher rate than 60fps, but rendering slowed to a much slower rate.  engine.getFPS() only reported about 5fps, so this is also clearly unacceptable.
 
Any ideas on how to unlock the FPS?  Is there something that I am missing?  Thanks for any help in advance!

Share this post


Link to post
Share on other sites

Sorry to up this topic, but i don't find after some searches a definition of potential FPS. What does 1000/scene.getLastFrameDuration() (what is the logic behind this) ? And how this is related to real FPS ?

Thanks :)

Share this post


Link to post
Share on other sites

Hi,

 First of all, cool project! We had the idea in the past to work on such a project (benchmark) but never had the time to work on it. ;-)

 In the browser, the best way to render the frame with efficiency is to use requestAnimationFrame that will let the browser deciding when to call you back based on its current utilization. It's far better than using setTimeout(1000/60) for instance. Anyway even with setTimeout set to 8 for instance to try to have 120fps, all browsers will limit the rendering to 60fps. Some recent Chrome builds have unlocked the FPS to 90 for WebVR and Oculus/Vive support.

 In conclusion: you can't ask to the browser to unlock the FPS like you can do in Win32 apps. That's why @deltakosh shares what we're using inside our debug layer tool, the potential FPS. Indeed, we know inside our engine the time it tooks to compute the last frame. For instance, let's say the current fps is 60 but the potential FPS is 200, it means that your GPU & browser could potentially display 200 fps. Unfortunately, this is not that simple. There are cases a bit more complex. Let's take the Mansion scene of babylonjs.com. It runs at 30 fps on my small laptop and says the potential fps is 50. This means that I'm losing rendering performance due to some job done on the CPU side (collision, physics, whatever).

 For your benchmark, you need to think about an algorithm / tests cases that will mix:

 - complex scenes like Sponza or Mansion that will stress the complete system: CPU, GPU & Browsers' implementation. Your score will then be computed based on an average FPS during the sequence provided by requestAnimationFrame callbacks + the potential FPS provided by getLastFrameDuration

 - pure GPU side scenes (using a unique draw call for instance) without anything enable on the CPU side (no collision, no physic, no sound, no input). The potential FPS will be probably what you would get if the browser would unlock the FPS

 

Bye,

David

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.