Hello,
I’m encountering a major performance issue when rendering large images using g.drawImageTransformed(...) in JUCE on macOS with JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS=1.
When this flag is enabled, my frame rate drops significantly (well below 10-30 FPS, + GPU/CPU 90%-100%) during image drawing. But when I disable the flag, everything runs perfectly smoothly at over 120 FPS, without any lags.
Here’s a simplified version of the rendering code I’m using:
const AffineTransform transform = AffineTransform()
.translated(-w / 2.0f, -h / 2.0f)
.scaled(drawBounds_.getWidth() / w, drawBounds_.getHeight() / h)
.rotated(angle)
.translated(centre.x, centre.y);
g.drawImageTransformed(image, transform, false);
The image being drawn is quite large (e.g., full-screen or bigger), and performance degradation seems to grow with image size.
Has anyone else faced this issue? Is there a recommended way to optimize drawImageTransformed usage with this flag enabled, or is this a known limitation of the CoreGraphics multi-paint implementation?
Also, ChatGPT mentioned that when using CoreGraphics (with JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS=1 ), especially on macOS where Metal is involved under the hood, the system may invalidate or re-upload the image texture to the GPU each time a transform is applied.
p.s. this happens for me on iOS, iPadOS and on any mac os version.
Any insight or suggestions would be much appreciated.
Thanks!
