dirkwhoffmann / virtualc64

VirtualC64 is a cycle-accurate C64 emulator for macOS
https://dirkwhoffmann.github.io/virtualc64
Other
356 stars 33 forks source link

Animation effects slow down when using Gaussian blur filter #276

Closed dirkwhoffmann closed 5 years ago

dirkwhoffmann commented 6 years ago

To reproduce:

Select Gaussian Blur as post-processing filter Perform a reset

None of the other filters causes the same effect Did not occur in 1.5.2 (texture size was smaller in 1.5.2, though)

TODO: It seems like fps is not computed properly (VirtualC64 measure seems to measure how many VIC frames are drawn which is always proportional to the CPU frequency). The implementation should measure how many Metal screens are drawn. I guess the Gaussian blur implementation is slow in general and the effect can only be recognized during animation effects.

dirkwhoffmann commented 6 years ago

My expectation was right. Gaussian blur slows emulator down to 30 fps.

GPU code needs a design improvement. The current GPU code works as follows:

  1. Run upscaler: 2048 x 2048 texture -> 2048 x 2048 texture
  2. Run filter: 2048 x 2048 texture -> 2048 x 2048 texture
  3. Draw into framebuffer

Improvement idea: Apply the filter in stage 3 when drawing into the framebuffer

Alessandro1970 commented 6 years ago

Thanks for the advice a few days ago, I had not seen discussion on the debate on "Gaussian Blur and FPS" before!

My MBP without the filter 60fps:

schermata 2018-08-05 alle 09 47 47

My MBP with the filter 28fps:

schermata 2018-08-05 alle 09 46 29

Here it is the Geos at 60fps on my MBP:

schermata 2018-08-05 alle 10 31 33
dirkwhoffmann commented 5 years ago

Fixed by the two-pass Gaussian blur shader implemented by Jim.