jit.gl.texture and usesrcdim?

karl krach's icon
Max Patch
Copy patch and select New From Clipboard in Max.

hi,
i am a bit confused about jit.gl.texture: according to its reference, it does support usesrcdim just like normal matrixes but actually it does not.
or do i just not get it?
the following patch illustrates what i mean - basicallly i just want to eat the chili stems...
best
k

Rob Ramirez's icon

src/dstdim only work with the subtex_matrix message.
this needs to be documented better, so thankyou for pointing it out.

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

below is your patch modified to work as expected.
please note, you must send at least one regular jit_matrix before using the subtex_matrix message.

karl krach's icon

ah! thanks for clearing me up!
does that mean i load the incoming matrix twice onto the gpu?
i am just asking since my matrix is pretty big (1980x1200) and in the meantime i tried to do the same with td.resample.jxs... which is not that elegant but now i am wondering which approach would be better in terms of performance?
and one more question: how would that work once in gpu land? like using usesrcdim from one texture to another?
(i try to do jit.scissors/jit.glue on the gpu...)
thanks once more!
k

Rob Ramirez's icon

you don't need to load it twice, you only need to initialize the jit.gl.texture with a full frame matrix (it can simply be black).
after that you can use subtex_matrix.

not sure what would be better.

see my reply here for a way to do this dynamically with jit.gl.pix on the gpu.
https://cycling74.com/forums/copying-a-texture-to-a-portion-of-another-texture-on-the-gpu

karl krach's icon

mhm... i tried to do this and it sorta works but it does not give me the performance boost i hoped for... even one jit.glue (which i need since otherwise i would have readbacks from gpu) is slowing things down more then when i just upscale the depthmap and save my matrix with 2 fullres planes... but i had another idea:
as i wrote above, i only need to do this whole procedure to save two matrixes (one big, one small) to a jxf-file. i do not need to see these matrixes or anything - as long as i can separate them again when i read them in later.
now i am wondering: is there maybe some other way to achieve this? maybe some trick of the jxf-format?
again: thank you a lot!
k

Rob Ramirez's icon

can you post a patch? i'm just making assumptions without one

karl krach's icon

it is sort of hard to isolate and really messy - however if you should have an example of combining eg. 4 textures into one big one (like a quadsplit), i would gladly take it, because actually this still does not work and i am quite lost with it - i switched back to jit.glue and scissors for the time being.

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

by the way: i had a bunch of serious crashes (the computer would just turn off all of a sudden - something i have not seen on a mac very often yet) and i think that happened when invalid files got written, maybe because the depth map arrived too slow and the pack produced an invalid matrix.
this is why i introduced the buddy - see patch below, so far this seems to work stable, knock on wood...
best
k

karl krach's icon

hey,
since this problem is still bugging me... forget the scissoring, just the glueing (and since there does not seem to be an example patch in the forum, i promise i will post one if i figure this out):
let's say i want to do something like a quadsplit, i have 4 small matrixes i just want to glue together on the gpu.
- i glue to one single videoplane OR to one for each matrix (=4) and then use jit.gl.node?
- i cannot glue in a slab or to a texture, right?
- what parameters do i use for positioning the matrixes? @position? @tex_offset?
- although my small matrixes are exactly a fourth of the big matrix dimension, some scaling seems to take place - even if i set transform_reset to 0. how would i prevent that?
- does this have to do with blending, that is blend_enable=1?
- if i have to glue to a videoplane but i do not want to show that, do i need to create a second render context, one without window? or do i just use my main one and assign the videoplane a bottom layer?

again, thank you so much for your help!
k

Rob Ramirez's icon

hi karl.
@transform_reset 2 is your friend.

this method works with either matrices or textures, and works with any window size.
by default, gl.texture and gl.slab will adapt their dimensions to the input matrix.

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

if this is not what you're trying to achieve, please explain further.

karl krach's icon

AHA...!
it is that simple the end! i thought transform_reset 2 is for scaling...

now it works nicely but seems really heavy on the gpu.. so one last question:
i do NOT need to see the immediate result of the glueing - so i capture the composited splitscreen to a gl.node, then do some imageprocessing on slabs, then render to final videoplanes for viewing.

question is: would i use only one jit.gl.render for all and just do the stitching on layer 0 so i do not see it?
or would it make more sense to use a separate jit.gl.render with no window attached just for the glueing and only transfer it to the main rendercontext when capturing to the node?
or is there even better ways?

again, thank you so much!
k

Rob Ramirez's icon

i don't really understand the question.

you should really only create a separate render context if you need a separate render destination (window or pwindow).

if this doesn't help, please restate, or start a new topic.