Hi. I am using Allegro 188.8.131.52 (I think, not sure how to check) from the Nuget packages. I'm not set up with a dev build of Allegro yet, so I can't be too specific about the cause of this problem yet. I figured I'd start a thread and see if anyone had any ideas first.
I am trying to track down some performance issues. I'm running in windowed mode (not full-screen windowed) under Windows 10. I have an "overlay" bitmap that I regenerate every frame and then render on top of everything else.
My performance issue was tracked down to some code that reads:
ALLEGRO_BITMAP *former_bitmap = al_get_target_bitmap();
al_set_target_bitmap( mSurface ); //****** THIS IS CRAZY SLOW ******
al_clear_to_color( al_map_rgba( 0, 0, 0, 0 ) );
al_set_target_bitmap( former_bitmap );
The only line that is running slowly is that first al_set_target_bitmap call. Some initial Googling suggested that I should create mSurface with ALLEGRO_NO_PRESERVE_TEXTURE (https://www.allegro.cc/forums/thread/616223), but it doesn't make any noticeable difference to the performance. I did call al_get_bitmap_flags after creating it to verify that ALLEGRO_NO_PRESERVE_TEXTURE was set--it was.
I stuck a high-resolution timer in there, and it is showing that this single line of code takes about 0.004 seconds in debug mode (MSVC), and about 0.0146 seconds in release mode. You are reading that correctly: debug mode is much faster than release mode . I get the same behavior on both 32- and 64-bit builds, so it's not that either.
Can anyone suggest what I should try next?
EDIT: The problem goes away if I remove ALLEGRO_OPENGL from my initial call to al_set_new_display_flags (previously: ALLEGRO_OPENGL | ALLEGRO_RESIZABLE | ALLEGRO_WINDOWED; much faster when using: ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE). This seems to be an OpenGL-only issue.