Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Quick Question about MSAA

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Quick Question about MSAA
codetricity
Member #17,059
March 2019

It's crashing when I run it with -msaa in fullscreen. Edit: it's not compiled in debug mode. Or not with something readable for my gdb:

Ahh, sorry about that. I updated a new build (same link).

1. Now you can press 'P' key to pause the rotating polygon. To compare, pause with/without -msaa at angles where jaggies are most extreme, and you can see the difference.

2. As far as the font, it has nothing to do with MSAA, but I just wanted to point out that with the scaling that suggested in another thread, for me, I'm getting good looking fonts in both windowed and fullscreen.

3. I decided to mention the fonts here since this in my general testbed app and I was testing scaleable fonts, MSAA, and speech at the moment.

4. I added a Allegro5.cfg file and set to debug.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

codetricity
Member #17,059
March 2019

Another small update. Now if you click on the [more] button, you can select startup options (VSync, antialias, Direct3D/OpenGL). Pick the polygon test to check MSAA.

GullRaDriel
Member #3,861
September 2003
avatar

Confirmed to be smoother here with the latest version.

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

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

codetricity
Member #17,059
March 2019

Hmm... question, I had only noticed that OGL startup took a bit longer but it wasn't until I added logging that I see why. It's ripping through a lot of failed modes which seems to be the cause. Is this normal behavior?

https://tinybiggames.com/temp/testbed.zip

You can see what I mean if you redownload testbed example. At startup click the more button and set render api to OpenGL, then click run and select any demo. You will see logging in the console as well a .log file in the folder.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I'll say this, it's not a fair measure of startup time when you run it with a logging console enabled. printf et al take a lot of overhead pumping output through the console.

Check out Eagle's time routines

I hacked their guts out here : https://www.allegro.cc/forums/thread/617840/1042341#target They're attribution open source license. MIT if you like or BSD.

Use them to measure time before and after al_create_display using

 double start = ProgramTime::Now();
 display = al_create_display(...);
 double diff = ProgramTime::Now() - start;

codetricity
Member #17,059
March 2019

Oh, sure I understand this. I mention it because I thought it might be another situation like what you discovered with the DirectX. There are a lot of failed modes like before your fix. If this is normal then fine, but just thought I would bring it up only in case it was.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

codetricity
Member #17,059
March 2019

Starting up from the command-line
al_create_display timing:
-milliseconds: 1591.91
-seconds : 1.59

In doing this I noticed also there may be an issue with al_draw_tinted_scaled_rotated_bitmap_region. When using OGL, it does not seem to honor the color. In an example, I load in a white bitmap and dynamically change the color. In OGL, they stay white. Hmm. You will see what I mean if you select OGL and run the ChainAction Test.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

1.59 seconds is a noticeable delay. I will look into it.

Here's a quick static win32 binary and source of a simple test program that measures startup and shutdown time.

Distro1.7z

Arguments to the program :

W H { [DX|dx|DirectX] | [FS|fs|fullscreen] | [MSAA|msaa] | NSAMPLES }

These are the times reported :

I am running Allegro 5.2.5 on Win10 on a 2.7GHz i7-5700HQ with two different adapters. An integrated Intel HD and an NVIDIA

What hardware are you using?

OpenGL and NVIDIA are just not getting along well.

When I enable multisampling and select OpenGL for the driver, it takes around 2150 MS, just over 2 full seconds in windowed mode and fullscreen took around 644 ms.

DirectX is blazing fast for fullscreen, taking only .1 seconds on the Intel HD. NVIDIA sucks again, with 576 ms for fullscreen OGL MSAA with 8 samples.

al_destroy_display takes anywhere between 4 and 6 seconds in fullscreen, which sucks. And sometimes with the NVIDIA driver, al_destroy_display hangs...???

