Make changes to rendering pipeline on the fly problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Make changes to rendering pipeline on the fly problem

EvilMax
Hi!

I am implemented basic ray casting engine for 3D visualization purposes using JOGL (implemented using OpenGL 3.2+ requirements). Now I have a problem adding more functions there. These functions require to change parameters of the rendering pipeline. For example:

1. To change ray tracing algorithm I need to replace source code of some shaders and recompile them.
2. To change appearance of the volume I need to upload to GPU another LUT.

I have a problem with doing that 'on the fly'. Every attempt to change compiled shader or bind texture and then upload new texture data causes OpenGL error (error 1282 - invalid operation). It seems that any GL operation initiated from outside is causing mentioned error.
To avoid that I stopped completely rendering (unbound GlEventListener), change parameters and reinitilaize pipeline from scratch (bind listener again). It works, but this is EXTREMELY slow...   - all textures including 3D are being generated, uploaded to GPU, shaders compiled...

My suspicions are that these errors are caused because I try to change these during OpenGL render loop running (i.e. active listener). Or more likely maybe because I try to make modifications from Java application EDT or other application threads (events for changing blending mode, changing LUTs etc are coming from application GUI and other).

How to resolve this?  Is there possibilities to change texture data from outside without stopping completely rendering? Or just make 'pause', put everything needed to renderer from outside and then 'continue'?  Maybe JOGL has some kind of mechanisms that allow to make changes to rendering pipeline built in init(GLAutoDrawable drawable) method without completely destroying and rebuilding it?

Please help with this issue.
Reply | Threaded
Open this post in threaded view
|

Re: Make changes to rendering pipeline on the fly problem

gouessej
Administrator
Hi

Please try to use the invoke method.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Make changes to rendering pipeline on the fly problem

EvilMax
So, scenario is to save GLAutoDrawable in class, and when get/set method that requires to make changes to pipeline is called by external thread, create there runnable, and then put it into pipeline by invloke() method?
Reply | Threaded
Open this post in threaded view
|

Re: Make changes to rendering pipeline on the fly problem

gouessej
Administrator
You don't need to save the GLAutoDrawable as the GLRunnable you pass to GLAutoDrawable.invoke(boolean,GLRunnable) implements this method that passes the GLAutoDrawable :)
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Make changes to rendering pipeline on the fly problem

EvilMax
Issue is solved, all is just ok.  

I'll post example here, because it would help me if it'd be here. updateLut here is a method that makes changes to GPU data used in rendering.  canvas.invoke is being called from EDT.

canvas.invoke(false, new GLRunnable() {
			
			@Override
			public boolean run(GLAutoDrawable drawable) {
				GL3 gl = drawable.getGL().getGL3();
				updateLut(gl);
				return false;
			}
		} );