Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096394

Canvas rendering many small shapes has a lot of overhead on some GPUs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8u60
    • 8
    • javafx
    • None

    Description

      When using Canvas to render many small shapes, it renders each with a separate upload to a mask texture and a quad that maps that mask texture through the current paint onto the surface.

      While some GPUs and drivers deal well with the constant switching back and forth between uploads and texture operations, other GPU/drivers experience a massive degradation in performance.

      The attached test case renders a lot of tiny triangles on each frame. It also has modes to replace the triangles with rectangles and to render the entire shape as a single path. On a retina MBP with integrated Intel 4000 graphics, it achieves the following frame rates:

      triangle mode: 17-24 fps, lots of variability
      rectangle mode: 167 fps, very consistent
      path mode: 122 fps, very consistent

      The performance on the same machine using the discrete nVidia 650m gpu produces much better frame rates for the triangle mode:

      triangle mode: 65fps, fairly consistent
      rectangle mode: 460fps, very consistent
      path mode: 175fps, very consisten

      Testing on other platforms demonstrates that integrated Intel GPUs and AMD GPUs both seem to degrade significantly for the triangle mode and while the nVidia GPUs degrade much much less, they still have about 1/3 to 1/2 the performance compared to rendering the many triangles as one large shape. Some amount of performance differential should be expected wrt having to setup and render many shapes over one single, more complex, shape, but the huge gap on the Intel/AMD GPUs is much too wide, and the gap on nVidia GPUs could be improved somewhat.

      To run the Sierpinski2 benchmark in the different modes:

      triangle mode: jfx -Djavafx.animation.fullspeed=true Sierpinski2
      rectangle mode: jfx -Djavafx.animation.fullspeed=true Sierpinski2 rects
      big path mode: jfx -Djavafx.animation.fullspeed=true Sierpinski2 path

      Attachments

        Issue Links

          Activity

            People

              flar Jim Graham
              flar Jim Graham
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: