GPGPU - an effective ping pong technique?

I am trying to implement an efficient fluid solver on a GPU using WebGL and GLSL shader programming.

I found an interesting article: http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html

See: 38.3.2 Overlapping operations

I wonder if such a technique is possible to ensure boundary conditions using ping-pong rendering? If I draw only lines, what about the inside of the texture? I always assumed that the entire input texture should be copied into a temporary texture (the border of the border is updated during this process), because after this operation they are swapped.

This is interesting, especially considering the fact that Example 38-5. The fragmentary boundary condition program (visualization: http://i.stack.imgur.com/M4Hih.jpg ) shows a scheme in which IMHO requires ping-pong technique.

What do you think? Do I not understand something?

As a rule, I found that recording a texture is extremely expensive, and therefore I would like to somehow limit it. Unfortunately, the ping-pong technique provides a lot of facts.

+4
source share
1 answer

I really implemented the technique described in this chapter using FrameBuffer Objects as a method of rendering texture (but in desktop OpenGL, since WebGL didn not exist at that time), so this is definitely possible. Unfortunately, I no longer believe that I have the code, but if you check any future questions that you have with [webgl], I will see if I can provide some help.

You will need ping-pong several times per frame (five steps are mentioned in the article, but it seems that I remember that the exact number depends on the quality of the simulation you want and on your exact boundary conditions). Using FBOs is quite a bit more efficient than it was when it was written (the author mentions the use of the GeForce FX 5950, which was recently), so I would not worry about the overhead that he mentions in the article. Until you return the data back to the CPU, you should not find the cost of switching between texture and framebuffer too high.

You will have some leakage if your borders are only pixel thick, but this may or may not be acceptable depending on how you do your results and the speed of your fluid. Deepening the boundaries can help, and there are documents that have been written since they explored various ways to limit fluid within the boundaries (I also recall several more effective diffusion / pressure solutions that you can check after the version works ... you will find interesting interesting results if you are looking for documents that provide an article on GPU gems for google Scientist ).

Addendum: I am not sure I fully understand your question about boundaries. The key is that you have to start the shader in every pixel of what you want to be a border, but it really doesn't matter how that pixel gets there, whether it is drawn by lines, dots or triangles (if it the inputs are correct).

In the most general case (which may not apply if you have only a limited number of boundary primitives), you probably have to draw a quadrant covering the framebuffer, since interactions with the velocity and pressure fields are more complex (any surrounding pixel can be a different border pixel , instead of having only certain edges). See Section 38.5.4 (Arbitrary Boundaries) for some explanation of how to do this. If something is not a border, you will not touch the vector field, and if so, instead of hard coding, what directions do you want to look to sum vector values, you will probably finish testing the surrounding pixels and only sum those that don’t are boundaries, so you can enforce boundary conditions.

+1
source

All Articles