Best coding practice in jitter/OpenGL

antik's icon

Hi there,

this is a somewhat general question about the most efficient way to work with jitter and OpenGL objects specifically. I attached a screenshot of a patch that I am currently building and I'll try to use it as an example to find the most optimal way to go about setting it up.

To explain the screenshot a bit further - what you're seeing are subpatchers/modules that work on a completely OpenGL basis and affect a video that is sent through them in different ways. A global rule that needs to be followed in my patch is that only one of the modules can be active at the same time; for example when the Filter Engine is active all other modules are rendered inactive.

One thing you can see however, is that I built the effect chain in serial, meaning the signal will still pass through the Delay and Isolator Engine, even if only the Filter Engine is activated. So here are my two questions:

1.) Does setting up a switch/gate in order to chain the effects in parallel bring a performance boost at all?
2.) If so, should I set the @automatic on OpenGL objects to 0 and manually send @enable 0 and @enable 1 messages to the objects whenever I am changing effects or does that offer no performance boost whatsoever? Basically what I'm asking is - do OpenGL objects drain CPU/GPU even if no signal is passing through?

Any help on the matter would be much appreciated!

Rob Ramirez's icon

basic rule of thumb, jit.gl.slab / jit.gl.pix will only do processing when they receive a texture or matrix input, or when they receive a bang. so gating their inputs will effectively shut them off.

most other jit.gl objects have an enable attribute to shut them off.

antik's icon

Thanks Rob, that helps a lot!

antik's icon

Hi there,

after you gave me the information about pix/slab objects I reconnected by patch in parallel and gated the signal so that only one of the effect modules is receiving the signal at a given time. I also implemented a jit.argb2uyvy object at the beginning of my video chain and changed the @colormode attribute to uyvy on all video processing objects.

All of this however gave no performance increase whatsoever.

After looking around I saw that pix and slab objects have @enabled set to 1 by default and @automatic set to 0, which I'm assuming means that they are always on. Should I rather switch their attributes so that @automatic is set to 1 and @enabled set to 0? This way the object will (in theory) be turned on only when a signal is passing through. Am I right in thinking so?

Also, am I doing something wrong with the uyvy colormode? A simplified signal flow for my video processing is as follows:

jit.movie -> jit.argb2uyvy -> jit.gl.pix @colormode uyvy -> jit.gl.videoplane @colormode uyvy -> jit.window @colormode uyvy

Reading about uyvy in the documentation I was told about a significant performance increase whereas my CPU usage is at the same % as it was in the previous version of my patch where I kept all effects in serial and used argb colormode.

Any help would be much appreciated!

Rob Ramirez's icon

if you're not seeing gains then you were probably already doing the correct thing. there should be no need to change the automatic or enable settings. you can check if a slab is disabled properly with a gated input by checking its output (with a button or print object). If nothing is output than it's properly disabled.

regarding colormodes, enabling uyvy mode is no longer needed for efficiency. the most efficient way to get images from movie files or video input devices is to use jit.movie / jit.grab @output_texture 1. unless you have a specific reason to change the colormode, I would leave it at the default of rgba for all GL image processing and drawing.

search the reference browser for "GL Texture Output" to read more.

antik's icon

Thanks for the reply!

Reflecting upon my previous post, I think I might be measuring performance wrong. I kept my eye on the CPU usage of my computer while jit.gl object all work on the GPU. I'm assuming measuring the fps of my video output would be a better measure of performance in my case.

I did however follow your advice on colormodes and switched back to argb. The @output_texture was a good call since I was previously summing different videos with jit.op whereas now I'm doing it with jit.gl.pix instead.

I'm afraid when it comes down to it, my Macbook Air might just be too old/weak to run my max patch without hiccups (sitting at 90% CPU usage when the patch is not doing anything).

Thanks for your help!