mickelson / attract

A graphical front-end for command line emulators that hides the underlying operating system and is intended to be controlled with a joystick or gamepad.
http://attractmode.org
GNU General Public License v3.0
393 stars 115 forks source link

Strange 50% CPU usage on nVidia #468

Open oomek opened 6 years ago

oomek commented 6 years ago
// Impact of nVidia GPU on CPU performance
// Run in Fullscreen mode

local flw = fe.layout.width
local flh = fe.layout.height

local bar1 = fe.add_image("white.png", 0, 0, 32, flh / 2)
local bar2 = fe.add_image("white.png", 0, flh / 2, 32, flh / 2)

function tick( ttime )
{
    // this line is using:
    // 1% of CPU with Threaded Optimization OFF in the nVidia control panel
    // 1% - 25% of CPU with Threaded Optimization ON
    bar1.x = ceil( ttime / 16.666667 % flw )

    // this line is using:
    // 25% of CPU on with Threaded Optimization OFF
    // 50% of CPU on with Threaded Optimization ON
    bar2.x++

    if ( bar2.x > flw ) bar2.x = 0
}

fe.add_ticks_callback( "tick" )
oomek commented 6 years ago

I've narrowed this down to 2 flags in the 3D settings on nvidia equipped PCs

OGL_THREAD_CONTROL_STRING defined as Threaded Optimizations in nv control panel It's default value is AUTO and for AM it's set to ON. When you set this to OFF you get 25% less CPU usage

OGL_FORCE_BLIT_STRING defined only in nvidia inspector, but not present in nv control panel It's default value is OFF. When it's ON you get an additional 25% reduction in CPU usage

What I'm thinking is we could create a profile when AM starts and define those flags on nvidia equipped PCs. When we do this it's also good to enable OGL_TRIPLE_BUFFER_STRING to ON I've observed it's beneficial for the reduction of stuttering on image loading, until we find a definite way of asynchronous image loading. I'm still thinking about it and I found out that the initial problems with threads behaving irrationally were caused bu those 2 flags I mentioned set to default values. I have now more control over the OGL commands queuing.