Hi !
I’m messing around with this for quite some time… I’m working on a terrain engine that uses CVAs. I switched from using normals to specifing vertex colors and do my own lighting. I read in the nVidia OpenGL Performance FAQ that this special vertex/color/texcoord combination is optimized on the GeForce. That’s right, it’s really much faster when you meet those special conditions…
Everything worked fine on my GeForce1. But then I noticed that the demos crashes on my GeForce2, it simply hangs inside the driver code. I found out that I can avoid this by a.) not locking the arrays or b.) using another vertex format. Strange, eh ? The only method that produces this crash is the only method that nVidia suggestes as fast !?!
After some time of playing around I found out that the crashes go away when I lock / unlock the arrays every frame. At least I thought this fixes the problem. But then I tried another landscape and the crashes appeared again…
I played a bit around and changed my code to lock the arrays, here is how it looks now:
void CVertexArray::Lock()
{
////////////////////////////////////////////////////////////////////////
// Lock the whole vertex array. This allows the driver to place the
// buffer in AGP memory and perform optimisations ond shared vertices
////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
assert(m_pfnglLockArraysEXT);
assert(m_iArraySize > 0);
if (!m_pfnglLockArraysEXT | | m_iArraySize < 1)
return;
#endif
// I'm a bit unsure about this parameters. The function seem to expect a
// one based start index, and the vertex count seems to be m_iArraySize
// minus one. The expected 0 / m_iArraySize combination works fine on
// GeForce DDR cards, but crashes on GeForce 2 cards. Maybe a driver bug,
// maybe it's just right ?
(* m_pfnglLockArraysEXT) (1, m_iArraySize - 1);
m_bLocked = true;
}
Looks strange, doesn’t it ? But it seems to work ob both GeForce. I read the specification and couldn’t any infos on zero based or not zero based indices and so on…
Is this the right way to do it ? Has anyone experienced the same problem ? The code above seems to work, but I want to be sure that I have a reliable solution, you know this “bad” feeling
If you need some more code or vertex array related infomations about my engine, let me know ! I’m using the 6.34 drivers, but it also happend on other driver releases and on other systems than my both W2k ones… Always worked on GF1, never on GF2
Please share your ideas / experinces…
Tim