v2-2-vulkan 32bit Image2 assert Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


dermont
Bugbear
Posts: 812
Joined: Thu Dec 09, 2004 2:51 am
x 42

v2-2-vulkan 32bit Image2 assert

Post by dermont »

Hi,

I'm trying a 32 build android build(armeabi-v7a) on the vulkan-2-2 branch, running the application on the device the following assert( mipLevel < mNumMipmaps ) is triggered from TextureGpuManager::processQueuedImage -> Image2::getData.

From the stack trace on android studio, it shows the numMips as 33 i.e. numMips = queuedImage.getMaxMipLevelPlusOne()

Looking at the code I think it might just need updating to account for 32 bit builds (not 100% sure), e.g main.cpp:

Code: Select all

#include "Ogre.h"
#include "OgreBitwise.h"
#include "OgreString.h"
#include <iostream>

using namespace std;
using namespace Ogre;

//g++  -o main main.cpp  -I /media/sdb5/Libraries/OGRE/sdk/v2-2-VULKAN/include/OGRE -L/media/sdb5/Libraries/OGRE/sdk/v2-2-VULKAN/lib 
//g++  -m32 -o main main.cpp  -I /media/sdb5/Libraries/OGRE/sdk/v2-2-VULKAN/include/OGRE -L/media/sdb5/Libraries/OGRE/sdk/v2-2-VULKAN/lib 


uint8 getMaxMipLevelPlusOne(uint64* mipLevelBitSet, uint32 numSlices)
    {
        for( size_t i=4u; i--; )
        {
            if( mipLevelBitSet[i] != 0u )
            {
                uint8 lastBitSet =
#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32
                static_cast<uint8>( 32u - Bitwise::clz64( mipLevelBitSet[i] ) + 32u * i );
#else
                static_cast<uint8>( 64u - Bitwise::clz64( mipLevelBitSet[i] ) + 64u * i );
#endif                        
                return (lastBitSet + numSlices - 1u) / numSlices;
            }
        }

        return 0u;
    }
    
uint8 getMinMipLevel(uint64* mipLevelBitSet, uint32 numSlices)
{
    for( size_t i=0; i<4u; ++i )
    {
        if( mipLevelBitSet[i] != 0u )
        {
            uint8 firstBitSet = static_cast<uint8>( Bitwise::ctz64( mipLevelBitSet[i] ) );
#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32
            return (firstBitSet + 32u * i) / numSlices;
#else
            return (firstBitSet + 64u * i) / numSlices;
#endif
            
        }
    }

    return 255u;
}


int main()
{
#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32
std::cout << "Using 32 Bit Architecture " << std::endl;
#endif

uint64 mipLevelBitSet[4];
mipLevelBitSet[0] = 1u;
mipLevelBitSet[1] = 0u;
mipLevelBitSet[2] = 0u;
mipLevelBitSet[3] = 0u;

unsigned val = (unsigned)getMaxMipLevelPlusOne(mipLevelBitSet,1);
std::cout << "Min Level " << (unsigned)getMinMipLevel(mipLevelBitSet,1) <<  " Max Level " << val << std::endl;
return 0;
}

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5446
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1348

Re: v2-2-vulkan 32bit Image2 assert

Post by dark_sylinc »

We had an extremely similar bug in Windows when built using MinGW.

The source of the problem is in OgreMain/include/OgreBitwise.h, where __builtin_clzll should be used instead of __builtin_clzl
See __MINGW32__ ifdefs.

Try forcing those paths for armeabi-v7a as well.
dermont
Bugbear
Posts: 812
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: v2-2-vulkan 32bit Image2 assert

Post by dermont »

Thanks that solved it.