ATi, Accessing texture level below TEXTURE_BASE

Hi,
using Ati Mobility Radeon HD 5650 with Catalyst 11.8 drivers, I noticed that this causes an AV at the glTexImage2D call:

  glGenBuffers(1, @PBO);
  glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PBO);
  glBufferData(GL_PIXEL_UNPACK_BUFFER, twidth*theight*4, @data, GL_STATIC_DRAW);

  glGenTextures(1, @tex);
  glBindTexture(GL_TEXTURE_2D, tex);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, twidth, theight, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);

It’s unusual calling glTexImage for a level beneath GL_TEXTURE_BASE_LEVEL, but AFAICT shouldn’t cause an AV.

Something else that causes an AV when it comes to render using a texture, is having GL_TEXTURE_MAX_LEVEL < GL_TEXTURE_BASE_LEVEL, eg.

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);

This is one of the listed checks of texture completeness, so should handle it cleanly rather than causing an AV.

What is an AV?

Sorry, AV = Access Violation.

Is it caused by glBufferData? I removed PBO stuff and found no AV in the glTexImage.See if upgrading to 11.9 works.

The access violation “Access violation at 03E7C870 in module ‘atioglxx.dll’. Read of address 00000000” occurs at the glTexImage2D call, but only when a buffer object is bound to GL_PIXEL_UNPACK_BUFFER.
eg. This doesn’t throw an AV:


glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glGenTextures(1, @tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, twidth, theight, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);

and uploading to a level >= GL_TEXTURE_BASE_LEVEL works fine, but this throws an AV:



  glGenBuffers(1, @PBO);
  glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PBO);
  glBufferData(GL_PIXEL_UNPACK_BUFFER, twidth*theight*4, nil, GL_STATIC_DRAW); // nil = NULL equivalent

  glGenTextures(1, @tex);
  glBindTexture(GL_TEXTURE_2D, tex);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4);
  // AV when (0 <= level < GL_TEXTURE_BASE_LEVEL)
  glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, twidth, theight, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);

The 2nd issue appears to be fixed, since:


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);

no longer causes an AV on draw calls in 11.9, but correctly detects an incomplete texture + renders a white triangle.

Another issue with glTexImage2D when a PBO is bound is that if you try loading a high image level, you get an out of memory error (or potentially a very big texture allocated), which you don’t get if no PBO is bound.


  glGenBuffers(1, @PBO);
  glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PBO);
  glBufferData(GL_PIXEL_UNPACK_BUFFER, twidth*theight*4, nil, GL_STATIC_DRAW);
  // adding this line prevents out of memory error
  // glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

  glGenTextures(1, @tex);
  glBindTexture(GL_TEXTURE_2D, tex);
  //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 9);
  //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10);
  glTexImage2D(GL_TEXTURE_2D, 10, GL_RGBA, 32, 32, 0, GL_BGRA, GL_UNSIGNED_BYTE, nil);
  CheckOpenGLError(); // out of memory

Got it. I reproduced your bug in my machine. It is indeed a driver bug: some NULL pointer is referred when PBO and texture are used at the same time. Thanks for pointing it out. We’ll fix it in the next version of catalyst driver.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.