al_set_target_bitmap on windows performace
archlinka

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

archlinka,

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

Frank Drebin

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

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

Wow the speed increase is great !

How can I try ?

Thread #618088. Printed from Allegro.cc