winterhell's picture

GL.Enable((EnableCap)All.VertexAttribArrayUnifiedNv) and bindless graphics does not seem to work

I'm experiencing some CPU bottlenecks in my game(200 different vertex buffers, 4000 draw calls per scene, will be more in the future), so I decided to switch from VBO to bindless arrays.
I've been reading on the topic the past 2 days and I have a lot of questions as to why and how it does not work.
I'm running on Core i5 2500K Desktop, GeForce GTX 660 Ti. Drivers are from this year. Windows 7 64bit running on .Net 4.0 with a March 2012 OpenTK release.

First, when I try to Enable VertexAttribArrayUnifiedNv and check with GL.IsEnabled it returns false. I suppose this is the main culprit behind my problems.

This is how I make the buffer (only the positions for simplicity, will add the rest once this works)

  GL.GenBuffers(1, out positionVboHandle);
                GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
                GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, new IntPtr(verticesOGL.Length * Vector3.SizeInBytes), verticesOGL, BufferUsageHint.StaticDraw);
                GL.NV.GetBufferParameter((NvShaderBufferLoad)BufferTarget.ArrayBuffer, NvShaderBufferLoad.BufferGpuAddressNv, out bindlessPosition); 
                GL.NV.MakeBufferResident((NvShaderBufferLoad)BufferTarget.ArrayBuffer, (NvShaderBufferLoad)All.ReadOnly);

and then I'm trying to render with

 GL.NV.BufferAddressRange(NvVertexBufferUnifiedMemory.VertexArrayAddressNv/*VertexAttribArrayAddressNv*/, 0, pModel.bindlessPosition, new IntPtr(pModel.verticesOGL.Length * Vector3.SizeInBytes));
                                GL.BindAttribLocation(testShader.program, 0, "vertex_position");
                                GL.DrawArrays(BeginMode.Triangles, 0, pModel.verticesOGL.Length);

If I switch to BeginMode.Points I sometimes get in the shader (0,0,0) for the vertex input.
If I try to GL.EnableVertexAttribArray(0);
the program crashes on the GL.DrawArrays(..)
Maybe I'm not linking the attributes properly? I saw somewhere they use VertexFormatNV() but in OpenTK the parameters are different and I don't know what to put there.

Also I checked the 64-bit pointer GetBufferParameter throws and at first glance it seems legit. Each consecutive vertex array was places in the vicinity, though each pointer has lower values than the previous one.

I really hope someone can help me with this, or at least point me in the right direction as to where to work if the problem is from the wrapper itself.