View Full Version : VBO not getting data

06-27-2011, 09:16 AM

I recently added VBO support to a project and I am having some issues with different NVIDIA cards. The issue that I am having is it seems on certain cards, some objects are not even making it into the buffer.

I'm loading the data from a custom OBJ into a few lists depending on certain properties of the objects. This code all works and everything displays fine on every compatible machine. One of my lists contains a large amount of static geometry that I am attempting to put into a VBO. My process is as follows.

Setting up the buffer

void vbo_manager::init(range_t range)
unsigned int size = 0;
unsigned int offset = 0;

//determine total size of buffer
for( prim_t::iterator pit = range.first; pit != range.second; ++pit)
size += pit->getVertexCount();

//set up buffer area
glBufferData(GL_ARRAY_BUFFER,sizeof(vertex)*size,N ULL,GL_STATIC_DRAW);

size = 0;
//copy data to buffer
for( prim_t::iterator pit = range.first; pit != range.second; ++pit)
size = pit->getVertexCount*sizeof(vertex);
glBufferSubData(GL_ARRAY_BUFFER,offset,size,(void* )pit->getAddressOfData() );
offset += size;


On certain machines, portions of the VBO don't get mapped. This seems to occur whenever the size parameter of the glBufferSubData() increases beyond a certain amount or the offset and size interact in some strange way. If I try and retrieve the data with glGetBufferSubData() at a location that is having trouble I receive all 0's.

The trouble has shown up on three different machines running in Windows with Nvidia cards: a notebook with 9800M GTS, a desktop with 275gtx, and a desktop with 460gtx, all with up to date drivers (275.xx). On another desktop with a 280gtx and on any of the machines in Linux, the problem does not exist.

I can get the triangles to reappear if I split larger objects into multiple glBufferSubData calls with smaller size parameters, or switch to using glMapbuffer. Is there some hard limit on glBufferSubData that I can not find in documentation or is there something more sinister happening?