Author Topic: multi texture objects & Texture.keepPixelData(..)  (Read 5400 times)

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
multi texture objects & Texture.keepPixelData(..)
« on: August 10, 2010, 02:32:54 pm »
say, i have multi texture object, for example a merged one. when GL surface is recreated textures are gone. in order to restore the object's state, calling Texture.keepPixelData(true) is the only way, right? otherwise, i can't load textures again and call setTexture on the object, because it's a multi texture object.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #1 on: August 10, 2010, 02:53:04 pm »
Or create/load everything from scratch...or simply exit the game on pause and stop, which is what i'm going to do... ;D

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #2 on: August 10, 2010, 02:57:59 pm »
the ability to pause the game seems valuable to me. for example when a call arrives. but cost a bit memory.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #3 on: August 10, 2010, 03:06:46 pm »
It has another drawback as well: Vertex arrays are save, but VBOs are bound to the gl context. If that changes, the code that renders the geometry will detect that (hopefully) and revert to plain vertex arrays (there should be a log message telling so). At least the current version can't recover back to use VBOs after destroying the gl context.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #4 on: August 10, 2010, 04:54:14 pm »
It has another drawback as well: Vertex arrays are save, but VBOs are bound to the gl context. If that changes, the code that renders the geometry will detect that (hopefully) and revert to plain vertex arrays (there should be a log message telling so). At least the current version can't recover back to use VBOs after destroying the gl context.
I've uploaded a jar that might be able to handle this...i'm not sure, i have no test case...

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #5 on: August 10, 2010, 05:14:12 pm »
cool ;D i'll give it a try soon

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #6 on: August 11, 2010, 01:39:53 am »
I've uploaded a jar that might be able to handle this...i'm not sure, i have no test case...

what should i look for in logs? it seems to work ok. at least there is no problem. the surface gets recreated and everything seems in place.

note: on my phone, a certain way to get surface recreated is to make phone sleep and wake up again


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #7 on: August 11, 2010, 07:01:16 am »
It should read something like "context changed...trying to recover" or similar. But that only happens if VBOs are enabled in Config anyway.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #8 on: August 11, 2010, 02:30:51 pm »
well, it tries to recover but never finishes it. recreates VBO's for same objects again and again..

Code: [Select]
I/jPCT-AE (14505): [ 1281529704748 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14505): VBO created for object 'object4'
I/jPCT-AE (14505): [ 1281529704765 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14505): VBO created for object 'object4'
I/jPCT-AE (14505): [ 1281529704780 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14505): VBO created for object 'GeoSphere0_jPCT3'
I/jPCT-AE (14505): [ 1281529704794 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14505): VBO created for object 'object6'
I/jPCT-AE (14505): [ 1281529704822 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14505): VBO created for object 'object4'
I/jPCT-AE (14505): [ 1281529704855 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14505): VBO created for object 'object4'
...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #9 on: August 11, 2010, 02:59:44 pm »
I must have done something stupid then...i'll look at it.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #10 on: August 11, 2010, 03:19:22 pm »
about the comment in javadoc for Config.useVBO
Quote
Makes the engine use vertex buffer objects if possible instead of plain vertex arrays. This may be faster on some hardware. On Samsung Galaxy, it isn't and i can't help but think that causes a crash now and then...which is why it defaults to false.

i didn't noticed any performance difference on N1 neither any crashes. indeed, on N1 i never experienced a crash in native code. on G1 it was happening quite often

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #11 on: August 11, 2010, 09:15:19 pm »
about the comment in javadoc for Config.useVBO
Quote
Makes the engine use vertex buffer objects if possible instead of plain vertex arrays. This may be faster on some hardware. On Samsung Galaxy, it isn't and i can't help but think that causes a crash now and then...which is why it defaults to false.

i didn't noticed any performance difference on N1 neither any crashes. indeed, on N1 i never experienced a crash in native code. on G1 it was happening quite often
I've uploaded a new jar which fixes at least some of the stupid things that i made when trying to recover. Please give it a try.
About the VBO stuff: It actually is faster on N1 at least when judging from the numbers that An3DBench returns. However, it's not used for animated objects or objects with an IVertexController attached anyway, because the VBO simply doesn't update even when created with GL11.GL_DYNAMIC_DRAW...at least not on my phone.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #12 on: August 11, 2010, 09:25:01 pm »
it still reports a few recovers for same object but does not last forever. maybe that recovers are for different compiled instances ? other than that everything seems fine ;D thanks..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #13 on: August 11, 2010, 09:29:44 pm »
Can you post the log output, please? It might be fine, i just want to be sure...

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #14 on: August 11, 2010, 09:32:26 pm »
Code: [Select]
I/jPCT-AE (14867): [ 1281554470189 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14867): VBO created for object 'object11'
I/jPCT-AE (14867): [ 1281554470282 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14867): VBO created for object 'object11'
I/jPCT-AE (14867): [ 1281554470288 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14867): VBO created for object 'object11'
I/jPCT-AE (14867): [ 1281554470311 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14867): VBO created for object 'GeoSphere0_jPCT10'
I/jPCT-AE (14867): [ 1281554470332 ] - WARNING: OpenGL context has changed...trying to recover...
I/jPCT-AE (14867): VBO created for object 'object13'