GL Context and Subpatchers and multiple Worlds and You

Dante's icon

Basically: I need 2 fullscreen windows: 1 for a recorder and another for a projector for a realtime performance.
Whats the patch do :
I am trying to have a webcam go into several effects. (all on gpu) Some of these effects are jit.gl.pix's with jit.movies textures going into them. The main chain of effects will be sent to the main jit.world. One texture output of a movie will be sent to a second jit.world.

The problem:
When i turn on the 2nd world the first world's screen goes black and i have to restart max to get it to work again. Sometimes this produces a jit_gl_geometry error.

Every time I close the patch I get 2 jit.gl: invalid extension called

Im including a zip w some preset files and the gl3 shader file, or since this is more likely just a context/ subpatcher error on my part im just embedding the patch for a quick look.

I really appreciate any help, ive been troubleshooting this for too many days and i just cant see it anymore.

Max Patch
Copy patch and select New From Clipboard in Max.

Pawn Forum.zip
zip 41.84 KB

Yoann's icon

don't use 2 world, just 2 videoplane / cornerpin into one large window. if you output on hdmi and you use an external recorder, a HDMI splitter could be another way to do it

Dante's icon

Thank you YOANN I have been investigating splitters, but have also accomplished this on my mbp a couple times w no prob, and my projection is basically a still reference image. I believe this is a context error.

I think I have found a solution, although i still have to try it on my machine. https://cycling74.com/forums/no-more-than-one-jit-gl-render-in-a-patcher

I think I need to use the @drawto on my many jit.movies. I am very confused between naming objects such as [jit.gl.videoplane ctx] and the difference in [jit.movie which cannot be named here @drawto ctx] and then also with objects like [jit.gl.pix ctx] which have @name, @drawto and also can take a context before attributes.

I have been over the Video and Graphics tutorials many times, but it seems patching with two jit.worlds requires much more specificity. Especially when you try to organize and use subpatchers.

I think my confusion comes from how node receives @drawto from other objects. So in my confused mind this chain: [movie @drawto ctx] - [gl. pix] -[ videoplane @drawto ctx] would send both a movie and the 'effected' movie to the world.

My questions are:

What is the difference between "naming an instance" and "drawing context"

Specifically with jit.gl.pix and jit.gl.slab is this [jit.gl.pix ctx @drawto ctx] basically redundant in terms of naming a context?

When using multiple worlds (and possibly multiple grabs) does jit.grab need a @drawto similarly to jit.movie?

Also If there is an article or reference that addresses multiple screens / worlds I would really like to see it. I started using Max with the intention of using 2 outputs often, but when i see scattered info on the forum, for instance, regarding 1 world and using a splitter. I never know if it is a) dated, b) for super-experts who are using 7 monitors who want that extra 3% CPU or GPU. or c) if it is how Jitter was made to operate.

Rob Ramirez's icon

it seems that rather than any fundamental misunderstandings of the workings, you have instead found a bug with rendering automatic-enabled video objects, jit.gl.slab/pix, and more than a single jit.world context. i can reproduce it with this simple patch:

Max Patch
Copy patch and select New From Clipboard in Max.

my guess is that this hasn't come up much because most use cases only require a single jit.world context, and if multiple displays are desired, then the jit.world window spans across those displays (and jit.gl.cornerpin is utilized as described above).

so if at all possible to avoid the second jit.world. if unable, then my suggestion for a workaround is to render all content for all displays using a single jit.world context and (and as many jit.gl.node @capture sub-contexts) for each separate display window required. your secondary jit.world objects are are then only used to display the desired texture output rendered by the first context (and do not other processing). i think most importantly all texture-outputing video objects (jit.movie and jit.grab) need to belong to this main context. in my tests this was a suitable workaround.

alternatively disable automatic mode for all video objects and trigger manually.

that being said, it is a bug so thanks for the report! i'll get it ticketed.

Dante's icon

Oh wow! I was not expecting that.

Thank you Rob for taking the time to look into my issue. I really appreciate it. And thank you for the workaround.

Dante's icon

uhh sorry Rob. Your suggestions made sense to me, but I keep getting this error every frame:

jit.gl.texture: bind: GL Error: Invalid operation
jit.gl.texture: blit: GL Error: Invalid operation

I must not be implementing them correctly.

I have tried removing the second world altogether and restarting max. Same error. I have also tried keeping the second world and following the guidelines you laid out. Specifically: 1) adding all jit.movie and jit.grab to the main context, and 2) taking all other processing away from second world.

Sometimes when troubleshooting the problem goes away and I test by restarting max and it works fine. But I sleep and turn on computer and it happens again.

Edit: if i recreate jit.world after opening the patch the problem goes away.

Rob Ramirez's icon

go ahead and send me your updated patch and i'll have a look

Dante's icon

thanks Rob, just fyi, the soonest i can post it is Sunday.

Dante's icon

Here it is. Thanks for taking a look.

forum.zip
zip 38.32 KB