on Google Nexus 5 mobile phone , the first call "RenderOneFrame" will take about 500ms , if modify "handleSchemeNotFound" to an empty function, the first "renderOneFrame" become fast , but nothing can be rendered on screen .
could somebody give me some suggestion on how to optimize the app start up time , how to resolve this "handleSchemeNotFound " error ? and will shader cache be help on android ? thanks !
in my app , i create all materials from code, and initialize the ShaderGenerator as following :
Code: Select all
initialiseRTShaderSystem(Ogre::SceneManager* sceneMgr)
{
if (Ogre::RTShader::ShaderGenerator::initialize())
{
mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
mShaderGenerator->addSceneManager(sceneMgr);
// Create and register the material manager listener if it doesn't exist yet.
if (mMaterialMgrListener == NULL) {
mMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);
Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);
}
}
return true;
}
Code: Select all
class ShaderGeneratorTechniqueResolverListener : public MaterialManager::Listener
{
public:
ShaderGeneratorTechniqueResolverListener(RTShader::ShaderGenerator* pShaderGenerator)
{
mShaderGenerator = pShaderGenerator;
}
virtual Technique* handleSchemeNotFound(unsigned short schemeIndex,
const String& schemeName, Material* originalMaterial, unsigned short lodIndex,
const Renderable* rend)
{
// Case this is the default shader generator scheme.
if (schemeName == RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)
{
MaterialRegisterIterator itFind = mRegisteredMaterials.find(originalMaterial);
bool techniqueCreated = false;
// This material was not registered before.
if (itFind == mRegisteredMaterials.end())
{
techniqueCreated = mShaderGenerator->createShaderBasedTechnique(
originalMaterial->getName(),
MaterialManager::DEFAULT_SCHEME_NAME,
schemeName);
}
mRegisteredMaterials[originalMaterial] = techniqueCreated;
}
return NULL;
}
protected:
typedef std::map<Material*, bool> MaterialRegisterMap;
typedef MaterialRegisterMap::iterator MaterialRegisterIterator;
protected:
MaterialRegisterMap mRegisteredMaterials; // Registered material map.
RTShader::ShaderGenerator* mShaderGenerator; // The shader generator instance.
};