Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java2D OpenGL Acceleration  (Read 3530 times)
0 Members and 1 Guest are viewing this topic.
Offline 20thCenturyBoy

Senior Member


Medals: 3


So much to learn, so little time.


« Posted 2005-02-21 04:32:47 »

The following quote is from Sun re J2SE 5.0:

Quote
Linux and Solaris users, and new in beta2, Windows users, who have the latest OpenGL drivers and select graphic cards can get native hardware acceleration from Java2D using the following runtime property:

java -Dsun.java2d.opengl=true -jar Java2D.jar


Does this mean that if I take my 1.4.2 Java2D game, and run it under 5.0 with the above switch I will automatically get OpenGL acceleration for free(assuming I have OpenGL drivers installed) ? In particular does this mean translucent images will be accelerated?


"I have never done unit testing and I don’t find it a very useful concept" - Jonathan Blow
Offline K.I.L.E.R

Senior Member




Java games rock!


« Reply #1 - Posted 2005-02-21 05:36:07 »

Yes, and yes, as long as you enable a translucency flag.

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #2 - Posted 2005-02-22 03:16:34 »

For opengl pipeline, you don't have use the translucency flag to get accelerated alpha compositing (and it has no effect for the opengl pipeline).

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 20thCenturyBoy

Senior Member


Medals: 3


So much to learn, so little time.


« Reply #3 - Posted 2005-02-22 10:31:34 »

Well, here's a quick comparison between normal and opengl-enabled under 5.0 on my machine (AMD64 3000+, GeForce 6600GT):

Using "java ImageSpeedTest":

Opaque: 3970.6667 images/sec
Transparent: 50370.0 images/sec
Translucent: 300.66666 images/sec
Translucent (Anti-Aliased): 374.0 images/sec


Using "java -Dsun.java2d.opengl=True ImageSpeedTest":

OpenGL pipeline enabled for default config on screen 0
Opaque: 33.0033 images/sec
Transparent: 23219.334 images/sec
Translucent: 406.0 images/sec
Translucent (Anti-Aliased): 519.3333 images/sec

So opaque rendering is over 100 times slower with opengl and transparent is 50% slower.  Translucent is slightly better. The code is from Brackeen's book and simply spits sprites at the screen and counts the images/sec.

Are these strange figures or am I missing something? The opengl switch seems to slow down more than it speeds up!

"I have never done unit testing and I don’t find it a very useful concept" - Jonathan Blow
Offline f.l.x

Senior Member


Projects: 3


there is no place like 127.0.0.1


« Reply #4 - Posted 2005-02-22 11:43:39 »

First of all hello ^^ i've been lurking over here for long but this si my first post .

Well it hapens the same to me, with the opengl pipeline disabled my little rendering experiment in java2d runs at 50 - 33 fps, with opengl enabled it does at 0 fps (one if lucky) both on Winxp with a geforce 5200 suposed to support opengl

Litterarum radices amaras, fructus dulces
http://flx.proyectoanonimo.com
figth spam!
Offline Valodim

Junior Member




*sigh*


« Reply #5 - Posted 2005-02-22 14:02:09 »

same here.... well, looks like we've got something to look forward to in 6.0 Wink
Offline DrBizzar0

Junior Member




Raj raj!


« Reply #6 - Posted 2005-02-22 15:39:59 »

My impresion is that you on windows should use the directX based hardware acceleration instead of the openGL one.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #7 - Posted 2005-02-22 15:47:08 »

i thought java was supposed to be os independant  Grin

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline campbell

Junior Member




Java games rock!


« Reply #8 - Posted 2005-02-22 16:11:57 »

Quote

So opaque rendering is over 100 times slower with opengl and transparent is 50% slower.  Translucent is slightly better. The code is from Brackeen's book and simply spits sprites at the screen and counts the images/sec.

Are these strange figures or am I missing something? The opengl switch seems to slow down more than it speeds up!


