Context changed

Started by Thomas., March 14, 2013, 01:39:57 PM

Previous topic - Next topic

Thomas.

Is really needed upload all textures and compile shaders again after context changed? Many games from play store are running immediately after I back into game. And please, could you compile default shaders only when are needed, or maybe when is called FrameBuffer.compileDefaultShaders() or GLSLShader.compile()? Compilation of default shaders take on lower devices almost 2 seconds and I do not use any of them.

EgonOlsen

#1
Yes, it's needed. There's nothing else i could do. If the context is lost, the data is lost. IF the context is actually lost, is another question. If you are sure that it's not lost, don't create a new FrameBuffer instance. However, we already had some problems with that kind of "optimization", so personally, i would live with the time it takes to upload the stuff again and be sure that it runs on different devices and different Android versions.

About the shaders...you are using at least one of them if you are using blitting. I'm not going to make this fully optional ATM, but i'll look into some Config hack to avoid using them altogether, if one doesn't want them.

EgonOlsen

I've updated the beta jar with a version that adds a switch to Config. Set Config.skipDefaultShaders=true; and only two default shaders will be compiled. If you are using any other, it will print out a warning message and uses the generic default instead, which will be slower.

Thomas.

Thanks ;) I added code to prevent lost GL content, so app is back instantly.

EgonOlsen

...nut be prepared that this might not work on all devices...

Thomas.

If will be lost, be loaded again, I hope...

raft

Quote from: EgonOlsen on March 14, 2013, 11:41:00 PM
...nut be prepared that this might not work on all devices...
Why is that? I'm also curious about this. Isnt there any reliable way of detecting if context is lost or not?

If even not, if system throws a specific or distinguishable exception when trying to access a lost context, that can be caught and a new context might be created, right?

EgonOlsen

In theory, yes. But i remember one case (from a user, not experienced this myself) where the gl instance remained the same but the data was lost anyway. Treating the "old" context as a new one solved the issue.