FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable

2 posters

Go down

[Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable Empty [Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable

Post  uprise78 Fri May 08, 2009 12:39 pm

I was doing a bit of testing with one of the tutorials and found that glBindTexture is a VERY expensive call on the iPhone. Would it be possible to modify sio2Image to check to see if the texture it is binding is not the currently bound texture?

sio2ImageRender could just be modified with something simple like:

Code:

if( sio2->currentTid != _SIO2image->tid )
{
    glBindTexture( GL_TEXTURE_2D, _SIO2image->tid );
    sio2->currentTid = _SIO2image->tid;
}

This strategy could also apply to all the glEnable calls with the current state being maintained in the sio2 struct to avoid unnecessary calls to glIsEnabled and glEnable.

I would like to make these changes in the version of SIO2 that I am using but I don't want to modify any of the SIO2 source so that I don't make my upgrade path difficult. These are some pretty easy changes that get a surprisingly large benefit on the iPhone from my testing.

uprise78

Posts : 228
Join date : 2008-10-31

Back to top Go down

[Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable Empty Re: [Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable

Post  sio2interactive Fri May 08, 2009 4:55 pm

I would suggest you to use a texture atlas, and create 1 material that is applied to all the necessary object...

So basically:

1. Material containing the atlas.
2. The material is applied on ALL objects that have a texture within the atlas.
3. When SIO2 is going to render is going to check for the last material.

The idea is to create ONE material per texture and apply it on as much object as you can... there's ALOT more state changes by rendering the material than the texture... You should really go with this approach.

Also, by default all objects are sorted alphabetically within the SIO2 file... you can tweak the name of your object to fit with the material that you are using. This will help SIO2 to perform better.

ex:

Material -> Wood -> Wood.jpg

w_Bench
w_Chair
w_Table

In this example its pretty much sure that when you see the table you'll see the Bench and the Chair by regrouping them alphabetically based on their material you avoid SIO2 to bind the material multiple times and since the material is the most heavy thing to bind in SIO2 well... I think you start getting it by now Wink
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

[Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable Empty Re: [Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable

Post  uprise78 Fri May 08, 2009 5:10 pm

Ahhhh...that will work just fine SIO2. Thanks for the alphabetical tip.

How about the glIsEnabled/glEnabled calls? They could all easily be wrapped up in an sio2GlEnbable() function that keeps it's own state to avoid state changes and gl queries when not necessary.

uprise78

Posts : 228
Join date : 2008-10-31

Back to top Go down

[Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable Empty Re: [Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable

Post  sio2interactive Fri May 08, 2009 5:16 pm

Yes... but Im not sure that the performance gain will be tremendous... I had this in mind for a while but I never implement it...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

[Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable Empty Re: [Request] Dont Call glBindTexture Unless Necessary ... and glIsEnabled/glEnable

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum