Game Development Community

No D3dcaps2_canautogenmipmap Causes Tse Ms 3.5 To Crash

by Florian Ross · in Torque Game Engine Advanced · 07/01/2006 (3:17 pm) · 3 replies

I do have some problems with running TSE under Vista x64. On Debug build i get an Fatal Assert that the texture is not pow2 when starting tse. When running in release it will crash there. I digged deeper and i think that it is because my current driver doesnt support Auto Mipmap generation. At least the DX caps and the TSE profiler are saying so :).

This is where it asserts in gBitmap.cpp
if (in_extrudeMipLevels == true) 
   {
      //AssertFatal(in_width <= 256 && in_height <= 256, "GBitmap::allocateBitmap: width or height is too large");
      AssertFatal(isPow2(in_width) == true && isPow2(in_height) == true, "GBitmap::GBitmap: in order to extrude miplevels, bitmap w/h must be pow2");
   }

changing it to

if (in_extrudeMipLevels == true) 
   {
      //AssertFatal(in_width <= 256 && in_height <= 256, "GBitmap::allocateBitmap: width or height is too large");
      //AssertFatal(isPow2(in_width) == true && isPow2(in_height) == true, "GBitmap::GBitmap: in order to extrude miplevels, bitmap w/h must be pow2");
      if (isPow2(in_width) == false || isPow2(in_height) == false)
         return;
   }

it doesnt crash anymore and i can get into the main menu. It then crashs later when i'm starting the tech demo during the "loading objects" phase when it tries to get a surface.

From what i recall you are allowed to have non pow2 textures if you are using mipmaps. The function "innerCreateTexture" in gfxD3DTextureManager.cpp seems to only support auto mipmap generation and doesnt manually create them.

maybe placing "GFXCardProfiler::setCapability("autoMipmapLevel", false);" into your cards profile could reproduce this behaviour. It doesnt occur on a modified milestone 3 build but i do notice that the textures produce some flickering.

#1
07/05/2006 (10:49 am)
Okay :)

digged a little deeper and got it to run now (at least it doesnt crash) the code change i mentioned above works good because it just disables the mipmaps while the original texture gets loaded normally.

The second crash happens in bool GFXD3DTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL) in file gfxD3DTextureManager.cpp. It cant create the surface so it does throw a assert. But after that it tries to delete the surface with surf->Release(); at line 270. Since the surface never got created surf still points to NULL and the call to Release() will crash the engine then.

Changing it to
if ( surf != NULL )
         surf->Release();
will fix it. And the engine no longer crashes. All textures (except the atlas ones) are shown but they just dont have any mipmaps.

Now on to the last thing that isnt working quite right:

The TechDemo part works perfectly except maybe some white stripes that occur on the terrain.
The Terrain_Water_Demo however has some pretty ugly flickering that is cause from the water. Removing the water will make the flickering go away.

I'm still working on that :D
#2
07/05/2006 (12:35 pm)
Another thing i noticed with the very first issue. If i just remove
if (in_extrudeMipLevels == true)    {      //AssertFatal(in_width <= 256 && in_height <= 256, "GBitmap::allocateBitmap: width or height is too large");      AssertFatal(isPow2(in_width) == true && isPow2(in_height) == true, "GBitmap::GBitmap: in order to extrude miplevels, bitmap w/h must be pow2");   }
the code will compute the mip chain and allocate the memory for it. It then crashes in GFXD3DTextureManager when it tries
D3DAssert(texture->get2DTex()->GetSurfaceLevel( i, &surf ), "Failed to get surface");

for every i that is larger than one. if AutoGenMipmap is used it only set i = 1 but when creating the mipmaps by hand it will increment for every mipmap in the chain
#3
07/06/2006 (2:09 pm)
Another follow up <.<

seems like the flickering goes away if i'm not running the engine at 640x480

the reason is that the water renders to a 512x512 reflect buffer which is higher than the 480 of screen resolution. Setting water reflect size to 256x256 fixes the flickering too