0

I recently heard about how awesome VolatileImage's performance is. I decided to switch from BufferedImage to VolatileImage, but it made things a lot worse.

1000 images performance test with BufferedImage:
0.0 ms on average to render a frame
~500 FPS

1000 images performance test with VolatileImage:
1500.0 ms on average to render a frame - that's 1.5 seconds!
<1 FPS

I am using graphics.drawImage() for all rendering. I watched a tutorial on YouTube and my code was the same, yet still I got terrible performance.

I found this thread: Java : VolatileImage slower than BufferedImage and someone in the answers mentioned that it may be due to mixing accelerated and unaccelerated operations. How can I tell which operations are hardware accelerated and which are not? Why isn't everything accelerated for the best performance?

boyernek
  • 45
  • 8
  • 2
    You can only accelerate operations if the operation (and the current parameters) are supported by the hardware. [This article](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/java2d001.html) may help. Generally, a technology that has been invented twenty years ago to improve performance on systems of that time may not be as useful on today’s systems. And, well, the results you have shown clearly indicate that your way of measuring is useless. – Holger Jul 28 '22 at 12:00

1 Answers1

0

So I messed around with the code a little and got some really interesting results.

My performance skyrocketed after changing the transparency mode. Originally I was using Transparency.BITMASK. Now when I switched to Transparency.TRANSLUCENT I got those results:

0.0 ms on average to render a frame
~500 FPS

The results are the same as in the BufferedImage test, whereas I was expecting better performance (~600-700 FPS)

But even more interesting is when I switched to Transparency.OPAQUE:

1.0 ms on average to render a frame
~100 FPS

I thought that performance will be a lot better without any translucent effects, but I was wrong. Now I am really confused by this behaviour

UPDATE: I created a different project and added 100000 bouncing balls and it was running butter smooth - 30 FPS! And of course I tried it with BufferedImage... and got the same results. I experimented with different amounts like 300, 1000, 20000, 50000 but everywhere the results were the same.

boyernek
  • 45
  • 8