Game Development Community

TGEA crashes when creating Atlas Texture

by Justin Mosiman · in Torque Game Engine Advanced · 04/11/2007 (3:04 pm) · 14 replies

Hello,

I'm trying to create an Atlas terrain, but when I get to the step of creating the texture TGEA crashes. I have tried creating the texture from both atlasGenerateTextureTOCFromLargeJPEG and atlasGenerateTextureTOCFromTiles, but they both crash at the same spot.

First, I created a separate main.cs for TGEA to run, and it contained:
enableWinConsole(true);
setLogMode(6);
atlasOldGenerateChunkFileFromRaw16("prototype/data/terrains/pathfinding/heightmap.raw", 1024, 1.0, 0.0014, "prototype/data/terrains/pathfinding/atlas/geometry.chu", 1, 2);
importOldAtlasCHU("prototype/data/terrains/pathfinding/atlas/geometry.chu", "prototype/data/terrains/pathfinding/atlas/geometry.atlas");

atlasGenerateTextureTOCFromLargeJPEG("prototype/data/terrains/pathfinding/texturemap.jpg",2,"prototype/data/terrains/pathfinding/atlas/texture.atlas");
// Or
atlasGenerateTextureTOCFromTiles(2, "prototype/data/terrains/pathfinding/texturemap.jpg", "prototype/data/terrains/pathfinding/atlas/texture.atlas", 0);

And running in debug mode using atlasGenerateTextureTOCFromLargeJPEG it crashes at:

Quote:
importOldAtlasCHU - import OK!
AtlasFile::waitForPendingWrites - Waiting for pending output to finish.
AtlasFile::waitForPendingWrites - Done!
atlasGenerateTextureTOCFromLargeJPEG - Successfully opened JPEG 'prototype/data/terrains/pathfinding/texturemap.jpg' for reading.
atlasGenerateTextureTOCFromLargeJPEG - Image is 2048px (hopefully square!).
atlasGenerateTextureTOCFromLargeJPEG - Tree depth of 2 mandates 2 tiles on a side.
atlasGenerateTextureTOCFromLargeJPEG - Therefore, tiles are 1024px wide.
AtlasDeferredFile::ensureStreamWritable - switching file into writable mode... This may cause a crash if you have other copies of Torque accessing it!
atlasGenerateTextureTOCFromLargeJPEG - Atlas file 'prototype/data/terrains/pathfinding/atlas/texture.atlas' created!
atlasGenerateTextureTOCFromLargeJPEG - Initialized Atlas threads, now importing texture data...
atlasGenerateTextureTOCFromLargeJPEG - Allocating ~6144 kb of JPEG decompression working area...
atlasGenerateTextureTOCFromLargeJPEG - Generating 1024px by 1024px leaf tiles...
- processing row 0...
Fatal: (d:\torque\tgea\engine\platform\platformmemory.cpp @ 1116) Not an allocated block!
Error, a DecalManager (1a7904c) isn't properly out of the bins!

And using atlasGenerateTextureTOCFromTiles it crashes at a similar point:

Quote:
importOldAtlasCHU - import OK!
AtlasFile::waitForPendingWrites - Waiting for pending output to finish.
AtlasFile::waitForPendingWrites - Done!
atlasGenerateTextureTOCFromTiles - Initializing atlas file 'prototype/data/terrains/pathfinding/atlas/texture.atlas'...
AtlasDeferredFile::ensureStreamWritable - switching file into writable mode... This may cause a crash if you have other copies of Torque accessing it!
atlasGenerateTextureTOCFromTiles - Atlas started, processing tiles for 2 deep tree...
atlasGenerateTextureTOCFromTiles - Storing tiles in JPEG format...
atlasGenerateTextureTOCFromTiles - processing row 0...
PlatformMemory: allocating new page, total bytes allocated so far: 5442220 (total bytes in all pages=37748872)
Fatal: (d:\torque\tgea\engine\platform\platformmemory.cpp @ 1116) Not an allocated block!
Error, a DecalManager (1a7904c) isn't properly out of the bins!

Has anybody seen this error before?

Thanks,
Justin

#1
04/11/2007 (5:07 pm)
Thanks for supplying so much infomation on the problem, it makes it easier. By looking throught the code I see you got two errors here. The first error "Not an allocated block!" is from the free() function where it was trying to free a block of memory that it doesn't remember allocating. The second error I think you can ignore because it was caused while the engine was trying to shut down.

Why you got an error in the free function I don't know. But in using the atlasGenerateTextureTOCFromLargeJPEG function I would suggest increasing your tree depth to at least 3. I find that using a tree depth of 2 with a texture measuring 2048x2048 cause the resulting Atlas terrain terrain texture to appear all black except for a "spotlight" of texture inside the clipmap area. So when processing a unique terrain I use these values for my minimum tree depth:

2 - for a 1024x1024 pixel texture
3 - for a 2048x2048 pixel texture
4 - for a 4096x4096 pixel texture
5 - for a 8192x8192 pixel texture
6 - for a 16384x16384 pixel texture
7 - for a 32768x32768 pixel texture

Why this happens I can only guess that having leafs larger than the 512 pixel size of the clipmap is a bad thing.

I never have used atlasGenerateTextureTOCFromTiles, but if you only have a single texture for your terrain I think you want to stay with atlasGenerateTextureTOCFromLargeJPEG() and create a unique terrain.
#2
04/11/2007 (6:36 pm)
Thanks for the reply, that tree depth explanation will help a lot.

But unfortunelly changing the tree depth didn't change it from crashing. I created a new terrain using L3DT and tried it again thinking it may have just been the terrain, but that didn't work either.

I also tried using the default exe that comes with TGEA 1.01 but that didn't change anything.

