[OpenJDK 2D-Dev] Initial implementation for batched AA-mask upload for xrender

2018-02-21 Thread Clemens Eisserer
Hi,

After achieving huge speedups with Marlin Laurent Bourgès recently
proposed increasing the AA tile size of MaskBlit/MaskFill operations.
The 128x64 tiles size should help the Xrender pipeline a lot for
larger aa shapes. For smaller xrender stays rather slow.

To solve this issue am currently working on batching the AA tile mask
uploads in the xrender pipeline to improve the performance with
antialiasing enabled.
Batching can happen regardless of state-changes, so different shapes
with different properties can all be uploaded in one batch.
Furthermore that batching (resulting in larger uploads) allows for
mask upload using XShm (shared memory), reducing the number of data
copies and context switches.

Initial results seem very promising - beating the current OpenGL
implementation by a wide margin:

J2DBench, 20x20 ellipse antialiased:

XRender + deferred mask upload + XSHM:
> Test(graphics.render.tests.fillOval) averaged
> 3.436728470039390E7 pixels/sec
> with width1, !clip, Default, !alphacolor, ident,
> !extraalpha, single, !xormode, antialias, SrcOver, 20x20, bounce, to
> VolatileImg(Opaque)

XRender + deferred mask upload:
> Test(graphics.render.tests.fillOval) averaged
> 3.0930638830897704E7 pixels/sec
> with width1, !clip, Default, !alphacolor, ident,
> !extraalpha, single, !xormode, antialias, SrcOver, 20x20, bounce, to
> VolatileImg(Opaque)

OpenGL pipeline:
>  Test(graphics.render.tests.fillOval) averaged
> 1.3258861545909312E7 pixels/sec
> with Default, !xormode, !extraalpha, single, bounce,
> 20x20, to VolatileImg(Opaque), ident, !clip, !alphacolor, antialias,
> SrcOver, width1

XRender as-is:
>   Test(graphics.render.tests.fillOval) averaged
>  6031195.796094009 pixels/sec
>  with !alphacolor, bounce, !extraalpha, !xormode,
> antialias, Default, single, ident, SrcOver, 20x20, to
> VolatileImg(Opaque), !clip, width1


And a real-world test: MigLayout Swing Benchmark with NimbusLnf, ms
for one iteration:

XRender-Deferred + SHM:
AMD: 850 ms
Intel: 1300 ms

OpenGL:
AMD: 1260 ms
Intel:  2580 ms

XRender (as is):
AMD: 2620 ms
Intel:  4690 ms

(AMD: AMD Kaveri 7650k / Intel: Intel Core i5 640M )


It is still in prototype state with a few rough edges and a few
corner-cases unimplemented (e.g. extra alpha with antialiasing),
but should be able to run most workloads:
http://93.83.133.214/webrev/
https://sourceforge.net/p/xrender-deferred/code/ref/default/

It is disabled by default, and can be enabled with -Dsun.java2d.xr.deferred=true
Shm upload is enabled with deferred and can be disabled with:
-Dsun.java2d.xr.shm=false

What would be the best way forward?
Would this have a chance to get into OpenJDK11 for platforms eith
XCB-based Xlib implementations?
Keeping in mind the dramatic performance increase,
even outperforming the current OpenGL pipeline, I really hope so.

Another change I would hope to see is a modification of the
maskblit/maskfill interfaces.
For now marlin has to rasterize into a byte[] tile, this array is
afterwards passed to the pipeline,
and the pipeline itself has to copy it again into some internal buffer.
With the enhancements described above, I see this copy process already
consuming ~5-10% of cpu cycles.
Instead the pipeline could provide a ByteBuffer to rasterize into to
Marlin, along with information regarding stride/width/etc.

Best regards, Clemens

Some background regarding the issue / implementation:

Since the creation of the xrender java2d backend, I was always
bothered how poor it performed with antialiasing enabled.
What the xrender backend does in this situation seems not to be that
common - the modern drivers basically stall the GPU for every single
AA tile (currently 32x32).

Pisces was so slow, xservers could consume the tiles more or less at
the speed pisces provided it.
However with the excellent work on Pisces's successor Marlin (big
thanks to Laurent Bourgès), the bottleneck the xrender pipeline
presented was more and more evident.

