Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_set_target_bitmap on windows performace

This thread is locked; no one can reply to it. rss feed Print
al_set_target_bitmap on windows performace
archlinka
Member #17,215
December 2019

Hi, I have a problem with perfomance on windows using Allegro.

My rendering loop is pretty simple:
1) Setup "buffer" texture as render target using al_set_target_bitmap.
2) Draw all stuff.
3) Setup display as render target.
4) Render "buffer" texture scaled by actual zoom to the display.

For maximal zoom of factor 2, the buffer texture has size (resolution * 2). All textures are video bitmaps.

On my linux system it works like a charm, I am able to achieve more than 1300 FPS in release build with hundrets of objects each frame (all from single texture in texture atlas).

But on the same machine on windows it drops to 30 FPS. Quite diference. I was able to simplify the problem code to simple setup of buffer texture. Even if I simply remove all drawing from the rendering loop and keep this simple code, it is still slow down to 100 FPS:

main_texture_->set_as_render_target();
al_set_target_bitmap(al_get_backbuffer(al_get_current_display()));

If I comment these two lines I have more than 2400 FPS.

Do you have any idea where the problem could be? Thank you very much for your answers.

EDIT:
I found a solution. The key is to create these "buffer" textures with ALLEGRO_NO_PRESERVE_TEXTURE flag enabled. And because it is only "buffer" texture is perfectly safe to not worry about losing it's content.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

archlinka,

Awesome that you found a solution. Thanks for sharing. How many fps did you get with NO_PRESERVE_TEXTURE enabled?

Frank Drebin
Member #2,987
December 2002
avatar

I found the same increase in FPS when creating the buffer with the flag ALLEGRO_NO_PRESERVE_TEXTURE is enabled:

{"name":"612405","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/7\/e7a4fd05a8d04faf1b1320a0911833f2.png","w":1301,"h":513,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/7\/e7a4fd05a8d04faf1b1320a0911833f2"}612405

archlinka
Member #17,215
December 2019

It seems that the slowdown increases with size of the buffer texture. So in my case where the size was 5120x2160, the difference was huge. Without the flag I got 30 FPS, with the flag a get over 1400 FPS :)

GullRaDriel
Member #3,861
September 2003
avatar

Wow the speed increase is great !

How can I try ?

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Go to: