Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java1.5 and OpenGL for 2D  RSS feed

 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across the fact that you can use OpenGL acceleration when doing some 2d graphics manipulation in the 1.5beta2 release.

http://java.sun.com/j2se/1.5.0/docs/guide/2d/new_features.html#ogl

I'm wondering how a test(s) could be written to detect differences in the new way versus the standard?

Regards,
Aaron R>
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad to see that they finally decided to do that for the Windows VM as well. Originally it was just targeted for Linux and Solaris.

I'd be interested in some tests as well, but I'm not smart enough to write any up. Something else I would be interested in knowing is what happens if only software rendering is available. What I mean is, some video cards don't support hardware opengl rendering but the drivers still support it so the driver actually handles the opengl instead of the firmware on the video card. In most cases, software rendering is extremely slow and I wonder if that could actually hurt performance compared to just not using the pipeline at all. Or if the VM checks for hardware support and if it isn't there, disables it.
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried running a few apps using the OpenGL command and always get an unable to enable the OpenGL pipeline error. The program runs, but performance goes down.

Has anyone had any success?

Regards,
Aaron R>
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked fine on my Windows box. I haven't tried it on my Laptop yet, which is Linux. I'll let you know what happens. What OS are you running?
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are the results from a WinXP computer -

C:\ardev\brackeen source\ch02src>java ImageSpeedTest
Opaque: 3470.0 images/sec
Transparent: 7262.706 images/sec
Translucent: 352.66666 images/sec
Translucent (Anti-Aliased): 480.66666 images/sec

C:\ardev\brackeen source\ch02src>java -Dsun.java2d.opengl=True ImageSpeedTest
OpenGL pipeline enabled for default config on screen 0
Opaque: 2.3923445 images/sec
Transparent: 3779.3333 images/sec
Translucent: 93.333336 images/sec
Translucent (Anti-Aliased): 382.66666 images/sec

C:\ardev\brackeen source\ch02src>java ImageSpeedTest2
Opaque: 3298.6667 images/sec
Transparent: 7262.706 images/sec
Translucent: 354.66666 images/sec
Translucent (Anti-Aliased): 480.66666 images/sec
Opaque (Flipped): 426.66666 images/sec
Transparent (Flipped): 423.33334 images/sec
Translucent (Flipped): 216.0 images/sec
Translucent (Anti-Aliased, Flipped): 252.66667 images/sec

C:\ardev\brackeen source\ch02src>java -Dsun.java2d.opengl=True ImageSpeedTest2
OpenGL pipeline enabled for default config on screen 0
Opaque: 2.3923445 images/sec
Transparent: 3846.0 images/sec
Translucent: 92.666664 images/sec
Translucent (Anti-Aliased): 382.0 images/sec
Opaque (Flipped): 97.333336 images/sec
Transparent (Flipped): 3681.3333 images/sec
Translucent (Flipped): 36.279682 images/sec
Translucent (Anti-Aliased, Flipped): 99.934685 images/sec

Using the pipeline killed the performance! The only test I saw it improve things on was the Transparent (Flipped) test. Not sure what to think of the results, as I was hoping for at least equal results with it turned on.

Hmmmmm.. I can't seem to find anyone who is trying to use this. Anyone try any other tests?

Regards,
Aaron R>
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I had to guess at why the performance was killed is because the pipeline is using Software to render the Opengl instead of hardware, like I said in my first post. I know that my driver for my card on my Linux machine only supports software rendering because when I code SDL/C++ and OpenGL code I test for hardware and software and have to set the SDL Surface up accordingly and it always defaults to software. Could you send me your code and let me run it on my machine? I'll post the results here.

Thanks.
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll zip up the source and send it to you. Whats weird about the pipeline though is on my other computer it gives me an error saying the pipeline couldn't be opened. I would think if it was opening a software pipeline, it would show the same/similiar error. I can't find any documentation other than the original link from above, so I've no way of knowing whats going on in the background.

Regards,
Aaron R>
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,
I did some more checking. David, from the book, recommended powers of 2 for the images. Duhhh! I hadn't even paid attention to the fact that openGL uses powers of 2 for its images.

I also switched the image formats around and found some very interesting results. Here ya go -

Change opaque image to jpg at 128x128
Opaque: 13120.667 images/sec !!! Wow

Change opaque image to jpg at 256x256
Opaque: 3662.0 images/sec

Switch transparent image to gif at 128x128
Tranparent: 6276.6665 images/sec

Switch transparent image to gif at 256x256
Tranparent: 2877.3333 images/sec

Switch transparent image to png 24 bit color at 256x256
Transparent: 1.626898 images/sec

It would be interesting to compare results from linux. Apparently java uses direct3d to accelerate image drawing normally in windows world. I recompiled the ImageSpeedTest to accomodate for the file extension changes.

Regards,
Aaron R>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!