Title: Best way to split GLSL into tiles? Post by: Softology on November 21, 2012, 01:11:59 AM I had a peek at the Fragmentarium source code, but couldn't find the relevant part.
What is the best way to render a shader as multiple smaller sub-tiles (to avoid the default 2 second video driver timeouts)? At the moment I am using loops and glviewport, like... Code: for yloop:=0 to ytiles-1 do Which does work, but seems to really slow down the rendering. I think this is due to the glfinish having to wait for the GPU to finish all its work before continuing with the next tile, but if I don't include that then the video card will timeout. Any ideas for improving the above method without the slowdown? How does Fragmentarium handle the issue? Thanks, Jason. Title: Re: Best way to split GLSL into tiles? Post by: eiffie on November 21, 2012, 06:07:01 PM Are you sure it is not something you do in processMessages like a screen refresh? That would slow things down.
Title: Re: Best way to split GLSL into tiles? Post by: Softology on November 22, 2012, 04:15:10 AM Commenting processmessages didn't make a difference. I only include it so the app doesn't get the dreaded Windows "not responding" title bar during intensive shaders.
Finding that I was using way more tiles than necessary (as in each subtile was around 10x10 pixels in size) helped get the speed back up. The above method/code still leads to a slight delay compared to a single full screen qaud. As an example if a single quad gives 1 fps then splitting the screen into 9 sub quads gives 0.5 fps. It isn't a huge deal. As long as I can avoid the GPU timeouts it is acceptible for the time being. But if there is a smarter way to divide the screen up I am ready to be educated. Thanks, Jason. Title: Re: Best way to split GLSL into tiles? Post by: Syntopia on November 22, 2012, 07:12:59 AM I don't use tile rendering to prevent time-outs - tile rendering is only used to create high-resolution images, and I always render whole fullscreen quads.
I think the best way to split up the rendering is to use progressive/accumulated rendering. Simple render to a offscreen buffer (a Frame Buffer Object), and when writing to the buffer, add the previous result. Then, when drawing the buffer to the screen, divide by the number of samples (this must be done in a custom shader). This way you can do progressive anti-aliasing or Monto-carlo raytracing (soft shadows, DOF, ...). Fragmentarium use a slightly more complex buffer setup, with two offscreen buffers, flipped at each frame, so that you can sample from neighbor points (this makes reaction-diffusion and game-of-life systems possible). I also use float buffers (32-bit for each channel), to avoid quantization errors, and allow for HDR rendering. In Fragmentarium I use the alpha-channel to keep track of how many samples have been used - this also allows me to do weighted sampling, since I can use the alpha-channel for the sum of the weights. Title: Re: Best way to split GLSL into tiles? Post by: Softology on November 28, 2012, 05:28:22 AM Thanks Mikael. I only started down the tile based approach after I was using older GPUs for testing that kept timing out with more complex shaders. Your other tips will come in handy when I eventually get the hang of shaders and GLSL to a more competant level. Jason. |