dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
293 stars 24 forks source link

Jitter in interlace mode #772

Closed dirkwhoffmann closed 1 year ago

dirkwhoffmann commented 1 year ago

This bug was originally reported by @AriX. The following video clarifiers the issue:

https://user-images.githubusercontent.com/12561945/209540211-936030a1-3317-4afb-8eca-386b448e3db5.mov

The issue is most likely due to frame drops. My guess is that, when a frame drop occurs, the wrong texture is updated.

dirkwhoffmann commented 1 year ago

This bug was actually a big one. Background: The graphics pipeline picks one of three paths based on the values of the long-frame bits of the current and the previous frame. The first two cases occur in standard modes and the latter one in interlace mode:

       // Compute the merge texture
        if currLOF == prevLOF {

            if currLOF {
                // Case 1: Non-interlace mode, two long frames in a row
            } else {
                // Case 2: Non-interlace mode, two short frames in a row
            }

        } else {
            // Case 3: Interlace mode, long frame followed by a short frame
        }

Now, let's assume a frame gets dropped in interlace mode. Then, currLOF matches prevLOF on the GPU side. Hence, the GUI selects a GPU path for a standard drawing mode which is wrong.

In the new code, the GUI gets the values currLOF and prevLOF right, even if frames are dropped or if the same frame is presented to the GUI twice (in case the emulator is too slow).

With the new code, the jitter is gone:

https://user-images.githubusercontent.com/12561945/209810283-6952ab13-ef19-4083-b840-3b24d06a24c0.mov

dirkwhoffmann commented 1 year ago

Fixed in v2.3