There are a couple different issues contributing to the poor performance numbers you're seeing... First, it appears that we're having a problem (in our image management code) that makes us unable to cache the opaque.png, translucent.png, and antialiased.png images from David's testcase in hardware.  This means that we end up using software loops to copy the images to the screen, which explains why (in both the OGL and non-OGL cases) we're slow in the non-translucent cases.

The problem appears to be isolated to the old Toolkit image loaders (which ImageIcon uses currently).  If you modify his testcase to use ImageIO (or simply "new BufferedImage()"), you'll see that the numbers are much more reasonable.  In any case, I'll have to investigate this further.

Regarding the comparitively poor performance of the opaque case with OGL enabled... As I mentioned, due to the bug described above, we always copy the sysmem-based copy of the image to the destination (since we don't have a copy cached in VRAM).  There is a performance bug in Nvidia's OGL drivers for Windows that makes this case extremely slow, thus the low scores with OGL enabled.  Nvidia fixed this in their most recent Linux drivers  (6629), and the fix should also be included in their next Windows release as well.

So here again are the dangers of microbenchmarking.  Low scores in one case can lead people to believe that the whole pipeline is slow or broken, but that isn't the case.  I'm still hoping to post an article that shows how the performance of the OGL pipeline compares to our existing pipelines.  I'll let you know when that's up...

Also, we have some big changes to both our OGL and D3D pipelines coming soon to a Mustang build near you... So you should see those scores continue to improve in 6.0... We'll make an announcement when those changes are available in the early Mustang builds.

Chris
Offline campbell

Junior Member




Java games rock!


« Reply #9 - Posted 2005-02-22 20:17:03 »

Quote

The problem appears to be isolated to the old Toolkit image loaders (which ImageIcon uses currently).  If you modify his testcase to use ImageIO (or simply "new BufferedImage()"), you'll see that the numbers are much more reasonable.  In any case, I'll have to investigate this further.


For the record, I tracked down the problem and filed a new bug (6231864), which will show up on the Bug Parade by tomorrow.

Chris
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 20thCenturyBoy

Senior Member


Medals: 3


So much to learn, so little time.


« Reply #10 - Posted 2005-02-22 21:13:42 »

Interesting stuff Chris. I'll try BufferedImage today as well.


"I have never done unit testing and I don’t find it a very useful concept" - Jonathan Blow
Offline f.l.x

Senior Member


Projects: 3


there is no place like 127.0.0.1


« Reply #11 - Posted 2005-02-22 22:16:46 »

I'll stay tuned. thanks for the detailed reply  Grin

Litterarum radices amaras, fructus dulces
http://flx.proyectoanonimo.com
figth spam!
Offline 20thCenturyBoy

Senior Member


Medals: 3


So much to learn, so little time.


« Reply #12 - Posted 2005-02-23 12:21:35 »

Ok, just out of interest I used BufferedImages instead of Images in the test program, these are the results:

OpenGL/BufferedImage:

Opaque: 20784.666 images/sec
Transparent: 24412.666 images/sec
Translucent: 18764.0 images/sec
Translucent (Anti-Aliased): 23033.334 images/sec

non-OpenGL/BufferedImage:

Opaque: 38738.668 images/sec
Transparent: 50322.0 images/sec
Translucent: 50.666668 images/sec
Translucent (Anti-Aliased): 51.451187 images/sec

So we have much better translucent performance with OpenGL/BufferedImage than with OpenGL/Image. However OpenGL/BufferedImage is still slower than non-OpenGL/BufferedImage for opaque and transparent images in this particular test.

I know I shouldn't microbenchmark, but I just can't resist!


"I have never done unit testing and I don’t find it a very useful concept" - Jonathan Blow
Offline Valodim

Junior Member




*sigh*


« Reply #13 - Posted 2005-02-23 18:38:57 »

why are anti-aliased translucent images faster than non-anti-aliased ones? o_O
Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #14 - Posted 2005-03-05 12:12:40 »

because AA images are not accerlated ;-)
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!