This is with the Intel HD :

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 FS MSAA 8
Creating GL fullscreen 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 0098DCF8
al_create_display took 0.097252 seconds (97.252380 ms)
al_destroy_display took 5.984846 (5984.846273 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 DX FS MSAA 8
Creating DX fullscreen 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 0094D8E8
al_create_display took 0.093484 seconds (93.484095 ms)
al_destroy_display took 5.988315 (5988.314631 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 DX FS MSAA 8
Creating DX fullscreen 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 0285E0E0
al_create_display took 0.576954 seconds (576.954277 ms)
al_destroy_display took 5.440986 (5440.985844 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 FS MSAA 8
Creating GL fullscreen 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 000DE4F0
al_create_display took 0.438442 seconds (438.442356 ms)
al_destroy_display took 4.443937 (4443.937217 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>

This is with the NVIDIA FX :

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 MSAA 8
Creating GL windowed 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 029ED528
al_create_display took 2.041416 seconds (2041.416157 ms)
al_destroy_display took 0.126034 (126.033589 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 MSAA 8
Creating GL windowed 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 008CD528
al_create_display took 1.881896 seconds (1881.895660 ms)
^C
c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 DX MSAA 8
Creating DX windowed 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 0093D558
al_create_display took 2.094915 seconds (2094.915306 ms)
al_destroy_display took 0.048418 (48.417875 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>display_test.exe 1920 1080 DX MSAA 8
Creating DX windowed 1920 x 1080 with 8 sampled MSAA display...
al_create_display returned 0298D558
al_create_display took 1.886072 seconds (1886.072211 ms)
al_destroy_display took 0.079688 (79.687833 MS) seconds.

c:\ctwoplus\progcode\allegro5\test\CreateDisplay>

So just using the NVIDIA makes it take 2 seconds to start. That seems wrong somehow. I better try to update my drivers and see if that makes a difference.

Here's the code :

#SelectExpand
1 2 3 4 5#include <stdio.h> 6#include "allegro5/allegro.h" 7#include "allegro5/allegro_font.h" 8#include "allegro5/allegro_ttf.h" 9#include "HighPerfTimer.hpp" 10 11 12 13int main(int argc , char** argv) { 14 15 bool use_gl = true; 16 bool fs = false; 17 bool ms = false; 18 int sw = 800; 19 int sh = 600; 20 int rw = 0; 21 int rh = 0; 22 int NSAMP = 0; 23 int ns = 0; 24 if (argc > 1) { 25 if (argc > 2) { 26 if (sscanf(argv[1] , "%d" , &rw) == 1) { 27 sw = rw; 28 } 29 if (sscanf(argv[2] , "%d" , &rh) == 1) { 30 sh = rh; 31 } 32 } 33 if (argc > 2) { 34 35 for (unsigned int i = 3 ; i < (unsigned int)argc ; ++i) { 36 37 if (strncmp(argv[i] , "DX" , 2) == 0) { 38 use_gl = false; 39 } 40 if (strncmp(argv[i] , "DirectX" , 7) == 0) { 41 use_gl = false; 42 } 43 if (strncmp(argv[i] , "dx" , 2) == 0) { 44 use_gl = false; 45 } 46 if (strncmp(argv[i] , "FS" , 2) == 0) { 47 fs = true; 48 } 49 if (strncmp(argv[i] , "fs" , 2) == 0) { 50 fs = true; 51 } 52 if (strncmp(argv[i] , "fullscreen" , 9) == 0) { 53 fs = true; 54 } 55 if (strncmp(argv[i] , "MSAA" , 4) == 0) { 56 ms = true; 57 } 58 if (strncmp(argv[i] , "msaa" , 4) == 0) { 59 ms = true; 60 } 61 if (sscanf(argv[i] , "%d" , &ns) == 1) { 62 NSAMP = ns; 63 } 64 } 65 } 66 67 } 68 69 if (!al_init()) {return -1;} 70 if (!al_init_font_addon()) {return -2;} 71 if (!al_init_ttf_addon()) {return -3;} 72 73 if (!al_install_keyboard()) {return -10;} 74 75 76 if (ms) { 77 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS , 1 , ALLEGRO_REQUIRE); 78 al_set_new_display_option(ALLEGRO_SAMPLES , NSAMP , ALLEGRO_REQUIRE); 79 } 80 81 al_set_new_display_flags(fs?ALLEGRO_FULLSCREEN:ALLEGRO_WINDOWED | use_gl?ALLEGRO_OPENGL:0); 82 83 ALLEGRO_DISPLAY* d = NULL; 84 85 char buf[1024] = {0}; 86 char buf2[1024] = {0}; 87 88 sprintf(buf , "Creating %s %s %d x %d with %d sampled %s display...\n" , use_gl?"GL":"DX" , fs?"fullscreen":"windowed" , sw , sh , NSAMP , ms?"MSAA":"NonAliased"); 89 90 printf("%s" , buf); 91 92 double start = ProgramTime::Now(); 93 d = al_create_display(sw , sh); 94 double diff = (double)ProgramTime::Now() - start; 95 printf("al_create_display returned %p\n" , (void*)d); 96 sprintf(buf2 , "al_create_display took %lf seconds (%lf ms)\n" , diff , 1000.0*diff); 97 printf("%s" , buf2); 98 99 if (!d) {return 1;} 100 101 ALLEGRO_EVENT_QUEUE* q = al_create_event_queue(); 102 al_register_event_source(q , al_get_display_event_source(d)); 103 al_register_event_source(q , al_get_keyboard_event_source()); 104 105 ALLEGRO_FONT* f = al_load_ttf_font("Verdana.ttf" , 20 , 0); 106 if (!f) { 107 f = al_create_builtin_font(); 108 } 109 if (!f) {return 2;} 110 111 al_set_target_backbuffer(d); 112 al_clear_to_color(al_map_rgb(255,255,255)); 113 al_draw_textf(f , al_map_rgb(0,0,0) , sw/2 , sh/2 - al_get_font_ascent(f)/2.0 , ALLEGRO_ALIGN_CENTRE , "%s" , buf); 114 al_draw_textf(f , al_map_rgb(0,0,0) , sw/2 , sh/2 + al_get_font_ascent(f)/2.0 + 10, ALLEGRO_ALIGN_CENTRE , "%s" , buf2); 115 al_flip_display(); 116 117 ALLEGRO_EVENT ev; 118 al_wait_for_event(q , &ev); 119 120 if (d) { 121 start = ProgramTime::Now(); 122 al_destroy_display(d); 123 diff = (double)ProgramTime::Now() - start; 124 125 printf("al_destroy_display took %lf (%lf MS) seconds.\n" , diff , 1000.0*diff); 126 d = 0; 127 } 128 129 130 131 132 return 0; 133}

codetricity
Member #17,059
March 2019

I'm running a GT1030, and my numbers are a bit better than yours but way slower than your Intel. Agreed with, something afoot with NVIDIA. I do have the latest drivers. Maybe its a result of them optimizing for specific games which then effect more general use?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I'm guessing its a difference in the number of modes available, and the number of extensions supported, between the Intel HD and the NVIDIA.

Because each enumeration of a display mode and each time an extension is loaded, that adds up. I'll have to dig deeper into the code tomorrow or in a few days. Maybe I can update my patch to fix NVIDIA gpus or just window creation in general.

EDIT
<anti_lock_bump>
How can I tell if the GFX card is NVIDIA?
</bump>

 1   2 


Go to: