glGetTexImage crashes, and I don't know why

Started by
5 comments, last by Trumgottist 13 years, 3 months ago
Hi!

My game engine is crashing (silently exiting) on one user's computer (Win XP with a Radeon X1600 with the latest drivers), but it's working fine everywhere else (both on Mac, Windows and Linux). I've been unable to reproduce it, so debugging consists of sending that user executables that print information to a log file.

Through fprintf-debugging, I've been able to find that the crash happens on this line:
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, newFreezer -> backdropTexture);


But I don't know why this is happening or what to do about it. I have checked that the texture is the size I expect (with glGetTexLevelParameteriv), I've set GL_PACK_ALIGNMENT to 1, I've checked the pointer after allocating the memory (newFreezer->backdropTexture = new GLubyte [w*h*4]). I have also checked glGetError before the call that crashes, and it's clean.

Does anyone have any ideas? I've tried everything I can think of.

(In case you're interested, the game where the crash was found in is Life Flashes By. The crash happens when clicking "New Game" from the main menu.)
Advertisement
You seem to be doing and checking everything, and from all I can tell, it should just work.

What I'd try is add a glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); just to be 101% sure that no buffer is bound (which would transform your pointer into an offset and cause an crash).
And, I would try to allocate a little more memory (rounding the width up to the nearest 4) in case there is a driver bug so that GL_PACK_ALIGNMENT isn't properly respected. Or, try and just allocate a buffer twice as much as you need. If this "magically" removes the crash, you'll know.
Why do you need glGetTexImage? Aren't your textures on the harddrive?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Hm... this seems strange, has he tried some different drivers? (maybe older ones) - because it might be driver bug (but I dont think so).

It can also be hidden in that pointer you're addressing .. but then it wouldn't work on more GPUs, not just particulary this one. I can test it on some Radeons if you havent (HD2900, HD6800 or Mobility HD5470) if it works (both linux and windows), if it works on AMD gpus, if you wish (if you have demo or such somewhere).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

Quote:Original post by samoth
What I'd try is add a glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); just to be 101% sure that no buffer is bound (which would transform your pointer into an offset and cause an crash).

Thanks, I'll try that.

Quote:And, I would try to allocate a little more memory (rounding the width up to the nearest 4) in case there is a driver bug so that GL_PACK_ALIGNMENT isn't properly respected. Or, try and just allocate a buffer twice as much as you need. If this "magically" removes the crash, you'll know.

I've tried that with a buffer four times the needed size. Did nothing.

Quote:Original post by V-man
Why do you need glGetTexImage? Aren't your textures on the harddrive?

It's a scene that's rendered for later use as a texture. (In this case to be used for a transition between scenes.)

Quote:Original post by Vilem Otte
Hm... this seems strange, has he tried some different drivers? (maybe older ones) - because it might be driver bug (but I dont think so).
He had an older driver first, and upgraded on my suggestion.

Quote:It can also be hidden in that pointer you're addressing .. but then it wouldn't work on more GPUs, not just particulary this one. I can test it on some Radeons if you havent (HD2900, HD6800 or Mobility HD5470) if it works (both linux and windows), if it works on AMD gpus, if you wish (if you have demo or such somewhere).

My Windows computer has a HD4550 on Vista, so I know it's at least not a problem with all ATI cards, but if you don't mind testing it, that'd be great. If file size is not an issue, the link to the full game Life Flashes By is in my first post. It's worth checking out anyway IMHO. (This game is not by me - I'm only responsible for the engine.) Or I could put together a smaller test.
Huh... strange, on all Radeons I have it seems working good (HD2900, HD6800 and HD5470). I even don't have same updated versions of drivers everywhere ... on linux too (through WinE).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

Quote:Original post by Trumgottist
It's a scene that's rendered for later use as a texture. (In this case to be used for a transition between scenes.)


In that case, bind the FBO and use glReadPixels.

Yes, since it sounds like a driver bug, ask your user to try some other driver.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Re-writing the code to render the texture and then use readPixels worked. Thanks!

This topic is closed to new replies.

Advertisement