Work done so far :
A working prototype of basic feature-set with Java 2D Metal rendering pipeline has been implemented for -
- 2D Primitives rendering
- Image rendering
- Grayscale Text Rendering
It is available in the lanai repo https://hg.openjdk.java.net/lanai/lanai/
It can be tested with J2DDemo (available at - src/demo/share/jfc/J2Ddemo) that shows working / partially working / not-working Java 2D features with Metal rendering as compared with OpenGL rendering.
VM option -Dsun.java2d.metal=True needs to be passed in to switch rendering pipeline to Metal.
Also, antialiasing needs to be turned off (which is on by default in J2DDemo)
Work in Progress :
Current focus area is - Rendering performance evaluation :
As basic blocks of rendering have been implemented, it is a good time to check on rendering performance to evaluate how Metal rendering in Java 2D fares as compared to OpenGL rendering in Java 2D. As a first step, we are using below test benchmarkings -
- RenderPerfTest (available at - src/demo/share/java2d/RenderPerfTest)
- J2DBench Tests (available at - src/demo/share/java2d/J2DBench) for drawing 2D primitives - line, rectangle, filled rectangle, ellipse, filled ellipse.
The performance numbers for Java 2D Metal rendering pipeline are not up to the mark as compared to the Java 2D OpenGL rendering pipeline. Multiple design level optimizations are being done to address this.
- Reducing number of MTLRenderEncoders that get created per render pass
- Reducing the number of drawPrimitives calls by batching data whenever possible
- Using setNeedsDisplay flag of MTLLayer and updating the layer content on AppKit thread in a callback