One early approach to solve this weakness was to implement the AA
primitives using a modified version of Cairo,
sending a list of trapezoids to the x-server instead of the AA coverage masks.
However this approach has it's own performance issues (and is
considered hard to GPU-accelerate) and finally because of the
maintenance burden the idea was dropped.

The root of all evil is the immediate nature of Java2D:
Java2D calls into the backends with 32x32 tiles and expects them to
"immediatly" perform a bleding operation with the 32x32px alpha mask
provided.
In the xrender pipeline, this results in a XPutImage call for
uploading the coverage mask immediatly followed by an XRenderComposite
call performing the blending.
This means:
- a lot of traffic on the X11 protocol socket for transferring the
mask data -> context switches
- a lot of GPU stalls, because the uploaded data from system-memory is
immediatly used as input for the GPU operation
- a 

Re: [OpenJDK 2D-Dev] [11] Upgrade to Marlin renderer 0.9.1

2018-02-21 Thread Laurent Bourgès
Phil,
Will you have some time soon to have a look ?

It fixes dashing performance definitively and dash error accumulation too.

Laurent

Le 15 févr. 2018 6:30 PM, "Laurent Bourgès"  a
écrit :

> Hi,
>
> Please review this large patch providing Marlin 0.9.1 for JDK 11:
>
> JBS: to be created asap
> webrev: http://cr.openjdk.java.net/~lbourges/marlin/marlin-091.0/
>
> Changes:
> - *ArrayCache: removed clean flag and usage of
> jdk.internal.UNSAFE.allocateUninitializedArray()
> - (D)Curve: added support for lines (curve type 4) + new methods x/y
> Points to compute intersections on clip edges
> - (D)Dasher: use new CurveBasicMonotonizer & CurveClipSplitter to perform
> clipping in Dasher that uses skipLen() to compute properly the dash phase &
> state
> - (D)Helpers: refined precision in cubicRootsInAB (float variant) + add
> fastXXXLen() to quickly estimate curve length from control points
>   moved findSubdivPoints() from (D)Stroker + added findClipPoints() to
> determine t values corresponding to curve intersections with the clip edges
> + added subdivideLineAt() to subdivide line segments
> - (D)MarlinRenderingEngine: disable stroker clipping if dasher clipping
> enabled (2nd clipping is counter-productive) + initialize new path
> simplifier if enabled (disabled by default) + log new settings
> - (D)Renderer: refined [quad/cubic]BreakIntoLinesAndAdd loops to enhance
> accuracy (smaller error related to 2nd ddx/y) with asymetric supixel counts
> - (D)Stroker: use new CurveBasicMonotonizer & CurveClipSplitter (code
> refactoring)
> - (D)TransformingPathConsumer2D: use CurveClipSplitter in PathClipFilter
> to clip filled shapes overlapping clipping edges
> added CurveClipSplitter that subdivides curves (line, quad,
> cubic) at clip intersections (+ small padding to avoid precision issues)
> added CurveBasicMonotonizer to monotonize curves (before in
> Stroker) to make it on initial curve in Dasher (more efficient than for all
> dashes)
> - (D)PathSimplifier: new basic path clipper (disabled by default) ignoring
> too small segments (radial distance threshold)
> - ClipShapeTest: improved test to use a small tolerance as clipped curves
> (at clip edges) has minor impact on computed offsets for stroked shapes and
> on dash positions: overall quality is improved as previously larger curves
> had more accumulated error on either dashes or stroke offsets
>
> Build & jtreg tests: OK
>
> Cheers,
> Laurent
>


Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Philip Race

That is fine.

-phil.

On 2/21/18, 9:34 AM, Sergey Bylokhov wrote:

On 21/02/2018 08:49, Philip Race wrote:
I am not sure it has mac specific code, I'll reevaluate this test in 
JDK-8198406.


This is mac-specific. It looks for specific fonts by name that exist 
only on MacOS.
And moreover the table handling in the implementation is relevant 
only for Apple AAT fonts ..

which you won't find anywhere else.
The one thing about this test that could change is that it doesn't 
need to create a Frame to
test this code -  drawing to a BI would suffice .. so it does not 
have to be headful with a few changes.


I would not like to mix the test changes and updating the problem 
list. I have filed a separate bugs for each test which should be 
updated/reworked/fixed.





Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Sergey Bylokhov

On 21/02/2018 08:49, Philip Race wrote:
I am not sure it has mac specific code, I'll reevaluate this test in 
JDK-8198406.


