Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (498)
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  
  drawImage performance weirdness - [EDIT: small images]  (Read 1224 times)
0 Members and 1 Guest are viewing this topic.
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Posted 2005-09-14 02:27:19 »

My computer is capable of rendering a certain 800x600 image to the screen approximately 650 times per second. Now, if I render an image of size 253x253 I get framerates of 4300(!), which is reasonably close to the same time per pixel. But if I resize that Image to 252x252, the framerate drops to about 250, then increases to about 400 in about 20 seconds. Apparently only images that are sufficiently large are accelerated. Does anyone know what is going on here?

Images created with GraphicsConfiguration.createCompatibleImage(int,int,int). No pipeline is enabled. No FSEM mode. Rendering done on Canvas with bufferStrategy(2).

Using: Linux, 1200 MHz AMD Duron, GeForce440MX, JRE 1.5.0_b05.

Feel free to ask for further information if it may shed light on something. Sorry about the heavy editing of this post if you just viewed it, but I thought I might as well update it completely based on recent results.

EDIT: Clarification - when I said "resize" above, I meant selecting another size at compile-time.
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #1 - Posted 2005-09-14 17:10:08 »

I have found a workaround.

The following method
1  
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) 

of java.awt.Graphics is able to draw parts of images. Rendering a "small" part of a "large" image will still be fast, as long as no rescaling is done (in which case rendering would probably still be fast).
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #2 - Posted 2005-09-15 00:04:00 »

Which type of image? Transparent, translucent or opaque?

Dmitri
Java2D Team
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #3 - Posted 2005-09-15 00:46:15 »

The image is opaque.

I tried to reproduce the problem in windows, without success. Nothing seems to happen with the framerate when I render small images. On the other hand, I get a maximum framerate of 1300 in windows, where in linux I can sometimes obtain more than 4000 fps. I guess I'll have to experiment a bit more with this.
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #4 - Posted 2005-09-15 23:14:35 »

Note that unless you do Toolkit.getDefaultToolkit.sync() after you
rendered the images (at the end of each frame, for example) you're measuring the speed at
which we can issue X11 calls,  which is not what you  want to measure.

X11 just queues those requests and does nothing. The sync() makes it
to flush the queue and process the requests - that is, to actually render the images.

Dmitri
Java2D Team



Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #5 - Posted 2005-10-04 02:36:43 »

Okay, sync() didn't seem to make any difference. Am I doing something wrong? Anyway, under windows the problem is not present, but the performance is not very high either. In linux, the performance is very good, but when the images are smaller than that value, performance drops tremendously.

I tried to run a tile-based game under windows and linux, and the performance on linux was extremely low, around 10 fps when it should easily output several hundred. As mentiond above I could increase performance by simply rendering *parts* of images, but this makes for highly ugly code. I just wonder whether the huge performance difference when rendering small images is because of the driver or Java2D.

Thanks for the help anyway.
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.

xsi3rr4x (15 views)
2014-04-15 18:08:23

BurntPizza (13 views)
2014-04-15 03:46:01

UprightPath (27 views)
2014-04-14 17:39:50

UprightPath (12 views)
2014-04-14 17:35:47

Porlus (29 views)
2014-04-14 15:48:38

tom_mai78101 (51 views)
2014-04-10 04:04:31

BurntPizza (110 views)
2014-04-08 23:06:04

tom_mai78101 (211 views)
2014-04-05 13:34:39

trollwarrior1 (179 views)
2014-04-04 12:06:45

CJLetsGame (185 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!