Openframeworks Processing Load

#1

Hi All,
I have a project that is using ASDFPixelSort to sort a row of pixels in an image whenever a user triggers a MQTT message.
The project is being shown on a 4K monitor. Whenever the OFX app is launched, the entire system slows down and the graphics card usage rockets up to 100% usage.
I think this is due to OFX re-drawing the image every cycle , however I can no be sure.
I just wondered if anyone has run into a similar issue or if anyone has any ideas of how to fix it?
Thanks,
Joel

#2

Hi, if you open a blank (just make a new project with project generator) and run it at full size on your monitor, does it slow down? if it does, then it is either a problem with OF or the GPU nor being powerful enough. If it does not then it seems that the problem must rely on your codign

#3

The problem could be the pixel sort addon:

the code is ported directly from a processing sketch, it does pixel operations on the CPU instead of GPU and allocates and deallocates memory inside the update loop, it doesn’t even look like something written for real-time use.
This is not really the cheapest way to do that in c++, so no wonder it could be hard to run at 4K.

But at this point it should slow down just when it is being used, instead you say that the program is always slow, even when the pixel sorting is not triggered? can you deactivate the pixel sorter and just draw an image to see if you have the same performance issues?

PS: can you give us some details about the system? OS / oF version / processor / graphic card

#4

So I’ve done some more digging and I’m confused.

I’m using
OFX Version: v0.10.1
OS: Mac Mojave 10.14.5
Processor: 2.3Ghz Intel I7 (I7-4850HQ)
Graphics Card: NVIDIA GeForce GT 750M 2 GB
External Screen Size: 3840 x 2160
Full System Specs

So it shouldn’t be OfxasdfPixelSort since they way I’m using it is altering one line at a time when it gets a user input. So there isn’t anything really intensive about that.
Below is the GPU workload as shown by activity monitor on the mac. I’ve highlighted whenever I did something so that you can see the difference in workload as I start different processes up.

You can see that the GPU usage randomly rockets up for no reason. I have tried rebooting the mac - which didn’t help. Sometimes closing and reopening OFX helps but not always. - OFX is the main workload - as you can see when I close it the GPU workload drops right down.
Even just displaying a 4k image using img.draw(0,0) sometimes fills the GPU workload to the max.

#5

It could also be that the OF App is running much faster than you need.

Does adding ofSetFrameRate(10); in ofApp::setup(){ make any difference?

All the best,
Theo

1 Like
#6

This, from first tests, seems to have helped alot!
Thanks for the suggestion. I mean its odd that in terms it used more GPU then others - but by setting the FPS to 10 it seems to have helped keep the workload low.