Jump to content

How to lock FPS.


photo

Recommended Posts

Hi,

i tried searching in the editor options, the viewport options, tried google "unigine lock fps", tried the documentation, tried the forum, still cant find any way to lock max fps to prevent my graphics card from melting. Whats the point in rendering the scene at 1500 Frames per second hmm ?

Edited by renaud.techer
Link to comment
  • 3 weeks later...

Hello, why "render_max_fps" increases the usage of the CPU? For example setting it to 30fps will increase the core#1 usage from 20% to 80% (and the UI becomes sluggish). Vsync (on Settings-Video) helps a lot to keep everything cool, but I was looking for something adjustable.

Link to comment

Dear @pufaqx,

Wonderful observation.  

Lots of statements are required to answer this. Making it real simple here.

In a case of free rendering...

Render Loop
{
	Calculations on CPU

	Fire Render command To GPU. (Now GPU will do rest of the things and return.)

	Next CPU stuff
}

But when you restrict the fps the simplest while loop technique. 

Render Loop
{
	auto CurrentTime = Timer::getFloatTime();
	m_dInterval = 1.0 / FPSRequired;
	
	auto NextFrameTime = m_dLastFrameTime + m_dInterval;

	while (CurrentTime < NextFrameTime)
	{
		CurrentTime = Timer::getFloatTime();
	}

	m_dLastFrameTime = CurrentTime;
                                       
	Calculations on CPU

	Fire Render command To GPU. (Now GPU will do rest of the things and return.)

	Next CPU stuff
}

Now you know where CPU core is wasting time and why CPU usage are high? Just to lock and wait to fire up GPU commands to match the required FPS.

If you talk about V SYNC, then GPU wait for vertical retrace on GPU clock itself. The GPU driver knows how to handle it when we fire command with D3D Present API in DirectX. CPU plays no role and CPU remains free.

I hope this answers questions revolving around your observation.

Rohit

Edited by rohit.gonsalves
  • Like 1
Link to comment

Hello Rohit, thank you for the fast reply. Yes, it does answer why, but since he know much time we need to wait, is it possible to insert a sleep in the loop? It probably won't be accurate but in some cases it can be acceptable.

Link to comment

Dear @pufaqx,

Consider you know that you need to wait for 50ms. Now you call sleep(50). But now it gives chance to other processes or threads to run during this time and probably after context switch when it returns, you could have wasted 80ms. 

This is always hard. In fact sleep(0) should return immediately, but it is an notification for context switch if any thread is waiting. So sleep main purpose is much more than exactly locking for some specific timing. Use it with care.

There are many resources you will find on internet for spin locks. Even Unigine api has spin locks.

Hope this helps.

Regards,

Rohit

Edited by rohit.gonsalves
Link to comment

The best thing I was able to do (with an NVIDIA GPU) to keep my laptop quiet and cool was:

  • install NVIDIA Profile Inspector 2.13
  • "Create a new profile"
  • "Add application to the profile" and select the editor exe
  • under "Sync And Refresh" change the value of "Frame Rate Limiter"
     
  • Like 1
Link to comment

Hey,

 

Here is what i do to prevent domestic fires : I set a low fps in screen settings, something between 10-30.

 

Then somewhere in the code (i use C# for scripting) I can set the max fps using :

Render.MaxFPS = 60;

 

This way the computor does not burn while working in the editor, or writing code !

 

There should be a way to disable realtime mode in the editor, render 1 frame in the viewport only when something changes, and then stop untill something else is updated.
I dont know if this already exists in Unigine, Blender's viewport is optimized like this, Unreal engine also allows to disable realtime preview of the scene.

 

Also it seems that the loading of the game when pressing the running button, is affected by the fps value. lol !
It loads instantly at 60fps, but if you set 5fps, it will take 10s to load the map with the Unigine loading screen.

 

Does the fps affect loading, is this the assets streaming feature that is fps dependant. Anyways.

 

Thanks for your fast answers.

Edited by renaud.techer
Discovered something else
Link to comment
7 hours ago, pufaqx said:

The best thing I was able to do (with an NVIDIA GPU) to keep my laptop quiet and cool was:

  • install NVIDIA Profile Inspector 2.13
  • "Create a new profile"
  • "Add application to the profile" and select the editor exe
  • under "Sync And Refresh" change the value of "Frame Rate Limiter"
     

Wonderful... NVIDIA driver handling stuff for you. If you are satisfied and it works for you, then there is no need to worry.

For me when I need to connect many other hardware to PC to interact with my rendering. The scenario changes completely and all the driver stuff is of no use. I can not use the VSYNC not the NVIDIA or AMD control panel stuff. Life is hard here. In fact a third party hardware is deciding on generated phase signals should I render or not.

Rohit

Link to comment
×
×
  • Create New...