This is mac-specific. It looks for specific fonts by name that exist 
only on MacOS.
And moreover the table handling in the implementation is relevant only 
for Apple AAT fonts ..

which you won't find anywhere else.
The one thing about this test that could change is that it doesn't need 
to create a Frame to
test this code -  drawing to a BI would suffice .. so it does not have 
to be headful with a few changes.


I would not like to mix the test changes and updating the problem list. 
I have filed a separate bugs for each test which should be 
updated/reworked/fixed.



--
Best regards, Sergey.


Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Philip Race



On 2/21/18, 7:45 AM, Sergey Bylokhov wrote:

Hi, Prasanta.
I have updated the tests mentioned in your previous email:
http://cr.openjdk.java.net/~serb/8198333/webrev.10


/java/awt/font/TextLayout/TestAATMorxFont.java should be for mac only

if (!osName.startsWith("mac")) {
   42 return;
   43 }


I am not sure it has mac specific code, I'll reevaluate this test in 
JDK-8198406.


This is mac-specific. It looks for specific fonts by name that exist 
only on MacOS.
And moreover the table handling in the implementation is relevant only 
for Apple AAT fonts ..

which you won't find anywhere else.
The one thing about this test that could change is that it doesn't need 
to create a Frame to
test this code -  drawing to a BI would suffice .. so it does not have 
to be headful with a few changes.


-phil.