Anybody have any other ideas?
#3
04/12/2007 (8:38 am)
I'm still playing around with this and still getting the same error. I tried using the Atlas2 GUI but it crashes at the same point as using the command line.

Maybe my heightfield or texture map is wrong.. Can somebody try these files with these settings to see if it works for them?

heightfield.raw
textureMap.jpg

I used the following commands (of course change it to the directory that corresponds with your system):
generateChunkFileFromRaw16("YOUR/DIRECTORY/heightfield.raw", 1024, 1.0, 0.0021, "YOUR/DIRECTORY/geometry.chu", 1, 4);
importOldAtlasCHU("YOUR/DIRECTORY/geometry.chu", "YOUR/DIRECTORY/geometry.atlas");
atlasGenerateTextureTOCFromLargeJPEG("YOUR/DIRECTORY/textureMap.jpg",4,"YOUR/DIRECTORY/texture.atlas");

If somebody could test this out I think that it would help a ton.

Thanks,
Justin
#4
04/12/2007 (3:20 pm)
Check your console log. The part where it shows the stats of your graphics card also displays what your card's maximum texture size is. For your card, that might be less than 1024.
#5
04/12/2007 (3:26 pm)
It doesn't look like that is the case
Quote:
Initializing GFXCardProfiler (D3D9)
o Vendor : 'NVIDIA'
o Card : 'GeForce FX 5900'
o Version: '93.71'
- Scanning card capabilities...
GFXCardProfiler (D3D9) - Setting capability 'autoMipMapLevel' to 1.
GFXCardProfiler (D3D9) - Setting capability 'maxTextureWidth' to 4096.
GFXCardProfiler (D3D9) - Setting capability 'maxTextureHeight' to 4096.
- Loading card profiles...
- Loading card profile profile/D3D9.cs
- Loading card profile profile/D3D9.NVIDIA.cs
- No card profile profile/D3D9.NVIDIA.GeForceFX5900.cs exists
- No card profile profile/D3D9.NVIDIA.GeForceFX5900.9371.cs exists

Does it matter that it couldn't load the card profiles?
#6
04/12/2007 (4:26 pm)
Justin,
I just merge our code changes with TGEA 1.01 and using your texture file, I'm getting the same errors. I tried one of my old texture files and I still got the same error. I assume that you are using TGEA 1.01 and I think I found a problem with it.

If you are using TGEA 1.01, and only if you are using TGEA 1.01, do me a favor and look at your engine/atlas/editor/atlasImportLargeImage.cpp file. At about line 285 it should say:

GBitmap *gb = new GBitmap(tileSize, tileSize);

In TGEA 1.01 this should be changed to:

GBitmap *gb = new GBitmap[1];
gb->allocateBitmap(tileSize, tileSize);

Let me know if that helps
#7
04/14/2007 (6:32 pm)
Sorry for the late reply, I wasn't able to try the change out until now.

Yes, I am using TGEA 1.01, and using your code fixed it so that I was able to build the main atlas file. But when I load it into a mission I am getting an this error:
Quote:
AtlasClipMapImageCache_TextureTOC::setTOC - clipmap size is bigger than all levels of the TOC! Set smaller clipap size or bigger texture TOC!
I noticed that the atlas texture file is only 3KB... which I know can't be right. Were you able to import the main atlas file into a mission?

Thanks,
Justin
#8
04/15/2007 (11:55 am)
Justin,
No, I have not gotten it to work for me. There is still something hosed in the texture processing. I believe Ben is still in the process of adding support for multiple terrain textures and those changes are not complete. I would suggest using R1 for Atlas processing until this is fixed. All of the texture leafs are being processed by I don't think they are being written to the file. I had hoped to have time to look at this last week but I got caught up in other things.
#9
04/15/2007 (12:10 pm)
Mary,

Thanks for all of the help. If I don't have the R1 exe anymore, do you know where I would go to find it?

Thanks again,
Justin
#10
04/16/2007 (10:23 am)
Justin,
After you merge into a new version, it's always a good idea to archive the old one ot DVD. Just in case you forgot to merge something. Check your email.
#11
04/28/2007 (12:00 pm)
Hello,

I have the same issue with TGEA 1.0.1 - opened a thread in bugs also since this seems to have been here for a while now and nobody managed to solve it.

It seems there's some problem with the memory management system...

atc->mFormat = (AtlasTexChunk::TexFormat)outFormat;
delete atc;  <---- here will work
atc->bitmap = bmp; 
delete atc;  <---- here will crash with non-allocated block

Above code is a part I zeroed in on in either of the texture generation cpp files (tiles and large jpeg).
The deletes are not there - but if you put one before the bitmap pointer assignment - delete will work. If you move it to after the assignment - it will crash... No idea how such an assignment could screw up this pointer. Since memory management is completely customized in TGE I kinda got lost at the super-fancy delete operator written by GarageGames guys...

Help... :( I need atlas to work - a saturday spent on debugging in not what I paid for. ;)
#12
05/30/2007 (9:21 pm)
Same problem here any news on the large jpeg crash prob?
#13
05/30/2007 (9:46 pm)
Jojimbo,
This problem has a fix. See Ben Garney's post at http://www.garagegames.com/mg/forums/result.thread.php?qt=61367

It involves replacing
GBitmap *gb = new GBitmap(tileSize, tileSize);

with
GBitmap *gb = new GBitmap[1];
gb->allocateBitmap(tileSize, tileSize);

and the addition of
atc->layerCount = 1;

Then 1.01 generates Atlas terrain just fine.
#14
05/30/2007 (10:11 pm)
Thanks mary i was over looking at that post,i imported fine with MS4 and copied my terrain to the 1.01.i will update my code asap. tyvm