PBO/glTexSubImage2D: partial update broken

Hi,

I’m currently trying to use pixel buffer objects to accelerate texture updates. The code looks as follows:

glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, mPBO);
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, size, imageBuffer, GL_STREAM_DRAW);

glTexSubImage2D(
	GL_TEXTURE_2D, 0, 
	regionPos[0], regionPos[1], 
	regionSize[0], regionSize[1], 
	mFormat,
	mType,
	0);

glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
  

This works fine as long as regionPos/regionSize cover the whole texture. If it’s only a partial update, the texture content is mixed up afterwards (I still have to investigate on this). If I just pass the buffer to glTexSubImage2D, partial updates work fine. Is there some kind of limitation for PBOs and partial texture updates?

I’m using a NVidia Geforce 7900GT, Windows XP x64, 97.92 drivers.

Best regards,
Malte

I’ve just tested this with my code, and it works fine here. Keep in mind that it will read the data from the PBO as one contiguous array of elements, that is the indexing into the PBO changes. That is

  glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
  pboMem = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);

  int i = 0;
  for (int y = regionPos[1]; y < regionSize[1]; y++) {
    for (int x = regionPos[0]; x < regionSize[0]; x++) {
      pboMem[i++] = whatever; // assuming pboMem is a pointer to the appropriate element type, ie 32bit int in case of RGBA texture
    }
  }
  glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);

  // Update (sub-)teximage from texture image buffer
  glTexSubImage2D(
	GL_TEXTURE_2D, 0, 
	regionPos[0], regionPos[1], 
	regionSize[0], regionSize[1], 
	mFormat,
	mType,
	0);

Mind you I don’t code in C/C++, and this is my attempt at adapting my code.

Hi,

I also had weird problems with PBO for textures
on NVIDIA cards with 9x.x drivers.
Downgrade to 8x.xx and try again.

I must admit I’m a n00b when it comes to PBO’s, but the code I tried to adapt works like a charm so far on my 7800GT with 93.71 drivers.