Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glTexSubImage2D causing graphics driver to crash

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2

    glTexSubImage2D causing graphics driver to crash

    Hello guys,

    I am having some trouble building my game engine. Basically I want to change the content of a texture at every frame and render it on a quad. So, I decided to use glTexSubImage2D to reupload the content of my texture in every frame. It works great for 10 to 20 seconds but after that it causes graphics driver to crash (Windows shows an error saying graphics driver has crashed and recovered) and after that the monitor flickers and the game screen just freezes. My graphics card is ATI Radeon 6630M and I have installed latest driver through the 'Device Manager'.
    I am sure it is due to glTexSubImage2D because if I comment it out from my source, it doesn't cause the crash anymore.

    Here's how I am setting up the texture:

    Code :
    	glGenTextures(1, &texture);
    	glBindTexture(GL_TEXTURE_2D, texture);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    And here's how I am reuploading the texture at every frame:

    Code :
    	glActiveTexture(GL_TEXTURE0);
    	glBindTexture(GL_TEXTURE_2D, texture);
    	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frameWidth, frameHeight, GL_BGRA, GL_UNSIGNED_BYTE, frameBuffers[currentActiveBuffer]);

    If someone could help me fix the problem I would really appreciate it.

    Thanks!

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,188
    Is frameWidth <= 1024 && frameHeight <= 1024 and the last arg to glTexSubImage2D() always a non-null pointer which has at least the appropriate size (frameWidth * frameHeight * 4).

  3. #3
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    315
    If the GL_PACK_ALIGNMENT is greater than 4, it'll also cause a crash if the scanline size isn't divisible by the GL_PACK_ALIGNEMENT (int align=0; glGetIntegerv(GL_PACK_ALIGNMENT, &align); ). It should be 4 unless you've changed it.

  4. #4
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2
    Quote Originally Posted by Dark Photon View Post
    Is frameWidth <= 1024 && frameHeight <= 1024 and the last arg to glTexSubImage2D() always a non-null pointer which has at least the appropriate size (frameWidth * frameHeight * 4).
    Yes they are both less than 1024, and frameBuffers is a non-null pointer and has appropriate size.

    If the GL_PACK_ALIGNMENT is greater than 4, it'll also cause a crash if the scanline size isn't divisible by the GL_PACK_ALIGNEMENT (int align=0; glGetIntegerv(GL_PACK_ALIGNMENT, &align); ). It should be 4 unless you've changed it.
    GL_PACK_ALIGNMENT is returning 4.

    It seems the issue was buggy drivers. Even if I was updating it from Device Manager, it wasn't actually updating it to the latest version. I had to go deep into lenovo forums to find out that there was another latest update and after I installed the new drivers, the crashing stopped.

    Thanks for your replies guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •