PDA

View Full Version : glTexSubImage2D causing graphics driver to crash



PradsN
05-05-2013, 05:47 AM
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:



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:



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!

Dark Photon
05-05-2013, 11:08 AM
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).

malexander
05-05-2013, 02:12 PM
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.

PradsN
05-05-2013, 04:26 PM
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.