4

In follow-up to my previous questions (especially this one : Java : VolatileImage slower than BufferedImage), i have noticed that simply drawing an Image (it doesn't matter if it's buffered or volatile, since the computer has no accelerated memory*, and tests shows it's doesn't change anything), tends to be very long.

(*) System.out.println(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getAvailableAcceleratedMemory()); --> 0

How long ? For a 500x400 image, about 0.04 seconds. This is only drawing the image on the backbuffer (obtained via buffer strategy).

Now considering that world of warcraft runs on that netbook (tough it is quite laggy) and that online java games seems to have no problem whatsoever, this is quite thought provoking.

I'm quite certain I didn't miss something obvious, I've searched extensively the web, but nothing will do. So do any of you java whiz have an idea of what obscure problem might be causing this (or maybe it is normal, tough I doubt it) ?

PS : As I'm writing this I realized this might be cause by my Linux installation (archlinux) tough I have the correct Intel driver. But my computer normally has "Integrated Intel Graphics Media Accelerator 950", which would mean it should have accelerated video memory somehow. Any ideas about this side of things ?

Community
  • 1
  • 1
Norswap
  • 11,740
  • 12
  • 47
  • 60
  • If you edit your question, you can use the code formatting around your code, which would be helpful. – justkt Apr 30 '10 at 17:12
  • 1
    Created a "compatible" buffer? – Tom Hawtin - tackline Apr 30 '10 at 17:42
  • Why don't you post your SSCCE: http://sscce.org. Then maybe people will test it on other environments. We have no idea what you actual code is like and if you are doing anything wrong. I always questions why people use a BufferStrategy. Swing is double buffered and it reduces the complexity of the coding. – camickr Apr 30 '10 at 18:23
  • @ Tom Hawtin : Yup || @ camickr : I draw on a Canvas, which is not swing. Also in a game, you obviously want to disable the auto swing refresh anyway. As for the SSCCE, the point is moot because basically, you create the simplest of simplest win and compatible image (using GraphicsDevice and stuff), then draw it and it's still slow. For comparison, it runs about 50 times faster on a top-notch Windows computer, and about 10 times faster on another netbook (with Intel Graphics Media Accelerator 3150). – Norswap Apr 30 '10 at 20:14
  • The other netbook - what OS does it run? See my edited answer. – Chris May 03 '10 at 03:11
  • Today I learned that `hell` is a unit of time measuring 0.04 seconds. I will commence usage of this term when I wish to denote small amounts of time. – rockerest Mar 04 '12 at 09:29

2 Answers2

2

I'm also running Arch Linux and noticed my games going slow sometimes, especially when using alpha transparencies with my images. It turns out that even Windows, not only Linux sometimes turns off hardware acceleration by default.

I looked for a solution to the problem and found this: http://web.archive.org/web/20120926022918/http://www.systemparadox.co.uk/node/29

Enabling OpenGL considerably sped up my framerates, and I assume if you ran your tests again, you'd get faster draws.

Dennis
  • 597
  • 4
  • 8
  • 24
  • I can't really confirm, as the test configuration in question was trashed some time ago. But I'll accept this in hopes it can help others. – Norswap Mar 04 '12 at 10:57
1

I don't know much about java graphics, but if I were in your shoes, I would assume that the measurement means nothing without a comparison value, which it sounds like you might have but are not sharing. Add this information to your question, along with the specs of the comparison system (is it a desktop? does it have a dedicated video card? does it run windows or linux?).


Concerning your measurement that it's 10 times faster on another netbook, does that other notebook run Windows, or is that one also Linux? Linux has historically had very mediocre graphics drivers - they just don't run nearly as well as the Windows equivalents. In fact for a long time the only drivers you could get were not written by ATI/nVidia/etc., but rather by hobbyists. It would not surprise me at all if a Linux machine ran a graphical program ten times slower than a similar machine running Windows.

This was the situation as I understood it about five years ago. I doubt it's changed much.

Chris
  • 3,400
  • 1
  • 27
  • 41
  • 1
    We can do some calculations. 500x400/0.04 is 5,000,000 pixel/second. That is going to be a read and a write of presumably 32 bits each. I'd be disappointed if a twenty year old (non-PC) desktop couldn't manage that. – Tom Hawtin - tackline Apr 30 '10 at 17:44
  • What about looking at existing games which use complex Java2D operations? I'd recommend the stuff on http://goldenstudios.or.id/products/games/index.php as perhaps a benchmark :) – Chris Dennett Apr 30 '10 at 17:57
  • @Chris : See my answer to camickr above for comparison values. || @Tom : My own calculations told me the same :) || @Chris : I looked it up some time ago, but there seems to be no magic trick of the sort I seek there. Actually I'm now about 99% the fault is in the OS camp. I have opened a thread on the archlinux forums, with no success so far. – Norswap Apr 30 '10 at 20:19
  • Ubuntu Netbook Edition, 9.10 (Karmic Koala) I think. Btw, Intel makes quality open source driver, which support graphical acceleration. I've looked around and found no one who had comparable problems - it definitely seems to be my system, because glxgears (a linux 3D benchmark) gives me 60fps, which is really low (people with my netbook usually report about 300-400). I have found one or two things to try, but I highly doubt they'll work :s – Norswap May 03 '10 at 19:20