javax/print/PrintServiceLookup/CountPrintServices.java for linux only
if (!os.equals("linux")) {
   44 System.out.println("Linux specific test. No need to 
continue");

   45 return;
   46 }


I guess this one could be run on mac as well, but it should be double 
checked.


Both tests have headful or printer keywords and already excluded in 
the headless mode, which is subject of the fix.




Regards
Prasanta

On 2/21/2018 7:28 PM, Prasanta Sadhukhan wrote:

Couple of points.

Shouldn't java/awt/List/SetBackgroundTest/SetBackgroundTest.java be 
run only on solaris/linux as it tests


if (!isXAWT){
  77 System.out.println(" this is XAWT-only test. ");
  78 return;
  79 }

java/awt/Toolkit/RealSync/Test.java has
System.exit(1);

Should we not remove that as it might hamper jtreg run?

I also think that this bugid needs to be added to all updated tests.

Regards
Prasanta

On 2/21/2018 1:33 AM, Phil Race wrote:

+1

-phil

On 02/20/2018 07:10 AM, Sergey Bylokhov wrote:

Hello.
Please review update of the tests for jdk11.

The goal is to make our testing as stable as possible and exclude 
any unstable tests(I have started from the tests which may be run 
in the headless mode).


Bug: https://bugs.openjdk.java.net/browse/JDK-8198333
Webrev can be found at: 
http://cr.openjdk.java.net/~serb/8198333/webrev.09


 - The ProblemList.txt is update, I have created a list of new 
bugs for any tests which fail at least once in a few iterations on 
a different systems.
 - "@key headful" was added to some tests which are noop in 
headless mode, they have some checks like:

* Desktop.isDesktopSupported
* Toolkit.getDefaultToolkit().getClass().getName().equals/
* GraphicsEnvironment.isHeadlessInstance()
* SystemTray.isSupported()
   ... etc. These checks are always false in headless mode.
 - "@key printer" was added to the tests which works in the 
headless mode, and tries to print something. Some of these tests 
are noop w/o printer.
 - "@run main/othervm" was added to a few tests which fails in 
agentvm mode. This mode is a default in mach5.

 - A few typos in the tests tags were fixed.












Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Prasanta Sadhukhan

looks ok. Only thing is the tests do not have the current bugid appended.

Regards
Prasanta
On 2/21/2018 9:15 PM, Sergey Bylokhov wrote:

Hi, Prasanta.
I have updated the tests mentioned in your previous email:
http://cr.openjdk.java.net/~serb/8198333/webrev.10


/java/awt/font/TextLayout/TestAATMorxFont.java should be for mac only

if (!osName.startsWith("mac")) {
   42 return;
   43 }


I am not sure it has mac specific code, I'll reevaluate this test in 
JDK-8198406.




javax/print/PrintServiceLookup/CountPrintServices.java for linux only
if (!os.equals("linux")) {
   44 System.out.println("Linux specific test. No need to 
continue");

   45 return;
   46 }


I guess this one could be run on mac as well, but it should be double 
checked.


Both tests have headful or printer keywords and already excluded in 
the headless mode, which is subject of the fix.




Regards
Prasanta

On 2/21/2018 7:28 PM, Prasanta Sadhukhan wrote:

Couple of points.

Shouldn't java/awt/List/SetBackgroundTest/SetBackgroundTest.java be 
run only on solaris/linux as it tests


if (!isXAWT){
  77 System.out.println(" this is XAWT-only test. ");
  78 return;
  79 }

java/awt/Toolkit/RealSync/Test.java has
System.exit(1);

Should we not remove that as it might hamper jtreg run?

I also think that this bugid needs to be added to all updated tests.

Regards
Prasanta

On 2/21/2018 1:33 AM, Phil Race wrote:

+1

-phil

On 02/20/2018 07:10 AM, Sergey Bylokhov wrote:

Hello.
Please review update of the tests for jdk11.

The goal is to make our testing as stable as possible and exclude 
any unstable tests(I have started from the tests which may be run 
in the headless mode).


Bug: https://bugs.openjdk.java.net/browse/JDK-8198333
Webrev can be found at: 
http://cr.openjdk.java.net/~serb/8198333/webrev.09


 - The ProblemList.txt is update, I have created a list of new 
bugs for any tests which fail at least once in a few iterations on 
a different systems.
 - "@key headful" was added to some tests which are noop in 
headless mode, they have some checks like:

    * Desktop.isDesktopSupported
    * Toolkit.getDefaultToolkit().getClass().getName().equals/
    * GraphicsEnvironment.isHeadlessInstance()
    * SystemTray.isSupported()
   ... etc. These checks are always false in headless mode.
 - "@key printer" was added to the tests which works in the 
headless mode, and tries to print something. Some of these tests 
are noop w/o printer.
 - "@run main/othervm" was added to a few tests which fails in 
agentvm mode. This mode is a default in mach5.

 - A few typos in the tests tags were fixed.














Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Sergey Bylokhov

Hi, Prasanta.
I have updated the tests mentioned in your previous email:
http://cr.openjdk.java.net/~serb/8198333/webrev.10


/java/awt/font/TextLayout/TestAATMorxFont.java should be for mac only

if (!osName.startsWith("mac")) {
   42 return;
   43 }


I am not sure it has mac specific code, I'll reevaluate this test in 
JDK-8198406.




javax/print/PrintServiceLookup/CountPrintServices.java for linux only
if (!os.equals("linux")) {
   44 System.out.println("Linux specific test. No need to 
continue");

   45 return;
   46 }


I guess this one could be run on mac as well, but it should be double 
checked.


Both tests have headful or printer keywords and already excluded in the 
headless mode, which is subject of the fix.




Regards
Prasanta

On 2/21/2018 7:28 PM, Prasanta Sadhukhan wrote:

Couple of points.

Shouldn't java/awt/List/SetBackgroundTest/SetBackgroundTest.java be 
run only on solaris/linux as it tests


if (!isXAWT){
  77 System.out.println(" this is XAWT-only test. ");
  78 return;
  79 }

java/awt/Toolkit/RealSync/Test.java has
System.exit(1);

Should we not remove that as it might hamper jtreg run?

I also think that this bugid needs to be added to all updated tests.

Regards
Prasanta

On 2/21/2018 1:33 AM, Phil Race wrote:

+1

-phil

On 02/20/2018 07:10 AM, Sergey Bylokhov wrote:

Hello.
Please review update of the tests for jdk11.

The goal is to make our testing as stable as possible and exclude 
any unstable tests(I have started from the tests which may be run in 
the headless mode).


Bug: https://bugs.openjdk.java.net/browse/JDK-8198333
Webrev can be found at: 
http://cr.openjdk.java.net/~serb/8198333/webrev.09


 - The ProblemList.txt is update, I have created a list of new bugs 
for any tests which fail at least once in a few iterations on a 
different systems.
 - "@key headful" was added to some tests which are noop in headless 
mode, they have some checks like:

    * Desktop.isDesktopSupported
    * Toolkit.getDefaultToolkit().getClass().getName().equals/
    * GraphicsEnvironment.isHeadlessInstance()
    * SystemTray.isSupported()
   ... etc. These checks are always false in headless mode.
 - "@key printer" was added to the tests which works in the headless 
mode, and tries to print something. Some of these tests are noop w/o 
printer.
 - "@run main/othervm" was added to a few tests which fails in 
agentvm mode. This mode is a default in mach5.

 - A few typos in the tests tags were fixed.










--
Best regards, Sergey.


Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Prasanta Sadhukhan

Also, these test should have @requires os.family too

/java/awt/font/TextLayout/TestAATMorxFont.java should be for mac only

if (!osName.startsWith("mac")) {
  42 return;
  43 }

javax/print/PrintServiceLookup/CountPrintServices.java for linux only
if (!os.equals("linux")) {
  44 System.out.println("Linux specific test. No need to continue");
  45 return;
  46 }

Regards
Prasanta

On 2/21/2018 7:28 PM, Prasanta Sadhukhan wrote:

Couple of points.

Shouldn't java/awt/List/SetBackgroundTest/SetBackgroundTest.java be 
run only on solaris/linux as it tests


if (!isXAWT){
  77 System.out.println(" this is XAWT-only test. ");
  78 return;
  79 }

java/awt/Toolkit/RealSync/Test.java has
System.exit(1);

Should we not remove that as it might hamper jtreg run?

I also think that this bugid needs to be added to all updated tests.

Regards
Prasanta

On 2/21/2018 1:33 AM, Phil Race wrote:

+1

-phil

On 02/20/2018 07:10 AM, Sergey Bylokhov wrote:

Hello.
Please review update of the tests for jdk11.

The goal is to make our testing as stable as possible and exclude 
any unstable tests(I have started from the tests which may be run in 
the headless mode).


Bug: https://bugs.openjdk.java.net/browse/JDK-8198333
Webrev can be found at: 
http://cr.openjdk.java.net/~serb/8198333/webrev.09


 - The ProblemList.txt is update, I have created a list of new bugs 
for any tests which fail at least once in a few iterations on a 
different systems.
 - "@key headful" was added to some tests which are noop in headless 
mode, they have some checks like:

    * Desktop.isDesktopSupported
    * Toolkit.getDefaultToolkit().getClass().getName().equals/
    * GraphicsEnvironment.isHeadlessInstance()
    * SystemTray.isSupported()
   ... etc. These checks are always false in headless mode.
 - "@key printer" was added to the tests which works in the headless 
mode, and tries to print something. Some of these tests are noop w/o 
printer.
 - "@run main/othervm" was added to a few tests which fails in 
agentvm mode. This mode is a default in mach5.

 - A few typos in the tests tags were fixed.









Re: [OpenJDK 2D-Dev] [11] Review Request: 8198333 ProblemList should be updated for headless mode

2018-02-21 Thread Prasanta Sadhukhan

Couple of points.

Shouldn't java/awt/List/SetBackgroundTest/SetBackgroundTest.java be run 
only on solaris/linux as it tests


if (!isXAWT){
  77 System.out.println(" this is XAWT-only test. ");
  78 return;
  79 }

java/awt/Toolkit/RealSync/Test.java has
System.exit(1);

Should we not remove that as it might hamper jtreg run?

I also think that this bugid needs to be added to all updated tests.

Regards
Prasanta

On 2/21/2018 1:33 AM, Phil Race wrote:

+1

-phil

On 02/20/2018 07:10 AM, Sergey Bylokhov wrote:

Hello.
Please review update of the tests for jdk11.

The goal is to make our testing as stable as possible and exclude any 
unstable tests(I have started from the tests which may be run in the 
headless mode).


Bug: https://bugs.openjdk.java.net/browse/JDK-8198333
Webrev can be found at: 
http://cr.openjdk.java.net/~serb/8198333/webrev.09


 - The ProblemList.txt is update, I have created a list of new bugs 
for any tests which fail at least once in a few iterations on a 
different systems.
 - "@key headful" was added to some tests which are noop in headless 
mode, they have some checks like:

    * Desktop.isDesktopSupported
    * Toolkit.getDefaultToolkit().getClass().getName().equals/
    * GraphicsEnvironment.isHeadlessInstance()
    * SystemTray.isSupported()
   ... etc. These checks are always false in headless mode.
 - "@key printer" was added to the tests which works in the headless 
mode, and tries to print something. Some of these tests are noop w/o 
printer.
 - "@run main/othervm" was added to a few tests which fails in 
agentvm mode. This mode is a default in mach5.

 - A few typos in the tests tags were fixed.