Jump to content

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:


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!
Link to comment
Share on other sites

  • 9 months later...

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 :)

Link to comment
Share on other sites


 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




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...