[2.2] Shader cache issue
Posted: Sat Oct 12, 2019 10:07 am
Hi,
I have an issue with the shader caches. I use the code from the Ogre2.2 examples:
But each time, I start the simulation, the graphics stall which make my game attempts unusable. See the video:
http://www.lukas-kalinowski.com/Homepag ... aching.mp4
So when I start the application the graphics do stall. When I restart the simulation within the application, it seems that the shaders are in cache and the simulation runs nice. But when I exit the application and check the "NOWA_Design.cache" file against a prior created "cache" will, nothing changed.
When I start the applictation again, the graphics will stall again.
I tried a lot of thinks, because I first thought, the issue is because of to big textures etc. I excluded a lot of thinks and what remains is the shader cache. I think it does not store shader correctly.
I hope somebody has an idea how to fix that issue, or what I could also try out...
I'm writing here in the forum, because I'm out of ideas, this issue does exist since I use shader caching, so its not a new issue in Ogre2.2 but also existed in Ogre 2.1.
Best Regards
Lax
I have an issue with the shader caches. I use the code from the Ogre2.2 examples:
Code: Select all
if (this->root->getRenderSystem() && Ogre::GpuProgramManager::getSingletonPtr())
{
Ogre::HlmsManager* hlmsManager = this->root->getHlmsManager();
Ogre::HlmsDiskCache diskCache(hlmsManager);
Ogre::ArchiveManager& archiveManager = Ogre::ArchiveManager::getSingleton();
Ogre::Archive* rwAccessFolderArchive = archiveManager.load(this->writeAccessFolder, "FileSystem", false);
Ogre::TextureGpuManager* textureManager = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
if (textureManager)
{
Ogre::String jsonString;
textureManager->exportTextureMetadataCache(jsonString);
const Ogre::String path = this->writeAccessFolder + "/NOWA_Engine.json";
std::ofstream file(path.c_str(), std::ios::binary | std::ios::out);
if (file.is_open())
file.write(jsonString.c_str(), static_cast<std::streamsize>(jsonString.size()));
file.close();
}
for (size_t i = Ogre::HLMS_LOW_LEVEL + 1u; i < Ogre::HLMS_MAX; ++i)
{
Ogre::Hlms* hlms = hlmsManager->getHlms(static_cast<Ogre::HlmsTypes>(i));
if (hlms)
{
diskCache.copyFrom(hlms);
Ogre::DataStreamPtr diskCacheFile = rwAccessFolderArchive->create("NOWA_Engine.bin");
diskCache.saveTo(diskCacheFile);
}
}
if (true == Ogre::GpuProgramManager::getSingleton().isCacheDirty())
{
try
{
// Save shader cache
const Ogre::String filename = "NOWA_Engine.cache";
Ogre::DataStreamPtr shaderCacheFile = rwAccessFolderArchive->create(filename);
Ogre::GpuProgramManager::getSingleton().saveMicrocodeCache(shaderCacheFile);
}
catch (std::exception&)
{
Ogre::LogManager::getSingletonPtr()->logMessage(Ogre::LML_CRITICAL, "[Core]: Something went wrong during GPU shader cache saving.");
}
}
archiveManager.unload(this->writeAccessFolder);
}
http://www.lukas-kalinowski.com/Homepag ... aching.mp4
So when I start the application the graphics do stall. When I restart the simulation within the application, it seems that the shaders are in cache and the simulation runs nice. But when I exit the application and check the "NOWA_Design.cache" file against a prior created "cache" will, nothing changed.
When I start the applictation again, the graphics will stall again.
I tried a lot of thinks, because I first thought, the issue is because of to big textures etc. I excluded a lot of thinks and what remains is the shader cache. I think it does not store shader correctly.
I hope somebody has an idea how to fix that issue, or what I could also try out...
I'm writing here in the forum, because I'm out of ideas, this issue does exist since I use shader caching, so its not a new issue in Ogre2.2 but also existed in Ogre 2.1.
Best Regards
Lax