FBO, NV_fragment_program2 help.


We are writing a particle simulation on the GPU. But we are facing a very tricky problem. Here is the summary of the problem.

Input textures

We initialize 4 textures each of size 128x128. Each pixel stores information worth 128 bits, thus storing 4 floats. The first 3 input textures are MassAddressTexture, PositionRcritTexture and ParticlePositionPhiTexture. The 4th texture is the one onto which I am rendering, thus used for writing 4 floats.

How to read results

The simulation run yields 4 float values. In the current setting, We have set the first 3 values to be zero. The fourth float value needs to be read to know proper results. We readback all these 4 float values and store them in the Buffer.txt.


We initially set my FBO size as 128x128 and the number of particles for simulation as 425. We render a quad of size 128x128 onto one of the FBO (used for writing). When we run the simulation, we will find that all the 4 float values are zero. However, when we increase the FBO size to 256x256, we get
correct values. We are rendering a quad of size 128x128 and thus we should be able to simulate 16384 particles. We can’t really locate why we get black values for this FBO size. We start recieving these black values starting with number of particles = 350. Upto number of particles = 349, we get all correct results.

Also instead of getting the results, we just capture the Particle positions after running through the shader that we store in one of the input textures. And we find that for particles for whom we were getting black values, have their particle positions as black and thus they should have black values as results. But, why are we having black values being stored in the Particle positions input texture. We checked if we store them properly in the 2d array on the CPU and they are all fine. So the values become black on the way to the GPU. But when I capture the Particle positions before running the shader on them, I capture all correct particle positions. I am pretty sure that I am not corrupting the values within the shader. Has anyone seen this before? This appears to be the root cause of all the issues.

We really seek help. Please help.