@Neurofuzzy, performance issues?
  • oztuneoztune September 2011
    Posts: 177
    Hey,

    I saw you mentioned Pixelwave having some performance issues on Twitter. I'd really appreciate it if you gave me some details so I can look into it. We've put a lot of effort into optimizing it so if something is running slowly I'd really like to fix it.

    Thanks,
    Oz
    Pixelwave team
    // Founder
  • neurofuzzyneurofuzzy September 2011
    Posts: 11

    Well, first of all let me say that PixelWave is pretty darn fast. I may just be doing something wrong. 


    1. You saw my thread about touch response and high frame rates. This only occurs under high graphic load at 60fps. I'm dragging a sprite for use on a Joypad control. If there's high load, there seems to be a delay and a latency in touch events. They kind of chug along.

    2. I am using colored rectangles to draw my background and all moving sprites (for testing) using the graphics API. This may be slower than the SPQuad I'm using with Sparrow. Also, In Sparrow, I'm using an SPRenderTexture to "collapse" the background to a single texture, whereby in PixelWave I just did multiple graphics.drawRect calls in a single sprite. I'm thinking this is slower, because the more rects I draw in the single sprite, the slower it gets. It appears the PixelWave must be redrawing the graphics on every frame instead of treating it as a texture. Is there a way to do the equivalent of cacheAsBitmap?
  • BekennBekenn September 2011
    Posts: 53

    Use PXTextureData:

    PXTextureData* cachedData = [[[PXTextureData alloc] initWithWidth: w height: h transparency: YES fillColor: 0] autorelease];
    [cachedData drawDisplayObject: obj];
    PXTexture* cachedImage = [PXTexture textureWithTextureData: cachedData];

    drawRect is really intended for objects whose contents are expected to change often (perhaps even every frame).

  • neurofuzzyneurofuzzy September 2011
    Posts: 11

    Okay, If replaced everything in my game with textures.


    Moving Sprites are Textures with 32x32 initted TextureDatas with color.

    Background is a single Texture as well.

    It's actually slower. I think it's because I'm creating a lot of separate textures for the moving sprites as opposed to a single texture atlas. Mind you I've got no 'real' graphics now.. just boxes moving around the screen.

    I'm curious to know if there's an equivalent of Sparrow's SPQuad?  It's simply a couple of triangles with color assigned to the vertices. If there was an equivalent in PixelWave, I could test apples to apples. :) 
  • neurofuzzyneurofuzzy September 2011
    Posts: 11
    Did a quick time profile, and yes, I think I must be zigging when I should be zagging. Almost all the time is spent on rendering.

    Running (Self) Symbol Name
    17886.0ms   94.9%                   PXEngineRenderDisplayObject
    17877.0ms   94.8%                    -[PXTexture _renderGL]
    17862.0ms   94.7%                     PXGLBindTexture
    17862.0ms   94.7%                      PXGLFlushBuffer
    17862.0ms   94.7%                       PXGLFlushBufferToGL
    17861.0ms   94.7%                        glDrawArrays
    17861.0ms   94.7%                         glDrawArrays_IMM_Exec
    17843.0ms   94.6%                          gleDrawArraysOrElements_ExecCore
    13176.0ms   69.9%                           gleFlushTriQuadStripFunc
    13158.0ms   69.8%                            0xb980612
    13158.0ms   69.8%                             gldRenderFillPolygonPtr
    12798.0ms   67.9%                              0xb9815b8

    Here's my display list:

    -(PXSprite *)root
        |
        -(PXsprite *)container
           -(PXsprite *)background 
               -(PXTexture *)background image (640 x 480)
           -(PXsprite *)objects (container for moving sprites)
               -(PXTexture *)game object (32x32)
                ... more game objects (30 of them)
        |
        -(PXsprite *)controls (child of root!)
            -(PXsprite *)joypad
            -(PXsprite *)buttonA
            -(PXsprite *)buttonB

    I hope that gives a better idea of what is going on.

  • oztuneoztune September 2011
    Posts: 177

    Hmm, are you creating a different PXTextureData for each object on screen? That could cost you the performance. You could instead have all the PXTexture objects share a single PXTextureData


    To draw a simple quad you can use PXShape. Here's how you can make a colored rectangle:
    PXShape *shape = [[PXShape alloc] init];
    [shape.graphics beginFill:0x00FF00 alpha:1.0f];
    [shape.graphics drawRectWithX:0 y:0 width:100.0f height:100.0f];
    
    Pixelwave team
    // Founder
  • neurofuzzyneurofuzzy September 2011
    Posts: 11

    Well, actually, I was using PXSprites with the same code you have there using [sprite.graphics drawRectWithX:y:width:height:] and it was chugging. So, I just switched to PXTexture to test and it was slower.


    I just switched to using PXShape for everything except the background, which is a PXTexture. It's about the same speed as using PXSprite.. maybe a tiny bit faster.

    I may post a video showing the difference in speed I'm getting between Sparrow and PixelWave. Still fiddling with it.
  • neurofuzzyneurofuzzy September 2011
    Posts: 11

    Here's a couple of videos demonstrating the differences in performance I'm seeing between PixelWave and Sparrow using the same game code. It may be a little hard to see on a 30fps video.


    Notice the annotation when I drag my finger on the left side around 50 seconds into the PixelWave video.
  • oztuneoztune September 2011
    Posts: 177

    Yeah, I definitely see the difference. Seems really odd. The touch performance is so laggy (I've done more complex things with it and haven't seen it go this slow) that I have to assume something is really wrong. Just not sure what.


    I tried replicating the issue and I can't seem to do it. Check out this project: http://www.pixelwave.org/temp/TouchResp.zip

    It renders 1000 quads on the screen at around 70fps on my iPhone 4, and the dragging seems smooth when the quads are visible or not.

    Let me know if that code helps at all. If not John or I would be glad to look at the actual code and debug it that way (not sure how you feel about sending the code over, but you can email it to me at oz at pixelwave.org).
    Pixelwave team
    // Founder
  • neurofuzzyneurofuzzy September 2011
    Posts: 11
    Thanks for putting together this example!

    On my iPod Touch 2G, I get around 9 fps with the quads visible. The dragging is just as laggy as mine.

    Without the quads, I get 100fps and the dragging is smooth.

    Maybe the iPod 2g is just too wimpy to handle it. :(


  • oztuneoztune October 2011
    Posts: 177

    Well that kind of makes sense if the total framerate is 9 the dragging would lag.

    In your project, what kind of framerate are you getting with Pixelwave? If you're getting a good total framerate there's really no good reason for the touch to lag...
    Pixelwave team
    // Founder

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter Sign In with OpenID

Sign In Apply for Membership

In this Discussion

Tagged

Top Posters