08 February 2021, 22:55 | #1 |
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
Blitter corruption in WinUAE
Hi,
I'm getting blitter corruption from my code in WinUAE in certain setups. I get it when emulating an A1200 with cpu_cycle_exact=true (but not false) And sometimes emulating an A500 with cpu_cycle_exact=false (but not true!) Real Amigas seem to run ok. Occasionally WinUAE outputs 'BLITTER write to DPT ignored!' although this does not always match up with the corruption, so may not be related. Can anyone tell me what this message means? I've checked and triple checked that I have a Wait Blitter before setting any BLT registers. This website: http://coppershade.org/articles/AMIG...g_the_Blitter/ claims that the load order for the BLT registers is important, but it is the only source I've seen for this information. Obviously you need to set BLTSIZE last to start the blit, but does the order that I set BLTxPTH/BLTCON0 matter too? Thanks |
08 February 2021, 23:02 | #2 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
Well, the info that the order matters is also in the HRM, though it's hidden quite well.
Quote:
|
|
08 February 2021, 23:14 | #3 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
08 February 2021, 23:16 | #4 |
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
|
08 February 2021, 23:19 | #5 | |
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
Quote:
Doh, I can never find things in the HRM, thanks for pointing me to it, although it does read as though it applies to BLTxDAT which I'm not currently using. |
|
08 February 2021, 23:21 | #6 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
|
08 February 2021, 23:22 | #7 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
08 February 2021, 23:24 | #8 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
Perhaps the Blitter source code might also provide some insights. Haven't had anything similar happen myself, so it would be interesting to see if we can't find a problem/difference from the 'standard'.
|
08 February 2021, 23:32 | #9 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
I noticed that very often the problem is not directly related to the code that users post, but to the environment and the exe..
|
08 February 2021, 23:33 | #10 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
Quite true!
But I still think the Blitter code can be of some small use. |
08 February 2021, 23:35 | #11 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
09 February 2021, 00:02 | #12 |
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
Before I look to post exe/code (that may need some cleanup work) I'm just trying a few more things.
I've just discovered something. In some cases I set up the BLT registers and then do multiple blits where only BLTAPTH, BLTDPTH change between each BLTSIZE. If I also set BLTDMOD per blit (even though it does not change value), then it seems to solve at least one instance of corruption. Is this a register that gets modified by the system and needs resetting before every blit? EDIT: actually I think all that is happening is that the extra command just lets the blitter finish its last operation before the next one. It must be a problem with my BLITTER_WAIT Last edited by Muzza; 09 February 2021 at 00:08. |
09 February 2021, 00:37 | #13 |
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
It was my WAIT_BLITTER macro. At some point in the past I'd changed it from a conventional wait loop to one that enabled blitter nasty.
I can't find exactly where I got it from (it has comments next to it that are definitely not from me, so I must have copied it from somewhere!) It is similar to the ones posted here http://eab.abime.net/showthread.php?t=94332 Broken version was: Code:
WAIT_BLITTER: MACRO move.w #$8400,DMACON ; Enable bit 10 : BLTPRI (BLITTER NASTY) - gives blitter priority over 68k tst.w DMACONR tst.w DMACONR move.w #$0400,DMACON ; Disable BLTPRI ENDM Code:
WAIT_BLITTER: MACRO move.w #$8400,DMACON .\@ btst #6,DMACONR bne.b .\@ move.w #$0400,DMACON ENDM |
09 February 2021, 00:46 | #14 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
So it seems the Blitter Waits in that thread didn't end up working after all. Good to know, even though I've not used them apart from that little test back then.
The second macro you show is very similar (as in, basically identical except for naming conventions) to what I actually use in my own code, it should be fine. |
09 February 2021, 01:00 | #15 |
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
Related to this, if I have a tight loop of several blits in a row, which of these versions is better?
Code:
WAIT_BLITTER: MACRO move.w #$8400,DMACON ; Enable BLTPRI .\@ btst #6,DMACONR bne.b .\@ move.w #$0400,DMACON ; Disable BLTPRI ENDM ENABLE_BLITTER_NASTY: MACRO move.w #$8400,DMACON ENDM DISABLE_BLITTER_NASTY: MACRO move.w #$0400,DMACON ; Disable BLTPRI ENDM WAIT_BLITTER2: MACRO .\@ btst #6,DMACONR bne.b .\@ ENDM ; version 1 WAIT_BLITTER Set common BLT registers loop: read one word from RAM set BLTAPTH,BLTDPTH,BLTSIZE if not done: WAIT_BLITTER goto loop ; version 2 ENABLE_BLITTER_NASTY WAIT_BLITTER2 Set common BLT registers loop: read one word from RAM set BLTAPTH,BLTDPTH,BLTSIZE if not done: WAIT_BLITTER2 goto loop DISABLE_BLITTER_NASTY |
09 February 2021, 01:00 | #16 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
This is interesting, because real amiga did not give problems.
You should try the code with the new blitter emulation engine in WinUAE 4.5 (when fully completed). Anyway yes, that code was for testing only and not to be used in a real environment! |
09 February 2021, 10:29 | #17 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
Quote:
(Note, this is obviously only true if the CPU has something useful to do. If it's waiting on the Blitter or waiting on anything else, it's not being usefull ) A small tip here is that most Blitter routines work best if they are ordered like this: Code:
Loop: <do stuff/grab variables from RAM> WAITBLITTER <setup blitter and start blitting> go to Loop |
|
09 February 2021, 16:50 | #18 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
|
What was the actual code? (Blitter setup before the wait) That kind of "wait" should work if blitter steals all cpu cycles but it isn't really good idea because non-cycle accurate emulation or reimplemention/etc that targets performance (like having enough bandwidth to allow both CPU and chipset run at the same time) would not work very well..
Anyway, that message means blitter pointer register was CPU written immediately before blitter used same pointer for DMA read/write. Write goes nowhere in this situation. All DMA pointer registers have same limitation. |
09 February 2021, 22:13 | #19 | ||
Registered User
Join Date: Sep 2019
Location: Sydney
Posts: 357
|
Quote:
Looking at it simplified like this (the real code is a lot longer) I think perhaps I'm making a performance mistake. There may be zero to eight blits happening in this pseudo code. I set certain non-changing blitter registers in advance to avoid setting them up to 8 times later on, but of course that means I have to put my WAIT_BLITTER earlier than I would have to otherwise. Possibly it is better to just set BLTCON0/1, BLTAF/LWM, BLTAMOD & BLTDMOD every time and not do the first WAIT_BLITTER so early. Code:
; one time setup of some blitter registers ; in advance of several blits to come WAIT_BLITTER move.l #$09f00000,BLTCON0 ; A->D move.l #$ffffffff,BLTAFWM move.w #0,BLTAMOD .loop2: ... work ... WAIT_BLITTER move.w #CONSTANT,BLTDMOD .loop1: ... calc new a4 ... move.l a4,BLTAPTH move.l a0,BLTDPTH move.w #CONSTANT,BLTSIZE if not done1 then: increment a0, WAIT_BLITTER, bra .loop1 if not done2 then: bra .loop2 Quote:
If I understand correctly, surely the only way that could be happening is if WAIT_BLITTER was not doing its job correctly? |
||
26 February 2021, 21:26 | #20 | |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
Quote:
And looking quickly, it seems that actually waiting for the Blitter fixes the problem. Am I wrong? Last edited by Photon; 26 February 2021 at 21:32. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Winuae monitor 1920x1080 with immediate blitter | White | support.WinUAE | 4 | 22 January 2020 13:06 |
demo bug with Winuae 4.2.1 - scroller corruption | SaphirJD | support.WinUAE | 13 | 02 July 2019 18:00 |
TVPaint corruption under WinUAE | ral-clan | support.WinUAE | 25 | 07 August 2017 17:16 |
Jaguar XJ220 GFX Corruption in winuae | SexyWayne | support.Games | 5 | 02 January 2005 12:43 |
WinUAE graphic corruption? | Critter | support.WinUAE | 13 | 08 February 2004 14:13 |
|
|