I'm working on a game library for Delphi using Allegro5 and have a question about this. Does the window suppose to jiggle like this on startup when MSAA is enabled?
Thanks
I've watched your video several times now, and I'm just not seeing it. Maybe it's too quick for me to notice, but I don't see any jiggling.
Correction, I see it now. The window position noticeably stutters on window creation.
Well, never seen that before. Can you post some system details? For instance I don't know what Delphi is.
Please post your OS, compiler and version, allegro version, and some code that can demonstrate this. Posting source code is best, but a binary that demonstrates it built in debugging mode might suffice.
Ok sure:
Allegro 5.2.5.0
Windows 10 Pro - Version:1809, Build:17763.379
This is the code I use to open a window and set MSAA:
Oh, in my testing, setting ALLEGRO_SAMPLES higher than 3, will result in the window stuttering.
Thanks
First, let's see if we can replicate it in C alone.
Here is some test code that enables multisampling on Windows 10 using MinGW-W64 gcc 8.1 :
However, I can't get it to jiggle. The window comes up directly. OpenGL takes longer, but still doesn't flicker.
I'm using Allegro 5.2.5
Hmmm. Interesting. Welp, looks likes something weird on my end. I will keep digging around and see what I can find.
Thanks so much for the help with this. Respect!
Update: If I add al_set_new_display_flags(ALLEGRO_OPENGL) and use OPENGL, I don't get the jiggle at all. Can you try Direct3D on your end? This may be the culprit.
Direct3D works for me with the code I posted above.
Try compiling with MinGW first, and then Delphi, to rule out any funny business on Delphi's part.
Edit, try this static exe that runs in D3D mode :
Hey, thanks for the sample to test. Yes, I get the jiggle with it as well. Maybe it's my NVIDIA drivers? I am using the latest versions, however. Sigh. Weird too that it only happens if it's > 3.
Hmmm, looking in the log file, I see some D3D format fails, I wonder if this has anything to do with it? I attached the log.
If it jiggles on your system and not mine, then it's some kind of difference between the two of our machines.
We're both using Windows 10, so that shouldn't be it assuming you are up to date.
I've got an older NVIDIA driver. That may be it, and I'm also running an onboard integrated Intel card.
By Jove, that's it. I don't get the flicker with my integrated Intel, but I do when I run it with the NVIDIA.
EDIT
yeah, your log is messed up. It's creating and destroying the display multiple times. I'll try it with the NVIDIA and see what is going on in my log.
EDIT2
My log has many of the same failure entries. Looks like D3D and NVIDIA don't play nice together right now.
Ahh, ok then. I'm not crazy, hehe.
Bro big props to you for your help with this. Thank you.
RESPECT!
I would need to debug this to investigate further, but I've never even looked at the D3D code. It might take me some time to figure out what's going on where.
For now, I would ask that you report this as a new issue on Github :
Ok, thanks.
RESPECT!
Ah, gratitude is always appreciated, and seldom given. You're welcome.
So if you want, you could try debugging with gdb, if you have the knowledge necessary to navigate threads and frames, get a backtrace, print values, go to the 'next' line or 'step' into a function call, set breakpoints, etc...
It looks like Delphi comes with a pretty nice Debugger, or was that just Rad?
Yup, so true. It is what we need more of, especially this day and time — common courtesy and gratitude. The world has certainly changed in the past 20 years. I remember a time when "word was bond." Nowadays, people can be shaking your hand and stabbing you in the back, at the same time, haha! Crazy but true.
Yes, Delphi (part of RAD Studio, include C++ Builder also) has a fantastic debugger. C++ Builder can consume Delphi code, and Delphi can consume C++ Builder/Visual Studio C OJB files (to a certain degree), but to use Allegro with Delphi the C headers had to be converted, and I dynamically link to the Allegro DLL (using the 32-bit monolithic one from the release page).
I managed to compile the previous version using VS2017, but it was a lot of work and could not get some of the dependencies to compile. I eventually gave up. The reason I tried to compile myself was that at the time, the MinGW version (VS does not include a monolithic version) had some dependencies (something thread and one or two more), even on the monolithic one. I reported it and now seems this is now corrected, and allegro_monolith-5.2.dll in the latest release does not suffer from that problem. Just have to keep the headers updated now.
So far, other than this issue, I've got 98% of my library ported from SDL2 (so many DLLs you have to include, 18+, sigh) and managed to fix/include/improve features that I've been looking to do for some time now. I am delighted to be using Allegro5.
I've got 98% of my library ported from SDL2 ... I am delighted to be using Allegro5.
Ah, revenge is sweet.
EDIT
To really debug this, I need to use VS, but I just broke it beyond repair by getting it stuck in a 22GB update loop that will never complete.
EDIT2
There's another similar issue here : https://github.com/liballeg/allegro5/issues/922
If I ever manage to fix VS, I'll try to debug it.
Ok cool, thanks. Oh yea, I recently came across that similar issue as well.
Ahh, that sucks bro, I know about updating hosing your working install all too well. Sigh.
I got Visual Studio fixed I'll look into this shortly.
My laptop power adapter died a week ago and I've been without a computer.
EDIT
Back in black!!!!
So, there's some funny business going on.
The workhorse of d3d device creation is d3d_create_device and it keeps returning D3DERR_INVALIDCALL and I can't figure out why. That's why it flickers, because the window is being created and destroyed multiple times before it succeeds.
I've enlisted the aid of Stack Overflow here :
Hopefully someone can help me enable debugging output in DirectX because I haven't had any luck so far.
EDIT2
I've posted a bounty for 50 reputation on StackOverflow if anyone can help me solve this ----
Thanks
EDIT3
It was due to an off by one error in the format list generation code. It should be fixed shortly after I finish up and make a patch. If anyone wants to help test, you can fork the 'test' branch of my allegro 5 fork here :
https://github.com/EdgarReynaldo/allegro5
https://github.com/EdgarReynaldo/allegro5/tree/test
Wooo Edgar, you finally got it !!
I'm gonna test it Sunday when I'll be back home :-D
It was due to an off by one error in the format list generation code. It should be fixed shortly after I finish up and make a patch. If anyone wants to help test, you can fork the 'test' branch of my allegro 5 fork here :
I can confirm that it works. Many thanks!
So the code worked? And it was multisampled? In D3D mode on Nvidia?
It's kind of tricky, because to get multisampling, you need D3DMULTISAMPLE_NONMASKABLE instead of D3DMULTISAMPLE_#_SAMPLES, which is really misleading. And quality levels in no way indicates the number of samples afaics, just the number of settings that are possible. :? ?
Here is a demo:
https://tinybiggames.com/temp/testbed.zip
1. run tbtestbed for no MSAA, run tbtestbed -msaa to enable msaa
2. also, using the scaled ttf change. toggle between window/fullscreen to see the quality is good in both
MultiSamplingAntiAliasing is only good for primitives. Transformed bitmaps are not affected, so that doesn't really work.
EDIT
I can't really tell the difference between tbtestbed with or without msaa
Even running them side by side they look pretty dang similar if not the same.
yes, I understand this. my point is that the fonts rendered on screen are the new scaled change from the other thread. if you do not use -msaa, toggling between window/fullscreen they look good in both is what I'm getting at.
see my edit - my eyes are not good enough to see a difference - where do you say it's visible?
1. run the tbtestbed with and without -msaa
2. position the console window so it slightly overlaps the window
3. click between the console window and the main window to pause and unpause
4. you can see a striking difference in jaggies without -msaa as it rotates
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:
Thread 1 received signal SIGSEGV, Segmentation fault. 0x0000002b in ?? () (gdb) bt #0 0x0000002b in ?? () #1 0x09bf8238 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?)
The crash occur when I try to use fullscreen mode, when pressing F11.
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.
I think I can see the difference now. It does look smoother with -msaa.
The fonts in windowed mode do look a little blurry, but not too bad.
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.
Confirmed to be smoother here with the latest version.
I'll submit a patch for this soon.
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.
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;
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.
I didn't say it was normal, and I didn't say it wasn't also a performance issue to be addressed. I just wanted the test to be accurate, and see if the kind of delay being experienced is enough to cause discomfort.
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.
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.
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 :
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?
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>