Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal: accelerate swing rendering #1031

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ujpv
Copy link

@ujpv ujpv commented Mar 3, 2025

This PR contain:

  1. Using shared metal textures with this JBR API - SharedTextures. See AcceleratedSwingPainter.

  2. Not ultimate, but visible improvement of the not accelerated painting for Windows(~%25), and MacOS(~20%). Unfortunately, didn't manage to see a positive change on Linux with XRender pipeline(about the same, probably few percents down). With opengl pipeline it also got ~20% faster. But currently our pipeline on linux is XRender
    I got rid of make one extra copy of the raster image. See SoftwareSwingPainter

com.jetbrains:jbr-api size is about 44kb

Benchmarks:
Redraw - time to prepare the offscreen image including sync, but not including fetching texture to the CPU RAM
Paint - time to get the image from GPU(if needed) and draw onto Graphics2D
Total - total time to deliver the frame

MetalSwingRedrawer:
Image size: 3200x2344
Test: ClocksAwt
MacBook Pro M1 Max
java2d pipeline = Metal
               Current   SoftwareSwingPainter   AcceleratedSwingPainter
FPS              66             80                      141
Redraw(ms)      7.13           7.13                     6.92
Paint(ms)       7.65           6.07                     0.006
Total(ms)      14.78          12.16                     6.92


Direct3DSwingRedrawer
Image size: 3176x2284
Dell Prescision 5570, i9-12900H + GPU Nvidia
Test: ClocksAwt
java2d pipeline = GDI
               Current   SoftwareSwingPainter
FPS              32             41
Redraw(ms)     12.58          11.57
Paint(ms)      17.43          11.54
Total(ms)      29.93          23.11


LinuxOpenGLSwingRedrawer
Image size: 3192x2230
Dell Prescision 5570, i9-12900H + GPU Nvidia
Test: ClocksAwt
java2d pipeline = XRender
               Current   SoftwareSwingPainter
FPS              24             23
Redraw(ms)     20.07          19.64
Paint(ms)      19.69          22.73
Total(ms)      39.77          42.39

@MaapuH
Copy link

MaapuH commented Mar 4, 2025

does that imlpy that I need to use jetbrains runtime?

@MatkovIvan
Copy link
Member

MatkovIvan commented Mar 4, 2025

does that imlpy that I need to use jetbrains runtime?

To get benefit from AcceleratedSwingPainter optimization - yes

@MatkovIvan MatkovIvan requested a review from igordmn March 4, 2025 09:05
@@ -45,6 +45,7 @@ allprojects {

repositories {
mavenCentral()
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that it will be required for all Compose customers and it looks like a blocker here

cc @igordmn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants