1.5 accelerated images are dodgy

No matter what I do my buffered images are not accelerated.

Here is how I get my information:

System.out.println( img.getCapabilities(img.createGraphics().getDeviceConfiguration()).isAccelerated() );

It returns false.

167fps when I display one image on the screen. 2500fps without any images on screen.

I’ve tried at least 3-5 methods of creating the images, none of them are accelerated.

I’ve read several articles explaining that creating a BI from a constructor makes it a managed image.

BufferedImage b = ImageIO.read(new File(szI));
img = new BufferedImage( b.getWidth(), b.getHeight(), BufferedImage.TYPE_INT_ARGB );

Here is my code and it is not accelerated like it is said to be.
Given that the code will not display the intended image but that can be fixed.

My problem is that managed images don’t work as advertised.

I didn’t think BIs were ever accelerated.

Cas :slight_smile:

[quote]I didn’t think BIs were ever accelerated.

Cas :slight_smile:
[/quote]
They are in 1.5 according to docs.

Where does it say that? I thought the deal was that they’d “try their damndest to accelerate managed images”.

Also I was under the impression that ImageIO.read() was going to attempt to return already accelerated images (which presumably would be a special subclass of buffered image or something?)

What you’ve done is copied (well not yet) the return of ImageIO into a new buffered image. I’d hope we still have the ability to create a BufferedImage that isn’t accelerated (I might not want to use video mem up!) and hence the default constructor would create a non-accelerated image.

Could you point me in the direction of the articles and documentation you mention?

Kev

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

You’re using ARGB format which I seem to recall requires a special flag to accelerate (transAccel or something like that).

Cas :slight_smile:

I’m using it:
System.setProperty( “sun.java2d.translaccel”, “true” );

You also need:
System.setProperty(“sun.java2d.accthreshold”, “0”);

if you want to have it accelerated asap (and not after some drawing… that getting accelerated is somewhat “lazy” in order to prevent temporary junk images from getting accelerated).

And there’s also:
System.setProperty(“sun.java2d.ddforcevram”, “true”);

Neither setting changes my frame rate.
They are enabled by default anyhow.

Here’s something I just discovered. When I start Rimscape fullscreen, the opening sequence has these results:

with:
System.setProperty(“sun.java2d.accthreshold”, “0”);
FPS = 20

with
System.setProperty(“sun.java2d.accthreshold”, “1”);
FPS = 110

Pretty big difference :wink: I think the culprit is my AffineTransform rotating all the ships and projectiles and such flying around, and every time it creates one, it tries to put it into VRAM, which is stupid because that particular rotation will never be drawn again, and even if it is, I doubt it’s smart enough to reuse it. Try messing with that!

EDIT: Just tried this test in Windowed mode:
with:
System.setProperty(“sun.java2d.accthreshold”, “0”);
FPS = 80-86

with
System.setProperty(“sun.java2d.accthreshold”, “1”);
FPS = 100-110

Transformations are not accelerated in 1.5 (unless you’re using the opengl pipeline). So if you’re rendering an image using a transform (other than translation), the operation will be done by the software loops.

yeah, so the improvement I found was a result of not forcing the game to move everything to VRAM upon creation only to pull it right back out in order to do the software transformation. Instead I just never put it in VRAM since it doesn’t help.

Instead I just never put it in VRAM since it doesn’t help

You do. But not asap (and temporary “junk” images won’t end up there too).

Well whatever is happening, it’s much much faster now :slight_smile:

I’ve done both. No change in performance.

C#.NET seems to accelerate images nicely. Why can’t Java?

I have no trouble at all getting accelerated BI:s on my setup (1.5). Might it be the Gfx card, drivers, settings in windows or something else that is in your way.

I use ATI cards, all kinds, dual screen and all. big res. No trouble. Though the PNG images from ImageIO is about 8x slower than unaccelerated (yes) ones. That is because of some transparency data incompatibility or something. They know about it anyway, so it will be a problem no more soon. :slight_smile:

Cheers,
Mikael Grev

Why can’t Java?

How should we know?

Well, you can try BufferedImage.TRANSLUCENT instead.

like…

GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage bi = gc.createCompatibleImage(w,h,Transparency.TRANSLUCENT);
Graphics2D g2d = (Graphics2D)bi.getGraphics();
g2d.setComposite(AlphaComposite.Src);
copy… dispose… yadda yadda (you wont need all this with 1.5)

If all fails do a (simple) test case.

Sorry for upsetting you but when you are working on something for hours and come to a problem which takes much longer than needed it tends to frustrate people.

Mikael Grev, I have an Ati Radeon 9700 Pro with an A64 3000+ and 1GB DDR400 RAM and an NForce 3 mobo.

Sorry for upsetting you

You didn’t :slight_smile:

It’s just… we can’t know why it isn’t working, because we don’t have something specific to look at (a small test case).

For example Cas suggested to set the transaccel flag to true and you said then that you already did that. Y’know… it kinda leads to a thread with 10 pages and no answer :wink:

If you want to get the answer you’re looking for asap you should tell everything which is relevant in this order:
-what you want to do (the “goal”)
-what you tried (the “way” - in detail [simple sample case preferred])
-what happened and what you’ve expected
-additional “bonus points”/related/random questions here

This way the reader can see what you want to do, how you tried to do it and what didn’t worked. Thanks to that order he/she will be able pretty fast if he/she might be able to answer the question, because it’s explained at the beginning. Reading across that part, which explains how you tried it, allows the reader to check common pitfalls and the like. And at the end there is a kind of summary, which can be used for comparison.

Trust me… you’ll get a usable answer faster this way :wink:

Have you got the latest driver for the Gfx card?
Installed DirectX 9?
Check that you have full acceleration in windows turned on.
run “dxdiag” and check if windows reports any problems.

Cheers,
Mikael Grev