C’mon, a light year is a (big) unit of distance, not time
Seriously, what Sleep() is that ? Time units, implementation details ? Does varying the value change the cpu usage, still on the while-isrunning-sleep loop ? (ie. doing 1000, 100 , 10, 100000 …)
Open NVIDIA Control Panel (RMB on desktop or in Control Panels) Select „Manage 3D settings“, tab „Global Settings“, scroll
down the list and select line „Threaded optimization“, choose Off
nope no diffrence
i did try this while i was in there:
i turned off vertical sync and added a Sleep(1000/60) in the rendering thread. cpu usage went down to 2%
Your workaround is nice, but it is not a solution.
It works because your scene is simple for your GPU.
When you add more complexity the render time grows.
Then the Sleep value will be too high and fps will drop.
On the other hand there is no real solution until NV improves the driver.
Dont count on that… Sleep(N) in windows doesn’t mean it will sleep N miliseconds. Depending on hardware, drivers and application timer cofiguration, Sleep(N) works different.
Sleep(1) can sleep 15-16ms, Sleep(16) can sleep 30-32ms…
if i only start the loaderThread when theres work to do and delete the thread when there is no work to do the OpenGL wouldn’t have make the costfull switching between the threads. That way for most of the time only the renderingThread would be running.
So I tried this but it didnt work. Once the loaderThread has been started it can also be stopped, but OpenGL doesn’t seem to recognise this even though there’s is no longer any thread for it to contextswitch too, cpu usage 50% average, ill have to guess i’m missing some kind of OpenGL deloading code.
So my questions is what is the code? I’ve tested some that didnt work.
Note as before I also tried to never start the loaderThread and let the renderingThread handle all the rendering, cpu usage 6% average.
LoaderThreadStart(){
this->thread = new Thread(this);
}
LoaderThreadStop(){
delete this->thread;
}
LoaderThreadRun(){
if(!wglMakeCurrent( this->window1->getDeviceContext(), this->renderingContext)){
throw "Loader: run: wglMakeCurrent failed
";
}
this->doJobs();
//jobs are done so this thread can return
//glFinish(); //tested no effect
//wglMakeCurrent(0,0); //tested no effect
//wglDeleteContext(this->renderingContext); //tested no effect
}