I have a weird problem with GL_NV_vertex_range. First, a description of what i’m trying to do: i do not have the fence extension, but i’m trying to optimize writes to the VA by using multiple buffers. So, in theory, i get a video or AGP memory buffer, i split it in MAX_BUF buffers, and in my loop i write to a buffer, call glDrawElements, then jump to the next buffer. I call glFlushVertexArrayRangeNV once i’ve used all the buffers, and loop back to the first buffer ( basically i simply want to achieve the same thing than in Nvidia’s VAR+Fence demo, for dynamic geometry, but without using the fence extension ).
So what is the problem ? My computer crashes. I allocate some space in video memory for my MAX_BUF buffers ( with a single call ), i setup the VA ( i only use the vertex and texture arrays ), then i fill my arrays as needed, calling glFlushVertexArrayRangeNV once i’m looping back to the first buffer. The heart of my loop looks like this:
if (cbuf==0) // comment me and it works
glVertexPointer(3,GL_FLOAT,3*sizeof(GLfloat),buf_verts[cbuf]); glTexCoordPointer(2,GL_FLOAT,2*sizeof(GLfloat),buf_texs[cbuf]); FillVA(buf_verts[cbuf],buf_texs[cbuf]); glTranslatef(x,0.0f,y); glDrawElements(GL_TRIANGLES,nb_elems,GL_UNSIGNED_INT,elems); glTranslatef(-x,0.0f,-y); cbuf=(cbuf+1)%MAX_BUF; } }
There is around 9000 elements and 3000 triangles for each call, but if i reduce it to 50 it still crashes. If i simply replace the priority in wglAllocateMemoryNV from 1.0 ( for video memory ) to 0.5 ( AGP memory ), everything runs fine, w/o changing any other line ( also runs if i use standard system memory ). If i disable texture mapping, it runs fine too ( ! ). Finally, if i call glFlushVertexArrayRangeNV every time i write a buffer ( instead of every MAX_BUF buffers ), it runs fine. I’ve tracked the crash to the glDrawElements call with the debugger, but all the arrays pointers seem to be fine: they are 4-bytes aligned ( btw, i tried with 8 and 16 bytes aligned pointers, doesn’t work either ).
Please… if anybody has an idea… i’ve ready all the specifications but i can’t find where the problem is ( btw, i’ve yet to see a demo using dynamic VARs without using fences… any links are welcome )… What would cause a crash in the driver ( the computer freezes, and i must reset )…?