UIWindow/GUI Performance

I’ve built a very small GUI to go over the top of martian madness, you can see it here…

http://www.newdawnsoftware.com/martian/screenshots/191103_1.gif

The GUI is currently static, which I assume mean textures are generated for the polys once at the start then its just a matter of drawing quads with those texture. My GUI is currently built out of 8 JPanels, each of which has a UIWindow. So I’d assumed (I assume alot) that this was going to be 16 triangles textured and placed in the right place…

However, I lost 100 FPS from the addition. I’ve made it possible to toggle the GUI on and off (with TAB for those who try out the demo) and using this you can see the significant drop.

  1. Is this the expected sort of drop?
  2. If not,
    a) Am I assuming something wrong and could design my GUI in a better way.
    b) Are there plans for improving the peformance of the GUI.

Any help/suggestions appreciated,

Kev

PS. That appearance bug is still hanging around :wink:

Right now because we do not yet support sub-texture update we break the overlay into very small peices. That way when the dirty region list is found we only have to update a couple of the textures. This is not optimal because it means a lot of additional shapes. That being said, your frame rate drop does seem extreme. Are you repainting your component on every frame?

When I do get sub-texture working then we can fall back to the way the overlay is supposed to work, which is to calculate an optimal set of power of 2 size textures to map the window into.

Ah ha, thats probably it since I have a bunch of sizable windows.

But no, I’m not actually repainting every frame. In fact at the moment the GUI is pretty static and should only get repainted at initialisation.

Kev

I have committed an update to the gui that should resolve your performance issues.

Coo! Performance is well up!

However, I’m getting some slight artifacts that I didn’t have before. Almost like the image is being copied to the texture 1 pixel up from where it should be.

Kev

Again, I made a small change and things came back into line. Don’t think its the correct fix but might help in finding the actual problem…

Change in UISubOverlayOptimized.java


protected void update(BufferedImage fullImage, Rectangle updateRect) {

        dirty = true;
        Rectangle r = updateRect.intersection(bounds);
        Graphics g = a.getGraphics();

        int destLX = r.x-bounds.x;
        int destLY = height-(r.y-bounds.y)-r.height;
//        int destLY = r.y-bounds.y;
        int destUX = destLX + r.width;
        int destUY = destLY + r.height;

        // updated to move the rectangle we're copying from
        // up one pixel
        r.y -= 1;
        
        int srcLX = r.x;
        int srcUY = r.y;
        int srcUX = r.x + r.width;
        int srcLY = r.y + r.height;

Thanks for the peforamance increase! I’m getting like 200 fps more than I was getting before. Superb!

Kev

Thanks for the fix! Do you know that one routine took me 2 hours to write? Funny how some things just bring you to a standstill for no good reason.

Hi
Thanks for both fixes Mr Yazel and Kev, the UI performance is much much much nicer :).

Endolf

Hi
I’ve just checked cvs, and it looks like kevs fix hasn’t made it in, any chance of someone doing this for us?

Cheers

Endolf