OpenGL RTT texture optimization problem!..

Discussion in 'Game Development (Technical)' started by Jamie W, Mar 31, 2011.

  1. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    Hello,

    I'm doing some optimizations on iPhone, that involve rendering several layers in to a composite tile map texture (I do this on setup). During the game, I then render tiles from this texture to the screen. Basically render-to-texture, to build up composite tiles, then render those to screen.

    I'm thinking that my RTT texture, should be 16 bits per pixel; and that this will be faster (compared to a 32 bits per pixel texture) to render to the screen, during play.

    It's all working fine now; but when I use 16 bits per pixel, I'm getting some slight artifacts on old (original) iPhones. Maybe my code is a bit dodgy..

    Here is the relevant bit of code; where I generate the textures:

    // 32BPP texture (I think)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

    // 16BPP texture (I think)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, NULL);

    Using 32BPP textures, works fine; but the 16BPP texture, would I think be ideal (less memory use, faster to bilt), but looks slightly odd on original iPhones.

    Is GL_UNSIGNED_SHORT_5_5_5_1 appropriate to use here; and should that result in a 16BPP texture?

    Thanks,
     
  2. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,734
    Likes Received:
    0
    I'll double check the GL usage syntax when I get home... But if I were you I would test to verify that 16bbp is actually faster, because my guess would be that it isn't. Also, compositing in 16bit could destroy your color resolution in various multipass arrangements. I wouldn't recommend this path unless you really need the memory savings (and even in that case, you'll need to verify that the driver isn't using a 32bit buffer behind your back; storage format is NOT guaranteed IIRC, it's just a hint).

    EDIT: Your usage looks correct. You might want to ensure that GL_UNSIGNED_SHORT_5_5_5_1 is actually supported by that GL driver (if it isn't supported, you can also try GL_EXT_packed_pixels which provides the same functionality). Or just use 32bit :p
     
    #2 vjvj, Apr 8, 2011
    Last edited: Apr 8, 2011
  3. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    Thanks Peter; just digging right now ... testing the app on various devices, getting some interesting results (all using 16bpp composite RTT):

    Getting artifacts on the following hardware: iPhone (original, old one) & iPod Touch 2nd Gen.

    While the same app, works fine on: iPad & iPod Touch 4th Gen.

    I'm assuming the OpenGL driver is part of iOS, so it's more dependent on which version of iOS a device is running; rather than which model (age) of device itself etc. I don't know that for sure though!
     
  4. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,734
    Likes Received:
    0
    I'm not 100% sure either, but I'd bet a few beers that you're right about this ;) IIRC the graphics driver is fixed for each iOS release/update. iPhone 1 is going a ways back, so you might just running into some obscure PVR driver bug here.
     
  5. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    Yeah, if that's the case; could be an idea to detect which version of iOS, then use 16bpp or 32bpp RTT accordingly. I guess I could do some tests, putting diff versions of iOS on same device; and see what kind of results I get using 16bpp.

    Doesn't seem straight forward how to test the speed of stuff on iPhone; in the Amiga and ST days, you could just run at 60hz, and set the colour for palette entry 0, and there was an immediate visual indication of how much time you're taking for update and render each loop. Struggling to do that kinda thing on iPhone. Real curious to know if the 16bpp thing actualy is faster than 32bpp.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer