Hi Mik,
Michele Puccini wrote:
Hi Chris,
here's a simple crude test case. It basically draws lines to an
offscreen image. Lines can be antialiased or not. When the image is
ready it is painted to a jframe.
From the "settings" in the source you can choose the kind of image to
generate, the antialiasing level and (of course) the opengl acceleration.
The VolatileImage codepath is not "perfect" as it does not handle
contentsLost(), but should be ok for such a poor little test.
There's one minor problem with the testcase: the call to Toolkit.sync()
needs to come right after computeImage(), not before it. Otherwise,
you're not accurately measuring the time it takes to flush the hardware
pipeline and render the pixels onto the destination.
Writing accurate microbenchmarks can be a tricky business. That's why
as usual I'd recommend using J2DBench (available as part of the JDK
source download bundle) for all your benchmarking needs. You're much
more likely to get reliable results from that than always rolling your
own microbenchmark. (For example, you're calling random() in your inner
loop; good microbenchmarks like J2DBench avoid all unnecessary/unrelated
method calls so that you're only measuring what matters.)
Also, when you're rendering to a BufferedImage (or "compatible" image),
you're only measuring the performance of software loops, not the OGL
pipeline. To measure performance of the OGL pipeline, you have to
render to a VolatileImage.
---------------------------------------------------------------------
Config 1
---------------------------------------------------------------------
WinXP sp2, P4-945D 3.4Ghz, 2GB ram, NVidia 7600GT (drivers 93.71), jdk
1.5.1_11, jdk 1.6.0 fcs.
on jdk6, volatileimage or compatibleimage, antialias on or off, ogl on:
I can "run" the test for a number of times, then the test does not work
anymore (driver issue ?).
Sometimes I get a crash into NVOpenGLPbuffer.exe. Sometimes it silently
dies.
This is the driver bug I alluded to earlier in 93.71. This bug is fixed
in Nvidia's next release, but it has been extremely frustrating waiting
for them to release that new driver (3 months is way too long between
releases)! Until that's released, you can work around the problem by
adding the following to the command line:
-Dsun.java2d.opengl.fbobject=false
on jdk5 it seems to work with any combination.
In any case I don't see any speed difference (with a bigger n. of lines)
with ogl on or off, with or without antialiasing. That could be my
fault. I'm focusing on stability, first.
On the couple Nvidia configurations I tried, I got similar performance
results to what I saw on ATI when rendering to a VolatileImage (more
details below). I would expect OGL to be a win for non-AA diagonal
lines, and maybe a bit slower for AA diagonal lines.
---------------------------------------------------------------------
---------------------------------------------------------------------
Config 2
---------------------------------------------------------------------
WinXP sp2, P4 3.2Ghz HT, 2GB ram, ATI X1600 (drivers catalyst 6.12), jdk
1.5.1_11, jdk 1.6.0 fcs.
on jdk6, volatileimage or compatibleimage, antialias on or off, ogl on:
Test frame repaint is broken: does not always repaint.
Could you elaborate on this? How is it broken?
The test works and I see the lines, even when running multiple times.
BIG suprise! Using the volatileimage path I get the real OpenGL speed
(but the antialias must be off)!
Here's what I see on my machine with ATI Radeon 9800 Pro, 2x 2.8GHz P4
(rendering to VolImg using J2DBench):
Options common across all tests:
testname=graphics.render.tests.drawLine
graphics.opts.xormode=false
graphics.render.opts.paint=random
graphics.opts.renderhint=Default
graphics.opts.alpharule=SrcOver
graphics.opts.extraalpha=false
graphics.render.opts.alphacolor=false
global.dest=VolatileImg
graphics.opts.sizes=250
graphics.opts.clip=false
graphics.opts.anim=2
graphics.render.opts.antialias=false:
def: 8670.301671 (var=0.04%) (100.0%)
ogl: 458044.06401 (var=0.04%) (5282.91%)
graphics.render.opts.antialias=true:
def: 547.1678467 (var=0.67%) (100.0%)
ogl: 542.0107349 (var=0.0%) (99.06%)
As you can see, there's not much benefit for AA lines, but for non-AA
lines OGL is about 50x faster than the default, mainly because the new
STR architecture avoids JNI overhead, plus the default pipeline doesn't
accelerate diagonal lines in hardware like OGL does.
Note that the numbers for AA lines still look pretty bad for OGL when
compared to non-AA. We haven't done any special optimization for the AA
case yet; we rasterize the line in software, and then do the last
compositing step in hardware. This is an especially inefficient
approach for diagonal lines, but it's the best way to ensure consistent
quality across all vendors/platforms. We could potentially use OGL's
built-in AA lines for simple cases like the one you're using (standalone
lines), but their quality varies wildly between vendors. (Sometimes
you'll get a 2 pixel wide line when you asked for one, and so on. Not
terribly reliable.) Anyway, if anyone wants to experiment with
improving AA line performance in the OGL pipeline, please be my guest.
on jdk5, the menubar is black (?)
Test frame repaint is broken: does not always repaint.
The test works and I see the lines, even when running multiple times.
Exiting the test produces a crash. See the PID.
These were known ATI driver bugs that were worked around in JDK 6 and
beyond. At this point, I wouldn't suggest using the OGL pipeline on JDK
5; we rewrote the OGL pipeline in JDK 6 in order to avoid all of those
problems, and we're not planning to backport any of that work to JDK 5.
JDK 6 is your best bet for stability of the OGL pipeline; we'll be
backporting important fixes to JDK 6 update releases going forward.
Thanks,
Chris
I hope this helps.
Cheers,
Mik
============================================================================
ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte
(PI) <
Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB:
http://www.classx.it <
============================================================================
----- Original Message ----- From: "Chris Campbell"
<[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 26, 2007 7:44 AM
Subject: Re: [JAVA2D] java2d Compositing -> OpenGL fragment shaders
Hi Mik,
All I can do is reiterate what I've said before... Our OGL pipeline
is only as good as the underlying drivers. We've done a ton of work
with Nvidia and ATI to get them to fix the remaining driver bugs, and
those efforts have been mostly successful. Lately we've been waiting
on both companies to release new drivers that contain fixes for some
really annoying crash/artifact bugs that cropped up recently. Both
Nvidia and ATI have a large testsuite that exercises Java 2D's OGL
pipeline, and this has helped prevent driver regression bugs, but
unfortunately it hasn't completely eliminated the problem. All we
can do is continue to keep the pressure on those companies so that
they don't release buggy drivers.
Please, if you've seen any bugs or performance issues in the OGL
pipeline, even if you think they're just driver bugs (and they
probably are), submit a bug report! Don't assume that we already
know about the problem! We can't fix problems that we don't know
about! And be as specific as possible about the problem (OS,
graphics board(s), exact driver version(s)) and include a testcase.
We all want developers to be able to consistently rely on the OGL
pipeline; the only way to get there is for developers like yourself
to help us stamp out the remaining bugs and keep the graphics vendors
on their toes.
Chris
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".