|
al_set_target_bitmap() slows down game |
Yodhe23
Member #8,726
June 2007
|
Hi, al_set_target_bitmap (zbuffer_bmp) (where zbuffer is a bitmap the same size as the display) ..it slows the game down massively and I am at a loss what it might be (I have already done the "obvious" checking for memory bitmaps, and whether vsync is on etc) If I comment out the al_set_target_bitmap the game doesn't slow down. Can any help or have any suggestions, thanks. www.justanotherturn.com |
David Couzelis
Member #10,079
August 2008
|
I'm curious why it's causing the game to slow down but... Do you even need either of those function calls? I don't think you do, since Allegro automacally sets the target bitmap and target backbuffer when you create a display. Is there a problem you are trying to resolve by adding those functions? |
Yodhe23
Member #8,726
June 2007
|
I was merely reducing my code to the barest minimum to determine what caused the slowing, and whittled it down to those two lines, and in particular the first one. Normally I "flush" the zbuffer with al_clear_to_color, before returning to the backbuffer. Then a little later on in the function, when I draw the players cards, I also draw on the zbuffer, so I can later do a (locked bitmap) al_get_pixel_color on the zbuffer to see if the cards/hand are clicked/touched. (I am using 5.2 and the windows binaries for the record.) www.justanotherturn.com |
David Couzelis
Member #10,079
August 2008
|
Can you please post more of the code that contains those two function calls? I think it's important to see any loops that are happening and where / how things are created / destroyed. |
Elias
Member #358
May 2000
|
Try setting the ALLEGRO_NO_PRESERVE_TEXTURE flag. -- |
Yodhe23
Member #8,726
June 2007
|
Thanks the ALLEGRO_NO_RESERVE_TEXTURE did the trick, though I would like to know why it works for future reference, and would really appreciate if you can illuminate me or point me in the right direction/documentation. www.justanotherturn.com |
Erin Maus
Member #7,537
July 2006
|
Without that flag, Allegro automatically stores a copy of the texture in system RAM. If the graphics device is reset by some means (seems to be a thing on mobile platforms I believe, but also relevant for the older version of DirectX), texture data may be lost. In such a case, Allegro would use the copy to generate the texture, so the graphics device reset is handled silently. However, for a texture that is modified every frame, this is useless and instead incurs a performance penalty, as you witnessed. (I think that's the gist of it.) --- |
Mark Oates
Member #1,146
March 2001
|
Aaron Bolyard said: Without that flag, Allegro automatically stores a copy of the texture in system RAM. If the graphics device is reset by some means (seems to be a thing on mobile platforms I believe, but also relevant for the older version of DirectX), texture data may be lost. In such a case, Allegro would use the copy to generate the texture, so the graphics device reset is handled silently. Is this feature automatically enabled on all systems? -- |
Audric
Member #907
January 2001
|
DirectX 9.0c (the last before DirectX10, and the last normally supported on Windows XP) loses textures when alt-tabbing from fullscreen. |
Elias
Member #358
May 2000
|
I think ALLEGRO_NO_PRESERVE_TEXTURE should be removed from Allegro (and should then be the new default, i.e. Allegro will never download textures behind your back) - it just completely breaks all programs using dynamic bitmaps. And then do something similar to iOS and Android where you can restore textures if/when needed. -- |
Kris Asick
Member #1,424
July 2001
|
I just force OpenGL usage so that texture preservation becomes a non-issue. The average person won't even notice nor care, plus given Microsoft's practices with legacy DirectX support, I think this is a better approach in the long run for keeping my games working their best through newer and newer versions of Windows. --- Kris Asick (Gemini) |
Edgar Reynaldo
Major Reynaldo
May 2007
|
This is really kind of a non-issue if you just use ALLEGRO_FULLSCREEN_WINDOW. :/ My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Elias
Member #358
May 2000
|
Is this really an issue with fullscreen only? Right now the DirectX port always has it on by default, even in windowed mode... if it's save to disable we probably should. -- |
Yodhe23
Member #8,726
June 2007
|
Thanks for enlightening me. www.justanotherturn.com |
Kris Asick
Member #1,424
July 2001
|
I feel I should clarify what I said: Forcing OpenGL you STILL need to disable Allegro's texture preservation with the appropriate flag, it's just with OpenGL rendering and full-screen stuff, when you alt-tab out and alt-tab back in, your textures should still be there, regardless of how this is set. --- Kris Asick (Gemini) |
RPG Hacker
Member #12,492
January 2011
|
I think internally, OpenGL just handles everything automatically, so even if textures are destroyed by switching, OpenGL restores them itfself. Would be quite useful if D3D also did that.
|
|