15 August 2015, 23:42 | #21 |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
The good news is that I have managed to pinpoint "when it started to go wrong" a little better. The flickering occurs when WinUAE 2.7.1b2 changes are merged into FS-UAE. Specifically, custom.cpp (it works with 2.7.1b2 changes and custom.cpp from 2.7.1b1).
The bad news is that custom.cpp saw a lot of changes going from 2.7.1b1 to 2.7.1b2. |
15 August 2015, 23:48 | #22 | |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
Hmmm, removing this code seemingly fixes the problem:
Quote:
|
|
16 August 2015, 13:16 | #23 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
|
16 August 2015, 23:25 | #24 |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
|
17 August 2015, 20:26 | #25 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
Too weird..
Does toscr_delay_adjusted[] change when glitch happens? It should not change in WB (at least unless WB screen is horizontally scrolled). |
17 August 2015, 22:55 | #26 | |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
It gets weirder...
Quote:
But anyway, onto the weird stuff... Turns out that that the "fix" involving removing some lines did not work in the latest FS-UAE versions. So I went back to the post-2.7.1beta2 merged version where this "fix" removed the flickering. The strange thing was that setting toscr_delay_adjusted[0] and toscr_delay_adjusted[1] to 0 (after the existing calculations) did not fix the flickering. This was unexpected since they should be 0 by default (static storage), and should also stay 0 when the code is commented out. So manually setting toscr_delay_adjusted[0] and [1] to 0 should have the same effect, except it didn't.... Smells indeed of undefined behavior / compiler optimizations / something... Testing further, going back to the "fix" of commenting out the lines setting toscr_delay_adjusted[] (now the flickering disappear), but then adding volatile to the declaration (static volatile int toscr_delay_adjusted[2] -- and the flickering reappears . So, still very strong indications of undefined behavior (of course, I must double-check my test results so far, but...) EDIT: Disabling compiler optimizations also breaks the "fix" (not surprisingly, as volatile too interferes with optimizations). So presumably, when toscr_delay_adjusted[] is never set, the compiler optimizer assumes (correctly) that this is effectively a constant, and optimizes (away?) some other code as a result. I'm not yet sure if this is just a wild goose chase or not. Last edited by FrodeSolheim; 17 August 2015 at 23:22. |
|
18 August 2015, 16:07 | #27 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
Does behavior also change if you remove "static"? It should force compiler to not "optimize" it away (if it for some reason does it now).
|
24 August 2015, 00:19 | #28 | |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
Quote:
The plan now is to make liberal use of #pragma GCC optimize in the source file to selectively disable optimizations for parts of the file at a time, to try to narrow down where something suspicious is happening. |
|
24 August 2015, 01:28 | #29 |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
I have fixed it (More details tomorrow, too late already!)
EDIT: the undefined behavior has also been identified now. Last edited by FrodeSolheim; 24 August 2015 at 01:47. |
24 August 2015, 21:11 | #30 |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
Yesterday I debugged the source, narrowing in on the problem by progressively compiling less and less parts of custom.cpp without optimizations until the behavior changed again. It turned out that the problem was located in long_fetch_64 and the preceeding shift functions.
I suspected there was an issue with the shift operations (implemented using a 2-item uae_u64 array), so I rewrote the shift code using GCC's 128 bit integer (__int128_t), and with this change, the flickering problem disappeared. After having confirmed that the problem was located, I took a closer look at the shifting code. The problem is the following lines: Code:
t |= p[0] >> (64 - n); ... t |= p[1] << (64 - n); This also explains why the flickering disappeared when I disabled the code responsible for setting the delay. When the compiler can prove delay is always 0, the shift functions are simply optimized away. (I do not really know why the problem does not seem to manifest itself in WinUAE. According to MSVC docs, this shift operation is undefined for MSVC as well. Perhaps it's the same reason the problem does not appear in cycle-exact mode in FS-UAE, i.e. several conditions have to be fulfilled at the same time for the flickering to occur.) I have submitted a pull request for WinUAE with a fix Last edited by FrodeSolheim; 24 August 2015 at 21:22. |
24 August 2015, 21:19 | #31 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
|
Great. I don't think this was first undefined shift bug
Just wondering why no one said it does not happen in OCS/ECS modes. It would have immediately made it much easier to narrow down. I thought it was all-modes bug because no one said anything.. (long_fetch_64 is AGA only) |
19 December 2015, 19:14 | #32 |
Registered User
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 466
|
I'm sorry to dig out this old thread again but I still have problems with emulated AGA Amigas. Visual glitches with the default overscan settings are fixed, but now there are glitches custom overscan settings. Also there a glitches with "Chaos Engine AGA" if the player (and the screen) moves horizontally. Vertical movement is OK.
I tried whdload-version and different disk-variants with different configs, but no change. uae_chipset=ocs "fixes" the problem, but disables AGA of course... Tested 2.7.5dev and latest git-master. |
22 December 2015, 18:19 | #33 |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
Yes, I get some flickering here as well, with Banshee (in-game) for example. I have merged UAE code from WinUAE 3.2.2, but flickering still occurs. I've also double-checked with WinUAE in Wine, and the flickering does not appear to happen there, at least not with Banshee. It looks like I'll need to do some tedious debugging...
Last edited by FrodeSolheim; 22 December 2015 at 20:50. |
22 December 2015, 20:51 | #34 |
FS-UAE Developer
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
|
@jbl007 I have pushed fix to github. Care to test?
|
23 December 2015, 17:05 | #35 |
Registered User
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 466
|
Small change, big impact. -> It works now.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Screen glitches with mouse movement or key press | Sparticle | Coders. C/C++ | 7 | 31 December 2014 10:11 |
Questions regarding 030 + CE accuracy | vagrant | support.WinUAE | 2 | 22 March 2014 02:01 |
Amiga CD32 Sound Glitches | Experiment T | support.WinUAE | 0 | 02 April 2009 23:13 |
Which is your all-time favourite Amiga chipset? | Paul_s | Nostalgia & memories | 15 | 28 August 2007 05:47 |
|
|