ugluk
10-22-2010, 11:14 PM
See the code sample:
//////////////////////////////////////////////////////////////////////////////
inline void GLVBOHandlera::load_resource_into_vbo(
vboresourceid_type resource_id)
{
ResourceInfo& resource(resources[resource_id]);
BOOST_ASSERT(resource.orphan_id != orphan_id);
//std::cout << "loading: " << resource_id << std::endl;
resource.orphan_id = orphan_id;
resource.vbo_ptr = current_ptr;
/*
boost::uint8_t* buffer_ptr(boost::reinterpret_pointer_cast<boost::uint8_t>(
glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY)));
std::memcpy(buffer_ptr + std::size_t(current_ptr), resource.client_ptr,
resource.client_size);
glUnmapBufferARB(GL_ARRAY_BUFFER);
*/
glBufferSubData(GL_ARRAY_BUFFER,
GLintptr(current_ptr), resource.client_size, resource.client_ptr);
current_ptr += resource.client_size;
}
If I use glMapBuffer() everything works, but if I use glBufferSubData() , some batches I upload don't render. What could be the cause? No errors are reported by the GL. The traces also make sense. The bug occurs both on Windows and Linux. But I tested on 1 card/driver combo only.
Maybe the reason is my use of a caching VBO? Specifically, the batches are processed like this:
- load batch into VBO if not already there
- render batch
...
Maybe GL is freaked by me trying to update a VBO that something is already being rendered from?
EDIT:
If I add the following check after glBufferSubData():
boost::uint8_t const* buffer_ptr_(
boost::reinterpret_pointer_cast<boost::uint8_t>(glMapBufferARB(
GL_ARRAY_BUFFER, GL_READ_ONLY)));
BOOST_ASSERT(!std::memcmp(buffer_ptr_ + std::size_t(current_ptr),
resource.client_ptr, resource.client_size));
glUnmapBufferARB(GL_ARRAY_BUFFER);
It passes! But the batch still will not render.
//////////////////////////////////////////////////////////////////////////////
inline void GLVBOHandlera::load_resource_into_vbo(
vboresourceid_type resource_id)
{
ResourceInfo& resource(resources[resource_id]);
BOOST_ASSERT(resource.orphan_id != orphan_id);
//std::cout << "loading: " << resource_id << std::endl;
resource.orphan_id = orphan_id;
resource.vbo_ptr = current_ptr;
/*
boost::uint8_t* buffer_ptr(boost::reinterpret_pointer_cast<boost::uint8_t>(
glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY)));
std::memcpy(buffer_ptr + std::size_t(current_ptr), resource.client_ptr,
resource.client_size);
glUnmapBufferARB(GL_ARRAY_BUFFER);
*/
glBufferSubData(GL_ARRAY_BUFFER,
GLintptr(current_ptr), resource.client_size, resource.client_ptr);
current_ptr += resource.client_size;
}
If I use glMapBuffer() everything works, but if I use glBufferSubData() , some batches I upload don't render. What could be the cause? No errors are reported by the GL. The traces also make sense. The bug occurs both on Windows and Linux. But I tested on 1 card/driver combo only.
Maybe the reason is my use of a caching VBO? Specifically, the batches are processed like this:
- load batch into VBO if not already there
- render batch
...
Maybe GL is freaked by me trying to update a VBO that something is already being rendered from?
EDIT:
If I add the following check after glBufferSubData():
boost::uint8_t const* buffer_ptr_(
boost::reinterpret_pointer_cast<boost::uint8_t>(glMapBufferARB(
GL_ARRAY_BUFFER, GL_READ_ONLY)));
BOOST_ASSERT(!std::memcmp(buffer_ptr_ + std::size_t(current_ptr),
resource.client_ptr, resource.client_size));
glUnmapBufferARB(GL_ARRAY_BUFFER);
It passes! But the batch still will not render.