I started with Tutorial00_Basic and pretty much copied the registerHlms() function, making some minor changes for my setup. Now it dies when creating the HlmsPbs object. I'm sure that there is something basic that I am missing but I can't figure it out. Below is my backtrace from GDB to go with the registerHlms() function and the function in my code that calls it.
GDB Backtrace:
Code: Select all
2021-02-01 23:52:31,502 INFO [default] renderEngine::registerHlms() Pbs Path = Hlms/Pbs/Any/Main
ubc: malloc.c:4064: _int_malloc: Assertion `(unsigned long) (size) >= (unsigned long) (nb)' failed.
Thread 1 "ubc" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49 return ret;
Missing separate debuginfos, use: zypper install libXt6-debuginfo-1.2.1-26.1.x86_64 libopenjp2-7-debuginfo-2.4.0-46.2.x86_64
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1 0x00007ffff6ab6864 in __GI_abort () at abort.c:79
#2 0x00007ffff6b17eca in __malloc_assert (assertion=assertion@entry=0x7ffff6c24ed8 "(unsigned long) (size) >= (unsigned long) (nb)", file=file@entry=0x7ffff6c204cb "malloc.c", line=line@entry=4064,
function=function@entry=0x7ffff6c25380 <__PRETTY_FUNCTION__.2> "_int_malloc") at malloc.c:298
#3 0x00007ffff6b1b978 in _int_malloc (av=av@entry=0x7ffff6c54a00 <main_arena>, bytes=bytes@entry=17) at malloc.c:4064
#4 0x00007ffff6b1c8c1 in __GI___libc_malloc (bytes=bytes@entry=17) at malloc.c:3086
#5 0x00007ffff6e6e969 in operator new (sz=17) at ../../../../libstdc++-v3/libsupc++/new_op.cc:50
#6 0x00007ffff6f037af in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=0xae7e80, __beg=0xdfb910 "Vct_piece_ps.any", __end=<optimized out>)
at /usr/src/debug/gcc10-10.2.1+git1030-1.2.x86_64/obj-x86_64-suse-linux/x86_64-suse-linux/libstdc++-v3/include/bits/basic_string.tcc:219
#7 0x00007ffff73e5a92 in Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> >::construct (this=0xae65b0,
p=0xae7e80, val="Vct_piece_ps.any") at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/include/OgreMemorySTLAllocator.h:175
#8 0x00007ffff73e56f2 in std::allocator_traits<Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_S_construct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> (__a=..., __p=0xae7e80)
at /usr/include/c++/10/bits/alloc_traits.h:247
#9 0x00007ffff73e508e in std::allocator_traits<Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::construct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> (__a=..., __p=0xae7e80)
at /usr/include/c++/10/bits/alloc_traits.h:360
#10 0x00007ffff73e4bfc in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::push_back (this=0xae65b0, __x="Vct_piece_ps.any") at /usr/include/c++/10/bits/stl_vector.h:1192
#11 0x00007ffff74a3d00 in Ogre::Hlms::enumeratePieceFiles (dataFolder=0xca2350, pieceFiles=0xae6598) at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreHlms.cpp:512
#12 0x00007ffff74a38fb in Ogre::Hlms::enumeratePieceFiles (this=0xe0ac40) at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreHlms.cpp:469
#13 0x00007ffff74a2594 in Ogre::Hlms::Hlms (this=0xe0ac40, type=Ogre::HLMS_PBS, typeName="pbs", dataFolder=0xe0de60, libraryFolders=0x7fffffffbca0)
at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreHlms.cpp:313
#14 0x00007ffff7173234 in Ogre::HlmsBufferManager::HlmsBufferManager (this=0xe0ac40, type=Ogre::HLMS_PBS, typeName="pbs", dataFolder=0xe0de60, libraryFolders=0x7fffffffbca0)
at /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Common/src/OgreHlmsBufferManager.cpp:58
#15 0x00007ffff71c1990 in Ogre::HlmsPbs::HlmsPbs (this=0xe0ac40, dataFolder=0xe0de60, libraryFolders=0x7fffffffbca0) at /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp:318
#16 0x000000000060e3de in renderEngine::registerHlms (this=0x841430) at /home/libolt/Projects/ubc/src/engine/renderengine.cpp:690
#17 0x000000000061001b in renderEngine::createScene (this=0x841430) at /home/libolt/Projects/ubc/src/engine/renderengine.cpp:972
#18 0x00000000006e4db0 in UBC::run (this=0x840080) at /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
#19 0x00000000006e6307 in main (argc=1, argv=0x7fffffffd5e8) at /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348
Code: Select all
void renderEngine::registerHlms(void)
{
std::string func = "renderEngine::registerHlms()";
logMsg(func +"Setting up HLMS");
#if __ANDROID__
std::string dataPath = "data";
#else
std::string dataPath = UBC_DATADIR;
#endif
hlmsManager = RERoot->getHlmsManager();
logMsg(func +"Hlms setup");
Ogre::ConfigFile cf;
// cf.load( AndroidSystems::openFile( mResourcePath + "resources2.cfg" ) );
Ogre::String rootHlmsFolder = dataPath +"/Media/" +
cf.getSetting("DoNotUseAsResource","Hlms","");
logMsg(func +" " +rootHlmsFolder);
if( rootHlmsFolder.empty() )
rootHlmsFolder = "./";
else if( *( rootHlmsFolder.end() - 1 ) != '/' )
rootHlmsFolder += "/";
Ogre::HlmsUnlit *hlmsUnlit = 0;
Ogre::HlmsPbs *hlmsPbs = 0;
//For retrieval of the paths to the different folders needed
Ogre::String mainFolderPath;
Ogre::StringVector libraryFoldersPaths;
Ogre::StringVector::const_iterator libraryFolderPathIt;
Ogre::StringVector::const_iterator libraryFolderPathEn;
Ogre::ArchiveManager &archiveManager = Ogre::ArchiveManager::getSingleton();
/* Ogre::Archive *archiveLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
dataPath + "/Media/Hlms/Common/GLSL", "FileSystem", true );
Ogre::ArchiveVec library;
library.push_back( archiveLibrary );
Ogre::Archive *archivePbs = Ogre::ArchiveManager::getSingletonPtr()->load(
dataPath + "/Media/Hlms/Pbs/GLSL", "FileSystem", true );
// Ogre::HlmsPbs *hlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &library );
// Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsPbs );
hlmsManager->registerHlms(hlmsPbs);
// Ogre::Archive *archiveUnlit = Ogre::ArchiveManager::getSingletonPtr()->load(
// dataPath + "/Media/Hlms/Unlit/GLSL", "FileSystem", true );
// 2.1 Ogre::HlmsUnlit *hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &library );
// Ogre::HlmsUnlit *hlmsUnlit = static_cast<Ogre::HlmsUnlit*>(hlmsManager->getHlms(Ogre::HLMS_UNLIT));
*/
// const Ogre::String &archiveType = getMediaReadArchiveType();
{
// Create & Register HlmsUnlit
// Get the path to all the subdirectories used by HlmsUnlit
Ogre::HlmsUnlit::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
Ogre::Archive *archiveUnlit =
archiveManager.load( rootHlmsFolder + mainFolderPath, "FileSystem", true );
Ogre::ArchiveVec archiveUnlitLibraryFolders;
libraryFolderPathIt = libraryFoldersPaths.begin();
libraryFolderPathEn = libraryFoldersPaths.end();
while( libraryFolderPathIt != libraryFolderPathEn )
{
Ogre::Archive *archiveLibrary =
archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
logMsg(func +" Unlit Path = " +*libraryFolderPathIt);
archiveUnlitLibraryFolders.push_back( archiveLibrary );
++libraryFolderPathIt;
}
// Create and register the unlit Hlms
hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &archiveUnlitLibraryFolders );
Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsUnlit );
}
{
// Create & Register HlmsPbs
// Do the same for HlmsPbs:
Ogre::HlmsPbs::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
Ogre::Archive *archivePbs = archiveManager.load( rootHlmsFolder + mainFolderPath, "FileSystem", true );
// Get the library archive(s)
Ogre::ArchiveVec archivePbsLibraryFolders;
libraryFolderPathIt = libraryFoldersPaths.begin();
libraryFolderPathEn = libraryFoldersPaths.end();
while( libraryFolderPathIt != libraryFolderPathEn )
{
Ogre::Archive *archiveLibrary =
archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
logMsg(func +" Pbs Path = " +*libraryFolderPathIt);
archivePbsLibraryFolders.push_back( archiveLibrary );
++libraryFolderPathIt;
}
// Create and register
hlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &archivePbsLibraryFolders );
Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsPbs );
}
Code: Select all
bool renderEngine::createScene()
{
conversionSharedPtr convert ;
std::string func = "renderEngine::createScene()";
logMsg(func +" begin");
instance += 1;
// exit(0);
#ifdef __ANDROID
logMsg(func +" Hello");
config = AConfiguration_new();
logMsg(func +" Mello");
// exit(0);
// AConfiguration_fromAssetManager(config, app->activity->assetManager);
// mAssetMgr = app->activity->assetManager;
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
jclass class_sdl_activity = env->FindClass("com/libolt/ubc/UBCActivity");
jmethodID method_get_native_surface = env->GetStaticMethodID(class_sdl_activity,
"getNativeSurface",
"()Landroid/view/Surface;");
jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity,
method_get_native_surface);
ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
if ( !native_window )
{
logMsg(func +" No Window, Goodbye!");
return(0);
}
jclass class_activity = env->FindClass("com/libolt/ubc/UBCActivity");
jclass class_resources = env->FindClass("android/content/res/Resources");
jmethodID method_get_resources = env->GetMethodID(class_activity,
"getResources",
"()Landroid/content/res/Resources;");
jmethodID method_get_assets = env->GetMethodID(class_resources,
"getAssets",
"()Landroid/content/res/AssetManager;");
jobject raw_activity = (jobject)SDL_AndroidGetActivity();
jobject raw_resources = env->CallObjectMethod(raw_activity,
method_get_resources);
jobject raw_asset_manager = env->CallObjectMethod(raw_resources,
method_get_assets);
// jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity, method_get_native_surface);
// ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
// exit(0);
uint32_t w = ANativeWindow_getWidth(native_window);
uint32_t h = ANativeWindow_getHeight(native_window);
logMsg(func +" Width = " +convert->toString(w));
logMsg(func +" Height = " +convert->toString(h));
setWindowWidth(w);
setWindowHeight(h);
mAssetMgr = AAssetManager_fromJava(env, raw_asset_manager);
logMsg(func +" Yello");
AConfiguration_fromAssetManager(config, mAssetMgr);
logMsg(func +" Bello");
// mAssetMgr = app->activity->assetManager;
Ogre::ArchiveManager::getSingleton().addArchiveFactory(
new Ogre::APKFileSystemArchiveFactory(mAssetMgr) );
Ogre::ArchiveManager::getSingleton().addArchiveFactory(
new Ogre::APKZipArchiveFactory(mAssetMgr) );
logMsg(func +" Hello?");
// exit(0);
#endif
logMsg(func +" winHandle = " +winHandle);
std::string windowTitle = "Ultimate Basketball Challenge";
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
misc.insert( std::make_pair("externalWindowHandle", winHandle) );
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
misc.insert( std::make_pair("parentWindowHandle", winHandle) );
#endif
misc.insert( std::make_pair("title", windowTitle) );
misc.insert( std::make_pair("gamma",
cfgOpts["sRGB Gamma Conversion"].currentValue) );
if( cfgOpts.find( "VSync Method" ) != cfgOpts.end() )
misc.insert( std::make_pair( "vsync_method",
cfgOpts["VSync Method"].currentValue ) );
misc.insert( std::make_pair("FSAA", cfgOpts["FSAA"].currentValue) );
misc.insert( std::make_pair("vsync", cfgOpts["VSync"].currentValue) );
misc.insert( std::make_pair("reverse_depth", "Yes" ) );
mWindow = sharedPtr<Ogre::Window>(
RERoot->createRenderWindow(windowTitle, windowWidth,
windowHeight, false, &misc));
logMsg(func +" renderWindow created!");
std::size_t handle = 0;
mWindow->getCustomAttribute("WINDOW", &handle);
logMsg(func +" mWindow handle = " +convert->toString(handle));
logMsg(func +" Dead");
#ifdef __ANDROID
sdlWindow = SDL_CreateWindowFrom(mWindow.get());
#endif
if (mWindow == nullptr)
{
logMsg(func +" createScene mWindow == nullptr!");
}
mResourceGroup = "UBCData";
// Ogre::ResourceGroupManager *rsm
rsm = sharedPtr<Ogre::ResourceGroupManager>(
Ogre::ResourceGroupManager::getSingletonPtr());
rsm->createResourceGroup(mResourceGroup);
// Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
#if __ANDROID__
Ogre::ConfigFile cf;
cf.load(openAPKFile("resources.cfg"));
logMsg(func +" or");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
//exit(0);
while (seci.hasMoreElements())
{
std::string sec, type, arch;
sec = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); i++)
{
type = i->first;
arch = i->second;
// Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
rsm->addResourceLocation(arch, type, mResourceGroup);
}
}
// Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::RTShader::ShaderGenerator::initialize();
// The Shader generator instance
Ogre::RTShader::ShaderGenerator* shaderGen =
Ogre::RTShader::ShaderGenerator::getSingletonPtr();
//Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setTargetLanguage("glsles");
shaderGen->setTargetLanguage("glsles");
if (mMatListener == nullptr)
{
mMatListener = new Ogre::ShaderGeneratorTechniqueResolverListener();
Ogre::MaterialManager::getSingleton().addListener(mMatListener);
}
// shaderGen->addSceneManager(mSceneMgr);
#else
// logMsg("Rendering!");
misc["externalWindowHandle"] = winHandle; //
// mWindow = RERoot->createRenderWindow("Ultimate Basketball Challenge", 0, 0, false, &misc);
// exit(0);
// mWindow->set
// mWindow->setVisible(true);
#endif
logMsg(func +" Alive?");
#if __ANDROID__
std::string dataPath = "data";
#else
std::string dataPath = UBC_DATADIR;
//exit(0);
// load the basic resource location(s)
rsm->addResourceLocation(dataPath + "/Media", "FileSystem", mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/compositor", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/fonts", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/gui", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/MyGUI_Media", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/models", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/materials/textures", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/materials/programs", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/materialss/scripts", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/materials", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/overlays", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/packs", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/skins", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/skins/qgui", "FileSystem",
mResourceGroup);
rsm->addResourceLocation(dataPath + "/Media/Audio", "FileSystem",
mResourceGroup);
rsm->initialiseResourceGroup("UBCData", false);
#endif
registerHlms(); // registers Hlms shader system