• Vladimir Kharitonov's avatar
    metal: accelerate swing rendering (#1031) · 1b7f65b7
    Vladimir Kharitonov authored
    This PR contain:
    1. Using shared metal textures with this JBR API -
    [SharedTextures](https://github.com/JetBrains/JetBrainsRuntimeApi/blob/main/src/com/jetbrains/SharedTextures.java).
    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
    ```
    
    ---------
    Co-authored-by: 's avatarIgor Demin <igordmn@users.noreply.github.com>
    1b7f65b7
build.gradle.kts 2.71 KB