Hi Ted,
That’s my demo… sorry about this bug! Unfortunately there was a bug in the old version of gpgpu_fluid and we haven’t put it into SDK10 for OpenGL yet (I’ve been too busy with CUDA!).
I will try to get a new version out soon. In the meantime, here are some changes you can make that I think should fix it.
In the file “flo.cpp”, in the Flo::Initialize() function, replace this:
_pScalarBuffer = new PBuffer("r float=32f depth=24");
With this:
if (glutExtensionSupported("GL_NV_gpu_program4"))
_pScalarBuffer = new PBuffer("r float=16f depth=24");
else
_pScalarBuffer = new PBuffer("r float=32f depth=24");
In “streamopGL.h”, in the BoundaryGLComputePolicy::Compute() function:
Change this:
// left boundary
if (_bLeft)
{
glMultiTexCoord2f(GL_TEXTURE1,
_bLeftPeriodic ? _iTexResS - 2 * _rTexelWidth :
_rTexelWidth, 0); // offset amount
glTexCoord2f(_rMinS, _rMinT); glVertex3f(_rMinX, _rMinY, _rZ);
glTexCoord2f(_rMinS, _rMaxT); glVertex3f(_rMinX, _rMaxY, _rZ);
}
// right boundary
if (_bRight)
{
glMultiTexCoord2f(GL_TEXTURE1,
_bRightPeriodic ? -_iTexResS + 2 * _rTexelWidth :
-_rTexelWidth, 0); // offset amount
glTexCoord2f(_rMaxS - _rTexelWidth, _rMinT);
glVertex3f(_rMaxX - _rPixelWidth, _rMinY, _rZ);
glTexCoord2f(_rMaxS - _rTexelWidth, _rMaxT);
glVertex3f(_rMaxX - _rPixelWidth, _rMaxY, _rZ);
}
To this:
// left boundary
if (_bLeft)
{
glMultiTexCoord2f(GL_TEXTURE1,
_bLeftPeriodic ? _iTexResS - 2 * _rTexelWidth :
_rTexelWidth, 0); // offset amount
glTexCoord2f(_rMinS, _rMinT); glVertex3f(_rMinX + 0.5f * _rPixelWidth, _rMinY, _rZ);
glTexCoord2f(_rMinS, _rMaxT); glVertex3f(_rMinX + 0.5f * _rPixelWidth, _rMaxY, _rZ);
}
// right boundary
if (_bRight)
{
glMultiTexCoord2f(GL_TEXTURE1,
_bRightPeriodic ? -_iTexResS + 2 * _rTexelWidth :
-_rTexelWidth, 0); // offset amount
glTexCoord2f(_rMaxS - _rTexelWidth, _rMinT);
glVertex3f(_rMaxX - 0.5f * _rPixelWidth, _rMinY, _rZ);
glTexCoord2f(_rMaxS - _rTexelWidth, _rMaxT);
glVertex3f(_rMaxX - 0.5f * _rPixelWidth, _rMaxY, _rZ);
}
The latter change was a bug that never manifested on earlier GPUs. It manifests on G80 because the rasterization rules changed slightly. The boundaries were drawn on pixel edges, rather than pixel centers, so they “fell off the knife edge” on G80.
Please try out these changes and let me know if it works (and what performance you get!).
The CUDA fluid sample uses the FFT to transform in to frequency space to solve the poisson equation directly, rather than iteratively. The downside is it can’t handle arbitrary interior boundaries or non-periodic exterior boundary conditions.
Mark