Forums > Jitter

any way to avoid this read-back-from-GPU?

August 27, 2006 | 8:35 am

hello,
thanks to the patch that joshua posted in respond to keiths question, i can now do what i was trying to do with jit.gl.mesh and indeed it is faster than handing geometries to jit.gl.render by hand.

i have one question, however; i’d like to make the displacements of my geometry’s vertices "smooth". i can accomplish that by blurring the matrix that defines the z-displacement. to get a nice cheap blur, i’d like to use the GPU bassed gaussian blur from the examples; however, in order to provide the blurred matrix to jit.gl.mesh, i need to copy it back to RAM from VRAM with jit.matrix which is an expensive step. is there any clever way to avoid that step?

the patch is below.

———————-

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 573 365 69 196617 loadmess 0.2;
#P flonum 573 398 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 713 286 48 196617 loadbang;
#P hidden newex 713 306 31 196617 t b 3;
#P comment 776 406 66 196617 draw on LCD;
#B color 6;
#P window setfont "Sans Serif" 18.;
#P comment 745 398 25 196626 5.;
#B color 6;
#P button 857 282 15 0;
#P user jit.pwindow 842 346 29 20 0 1 0 0 1 0;
#P window setfont "Sans Serif" 9.;
#P message 987 265 101 196617 read chilis.jpg , bang;
#P comment 454 396 60 196617 blur on/off;
#B color 6;
#P window setfont "Sans Serif" 18.;
#P comment 423 388 25 196626 6.;
#B color 6;
#P toggle 531 402 15 0;
#P window setfont "Sans Serif" 9.;
#N vpatcher 30 89 704 557;
#P inlet 268 59 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 50 50 59 196617 r geomsize;
#P newex 50 78 27 196617 t b l;
#P window linecount 2;
#P message 472 141 178 196617 exprfill 0 "norm[0]" , exprfill 1 1.-
norm[1] , bang;
#P window linecount 1;
#P newex 472 173 190 196617 jit.matrix texcoords 2 float32 320 240;
#P window linecount 2;
#P message 293 141 112 196617 exprfill 0 "snorm[0]" , exprfill 1 "snorm[1]" ,;
#P window linecount 1;
#P newex 293 173 168 196617 jit.matrix geom 3 float32 320 240;
#P newex 67 173 211 196617 jit.pack 3 float32 320 240 @out_name geom;
#P inlet 173 58 15 0;
#P outlet 472 195 15 0;
#P outlet 67 195 15 0;
#P connect 9 0 8 0;
#P connect 8 1 3 0;
#P connect 2 0 3 0;
#P connect 3 0 0 0;
#P connect 10 0 3 2;
#P connect 8 0 5 0;
#P connect 8 1 4 0;
#P connect 5 0 4 0;
#P connect 8 0 7 0;
#P connect 8 1 6 0;
#P connect 7 0 6 0;
#P connect 6 0 1 0;
#P pop;
#P newobj 164 506 61 196617 p geometry;
#N vpatcher 0 44 1440 870;
#P inlet 592 75 15 0;
#P user jit.pwindow 616 167 82 62 0 1 0 0 1 0;
#P user jit.pwindow 619 365 82 62 0 1 0 0 1 0;
#P inlet 322 50 15 0;
#P user gswitch2 357 150 39 32 0 0;
#P window setfont "Sans Serif" 9.;
#P newex 318 234 59 196617 r geomsize;
#P newex 386 263 142 196617 jit.matrix 4 float32 320 240;
#P newex 386 234 167 196617 jit.gl.slab.gauss6x.pat render_grid;
#P inlet 386 51 15 0;
#P outlet 386 334 15 0;
#P connect 6 0 5 0;
#P connect 1 0 5 1;
#P connect 5 1 2 0;
#P connect 4 0 3 0;
#P connect 2 0 3 0;
#P connect 3 0 0 0;
#P fasten 5 0 0 0 288 219 288 272;
#P connect 9 0 2 1;
#P connect 1 0 8 0;
#P connect 3 0 7 0;
#P pop;
#P newobj 531 435 52 196617 p blur;
#P comment 189 90 40 196617 render;
#B color 6;
#P comment 980 246 142 196617 send image to GPU as texture;
#B color 6;
#N vpatcher 40 104 640 504;
#P window setfont "Sans Serif" 9.;
#P newex 50 140 66 196617 prepend size;
#P newex 50 106 79 196617 vexpr $i1 + 20;
#P newex 50 77 53 196617 route dim;
#P newex 50 50 59 196617 r geomsize;
#P outlet 50 162 15 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 0 0;
#P pop;
#P hidden newobj 691 404 30 196617 p;
#P newex 1031 304 57 196617 route read;
#P user jit.fpsgui 813 304 60 196617 3;
#P flonum 205 112 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 164 111 15 0;
#P newex 164 131 51 196617 qmetro 2;
#P user jit.fpsgui 88 164 60 196617 0;
#P window setfont "Sans Serif" 18.;
#P comment 160 82 25 196626 4.;
#B color 6;
#P comment 954 240 25 196626 3.;
#B color 6;
#P button 1031 330 15 0;
#P window setfont "Sans Serif" 9.;
#P number 713 330 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 713 350 73 196617 pensize $1 $1;
#P comment 1039 58 74 196617 geometry size;
#B color 6;
#P comment 923 58 57 196617 image size;
#B color 6;
#P window setfont "Sans Serif" 18.;
#P comment 1012 51 25 196626 2.;
#B color 6;
#P window setfont "Sans Serif" 9.;
#P newex 757 90 60 196617 loadmess 1;
#P newex 875 245 62 196617 r imagesize;
#P button 876 59 15 0;
#P button 994 57 15 0;
#P newex 994 203 59 196617 s geomsize;
#P newex 994 179 64 196617 prepend dim;
#P newex 994 154 56 196617 route text;
#P user textedit 994 85 1094 135 32896 3 9 160 120;
#P newex 876 203 62 196617 s imagesize;
#P newex 876 179 64 196617 prepend dim;
#P newex 876 154 56 196617 route text;
#P user textedit 876 85 976 135 32896 3 9 320 240;
#P message 679 350 33 196617 clear;
#P user jit.pwindow 678 439 162 122 0 1 0 0 1 0;
#N vpatcher 0 44 1440 870;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 692 282 56 196617 jit.pack 4.;
#P newex 717 236 115 196617 jit.op @op !- @val 255.;
#P message 725 73 45 196617 color $1;
#P number 725 54 35 9 0 255 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 103 168 66 196617 prepend size;
#P newex 103 138 53 196617 route dim;
#P newex 103 101 59 196617 r geomsize;
#P newex 296 119 59 196617 r geomsize;
#P newex 865 73 59 196617 r geomsize;
#P newex 689 204 66 196617 jit.unpack 4.;
#P newex 384 178 142 196617 jit.matrix 4 float32 640 480;
#P outlet 485 331 15 0;
#P inlet 1127 51 15 0;
#P inlet 588 51 15 0;
#P outlet 384 331 15 0;
#P window linecount 0;
#P newex 824 74 31 196617 r lcd;
#P window linecount 1;
#P message 1057 465 44 196617 getpixel;
#P message 1057 445 50 196617 getpenloc;
#P toggle 824 514 15 0;
#P newex 824 532 50 196617 gate 1 1;
#P newex 961 521 50 196617 gate 2 2;
#P message 983 548 50 196617 set lineto;
#P message 900 549 58 196617 set moveto;
#P newex 898 443 29 196617 t i b;
#P newex 900 470 27 196617 int;
#P newex 824 583 79 196617 prepend moveto;
#P newex 824 487 47 196617 pack 0 0;
#P message 984 74 32 196617 reset;
#P message 984 57 31 196617 clear;
#P newex 824 117 111 196617 jit.lcd 4 char 640 480;
#B color 5;
#P comment 839 424 28 196617 x , y;
#P number 988 402 16 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 970 402 16 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 952 402 16 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 934 402 16 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 916 402 16 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 898 402 16 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 861 402 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 824 402 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 824 376 166 196617 unpack 0 0 0 0 0 0 0 0;
#P newex 824 350 110 196617 route mouse mouseidle;
#P comment 908 424 169 196617 button , cmd , shift , caps , opt , ctrl;
#P newex 900 491 40 196617 sel 0 1;
#P window linecount 4;
#P comment 1051 512 130 196617 picts can either be read in from a file just like lcd , or can reference named matrices (must be 4 char);
#P user ubumenu 961 494 82 196617 0 1 1 0;
#X add no_mouse;
#X add mouse_moves;
#X add mouse_draws;
#X prefix_set 0 0 0;
#X pattrmode 1;
#P connect 38 0 39 0;
#P connect 39 0 40 0;
#P connect 44 0 34 0;
#P connect 31 0 34 0;
#P connect 37 0 34 0;
#P connect 34 0 30 0;
#P connect 40 0 33 0;
#P connect 15 0 33 0;
#P connect 15 0 35 0;
#P connect 43 0 44 0;
#P connect 43 0 44 1;
#P connect 35 2 43 0;
#P connect 43 0 44 2;
#P connect 41 0 42 0;
#P connect 43 0 44 3;
#P connect 36 0 15 0;
#P hidden connect 28 0 15 0;
#P hidden connect 27 0 15 0;
#P hidden connect 17 0 15 0;
#P hidden connect 16 0 15 0;
#P connect 29 0 15 0;
#P fasten 19 0 15 0 829 609 802 609 802 105 829 105;
#P connect 42 0 15 0;
#P connect 31 0 15 0;
#P connect 32 0 4 0;
#P fasten 4 1 5 0 879 371 829 371;
#P connect 4 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 18 0;
#P fasten 0 0 26 0 966 511 829 511;
#P connect 26 0 25 0;
#P connect 25 0 19 0;
#P fasten 22 0 19 0 905 573 829 573;
#P fasten 23 0 19 0 988 573 829 573;
#P fasten 5 1 7 0 851 397 866 397;
#P connect 7 0 18 1;
#P fasten 18 0 25 1 829 511 869 511;
#P fasten 5 2 8 0 873 397 903 397;
#P connect 8 0 21 0;
#P connect 21 1 20 0;
#P connect 20 0 2 0;
#P connect 2 0 22 0;
#P fasten 24 0 22 0 966 544 905 544;
#P fasten 5 3 9 0 895 397 921 397;
#P connect 21 0 20 1;
#P fasten 5 4 10 0 917 397 939 397;
#P fasten 5 5 11 0 939 397 957 397;
#P fasten 0 0 24 0 966 514 966 514;
#P fasten 5 6 12 0 961 397 975 397;
#P fasten 24 1 23 0 1006 544 988 544;
#P fasten 5 7 13 0 983 397 993 397;
#P fasten 2 1 24 1 920 518 1006 518;
#P pop;
#P newobj 649 404 40 196617 p lcd;
#P toggle 459 501 15 0;
#P message 459 524 88 196617 poly_mode $1 $1;
#P toggle 757 130 15 0;
#P message 757 158 44 196617 fsaa $1;
#P toggle 698 130 15 0;
#P message 698 158 46 196617 sync $1;
#P hidden newex 386 471 75 196617 loadmess 0.25;
#P flonum 386 502 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 343 502 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 301 502 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 272 526 99 196617 pak scale 1. 1. 0.25;
#P newex 164 177 80 196617 t b l erase b;
#P newex 875 351 192 196617 jit.gl.texture render_grid @name mytex;
#P newex 164 579 423 196617 jit.gl.mesh render_grid @draw_mode tri_grid @texture mytex @color 1. 1. 1. 1.;
#P user jit.fpsgui 679 593 60 196617 0;
#N vpatcher 645 520 1121 872;
#P inlet 230 84 15 0;
#P toggle 352 214 15 0;
#P window setfont "Sans Serif" 9.;
#P message 352 233 75 196617 auto_rotate $1;
#P message 315 233 32 196617 reset;
#P newex 103 101 27 196617 t i i;
#P flonum 261 213 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 261 233 51 196617 radius $1;
#P flonum 194 213 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 194 233 60 196617 tracking $1;
#P newex 10 254 355 196617 jit.gl.handle render_grid @inherit_transform 1 @depth_enable 1 @tracking 8;
#P outlet 10 284 15 0;
#P newex 103 56 50 196617 select 27;
#P newex 103 34 40 196617 key;
#P newex 120 146 91 196617 prepend fullscreen;
#P newex 120 167 312 196617 jit.window render_grid @size 320 240 @depthbuffer 1 @floating 1;
#P comment 10 218 178 196617 inherit_transform is important here , since we are controlling jit.gl.render;
#P toggle 103 81 15 0;
#P fasten 14 0 7 0 357 251 15 251;
#P fasten 10 0 7 0 266 251 15 251;
#P fasten 8 0 7 0 199 248 15 248;
#P fasten 13 0 7 0 320 251 15 251;
#P connect 7 0 6 0;
#P connect 4 0 5 0;
#P connect 5 0 0 0;
#P connect 0 0 12 0;
#P connect 12 1 3 0;
#P connect 3 0 2 0;
#P connect 16 0 2 0;
#P connect 9 0 8 0;
#P connect 11 0 10 0;
#P connect 15 0 14 0;
#P pop;
#P newobj 698 185 115 196617 p window-mouse-rotate;
#P message 1176 271 111 196617 read bastille.png , bang;
#P newex 875 304 153 196617 jit.qt.movie 320 240 @unique 1;
#P newex 210 224 120 196617 jit.gl.render render_grid;
#P user panel 669 430 180 140;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont "Sans Serif" 18.;
#P comment 895 51 25 196626 1.;
#B color 6;
#P connect 9 0 44 0;
#P connect 46 0 45 0;
#P connect 45 0 9 0;
#P connect 9 0 54 0;
#P fasten 19 0 7 0 464 560 169 560;
#P fasten 10 0 7 0 277 554 169 554;
#P connect 54 0 7 0;
#P connect 47 0 45 1;
#P fasten 9 0 2 0 169 207 215 207;
#P fasten 5 0 2 0 703 207 215 207;
#P fasten 9 2 2 0 215 206 215 206;
#P fasten 53 0 54 1 536 459 220 459;
#P connect 54 1 7 1;
#P connect 11 0 10 1;
#P connect 12 0 10 2;
#P connect 13 0 10 3;
#P hidden connect 14 0 13 0;
#P connect 20 0 19 0;
#P connect 55 0 53 0;
#P fasten 21 0 53 1 654 426 557 426;
#P connect 66 0 65 0;
#P connect 65 0 53 2;
#P connect 23 0 21 0;
#P connect 39 0 21 0;
#P fasten 9 3 21 0 238 192 654 192 654 215 654 215;
#P hidden connect 50 0 1 0;
#P hidden connect 63 0 23 0;
#P fasten 22 1 21 1 834 567 1114 567 1114 390 684 390;
#P connect 21 1 22 0;
#P connect 22 0 6 0;
#P connect 16 0 15 0;
#P connect 17 0 5 0;
#P connect 15 0 5 0;
#P hidden connect 64 0 63 0;
#P hidden connect 63 1 40 0;
#P connect 40 0 39 0;
#P connect 35 0 18 0;
#P connect 18 0 17 0;
#P connect 3 0 48 0;
#P connect 3 0 59 0;
#P connect 41 0 3 0;
#P fasten 4 0 3 0 1181 295 880 295;
#P connect 34 0 3 0;
#P fasten 58 0 3 0 992 295 880 295;
#P connect 60 0 3 0;
#P connect 3 0 8 0;
#P connect 33 0 24 0;
#P connect 24 0 25 0;
#P connect 25 0 26 0;
#P connect 26 0 27 0;
#P connect 32 0 28 0;
#P connect 28 0 29 0;
#P connect 29 0 30 0;
#P connect 30 0 31 0;
#P connect 3 1 49 0;
#P connect 49 0 41 0;
#P window clipboard copycount 67;


August 27, 2006 | 10:00 pm

On Aug 27, 2006, at 1:35 AM, Ali Momeni wrote:

> i have one question, however; i’d like to make the displacements of
> my geometry’s vertices "smooth". i can accomplish that by blurring
> the matrix that defines the z-displacement. to get a nice cheap
> blur, i’d like to use the GPU bassed gaussian blur from the
> examples; however, in order to provide the blurred matrix to
> jit.gl.mesh, i need to copy it back to RAM from VRAM with
> jit.matrix which is an expensive step. is there any clever way to
> avoid that step?

Not currently. Technically there is a way to use Frame Buffer Objects
(FBOs) as Vertex Buffer Objects (VBOs), but this is not exposed in
Jitter at this time. You will have to copy back to RAM, use fewer
vertices, or figure out a different approach.

-Joshua


Viewing 2 posts - 1 through 2 (of 2 total)