Game Development Community

RC1 Bug : Atlas2 Unique texture terrain crash

by Vincent BILLET · in Torque Game Engine Advanced · 02/11/2007 (1:55 am) · 14 replies

I use Atlas unique texture. Unfortunatily, this kind of terrain crash the engine.

#1
02/11/2007 (5:44 am)
Confirmed, we have the same problem. No problems in MS4.2.
#2
02/11/2007 (4:36 pm)
I as well have crashes with unique terrain. Our build crashes (didn't with 4.2), and the stock demo crashes with our terrain.
#3
02/11/2007 (6:05 pm)
Guys... the best thing you can do to help with these issues is post more than "it crashed". Did you run it in debug? Where in the code did it crash? Did you try recreating the .atlas file? Try creating the .atlas with a debug build (it spits out extra assertions).
#4
02/11/2007 (8:28 pm)
Here's where the crash happens:
while(curIn < endIn)
               {
                  *curOut = (*(U32*)curIn) & 0x00FFFFFF;    <---- here
                  curIn+=3;
                  curOut++;
               }
I'll run a debug and see if I get any more information.
#5
02/11/2007 (9:15 pm)
Ok, that's in AtlasClipMapUniqueCache.cpp. The error is an Access Violation, and here's my callstack:
>	TGEA_DEBUG.exe!AtlasClipMapImageCache_TextureTOC::bitblt(unsigned int mipLevel=1, const AtlasClipMap::ClipStackEntry & cse={...}, RectI srcRegion={...}, unsigned char * bits=0x1f8d5a1c, unsigned int pitch=2048)  Line 341 + 0x14 bytes	C++
 	TGEA_DEBUG.exe!AtlasClipMapImageCache_TextureTOC::doRectUpdate(unsigned int mipLevel=2, AtlasClipMap::ClipStackEntry & cse={...}, RectI srcRegion={...}, RectI dstRegion={...})  Line 179	C++
 	TGEA_DEBUG.exe!AtlasClipMap::recenter(Point2F center={...})  Line 687	C++
 	TGEA_DEBUG.exe!AtlasInstance2::renderObject(SceneState * state=0x24ebe4d8, RenderInst * __formal=0x29b1ac20)  Line 363	C++
 	TGEA_DEBUG.exe!RenderObjectMgr::render()  Line 19 + 0x25 bytes	C++
 	TGEA_DEBUG.exe!RenderInstManager::render()  Line 285 + 0x2c bytes	C++
 	TGEA_DEBUG.exe!SceneState::renderCurrentImages()  Line 144	C++
 	TGEA_DEBUG.exe!SceneGraph::traverseSceneTree(SceneState * pState=0x24ebe4d8)  Line 364	C++
 	TGEA_DEBUG.exe!SceneGraph::renderScene(const unsigned int objectMask=4294967295)  Line 190	C++
 	TGEA_DEBUG.exe!GameRenderWorld()  Line 1025	C++
 	TGEA_DEBUG.exe!GameTSCtrl::renderWorld(const RectI & updateRect={...})  Line 42	C++
 	TGEA_DEBUG.exe!GuiTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...})  Line 116 + 0x16 bytes	C++
 	TGEA_DEBUG.exe!GameTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...})  Line 77	C++
 	TGEA_DEBUG.exe!GuiCanvas::renderFrame(bool preRenderOnly=false)  Line 1250	C++
 	TGEA_DEBUG.exe!DemoGame::processTimeEvent(TimeEvent * event=0x0012fc9c)  Line 756	C++
 	TGEA_DEBUG.exe!GameInterface::processEvent(Event * event=0x0012fc9c)  Line 74 + 0x13 bytes	C++
 	TGEA_DEBUG.exe!GameInterface::postEvent(Event & event={...})  Line 156 + 0x13 bytes	C++
 	TGEA_DEBUG.exe!TimeManager::process()  Line 1014 + 0x19 bytes	C++
 	TGEA_DEBUG.exe!DemoGame::main(int argc=1, const char * * argv=0x013e4f70)  Line 543	C++
 	TGEA_DEBUG.exe!run(int argc=1, const char * * argv=0x013e4f70)  Line 887 + 0x1c bytes	C++
 	TGEA_DEBUG.exe!main(int argc=1, const char * * argv=0x013e4f70)  Line 965 + 0xd bytes	C++
 	TGEA_DEBUG.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes	C
 	TGEA_DEBUG.exe!mainCRTStartup()  Line 403	C
 	kernel32.dll!7c816fd7() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]

I'll dig up the original files and try re-creating the terrain. However, since it seemed to (at least start) rendering fine with the stock demo, I was thinking that wasn't the problem. With our build, the engine dies right away, and with the stock demo I can start moving around for a little bit before it crashes (same line with stock). Our build has a lot more objects in our mission, so that might contribute to the speed at which the crash occurs.
#6
02/12/2007 (8:18 am)
I can confirm that recreating the atlas terrain from scratch doesn't solve the problem. We are only early in the project, so can't post any further info.

The mission displays briefly for a few frames, then a CTD.
#7
02/13/2007 (8:46 am)
Ben posted this in another thread:
Quote:
For the atlas crash, go to line 87 of gfxD3DTextureObject.cpp and change the if(inRect) block to read:

if(inRect)
      {
         r.top  = inRect->point.x;
         r.left = inRect->point.y;
         r.bottom = inRect->point.x + inRect->extent.x;
         r.right  = inRect->point.y + inRect->extent.y;
      }


This will fix the upload crash.
#8
02/13/2007 (12:10 pm)
Is that fix working for you guys?
#9
02/13/2007 (12:15 pm)
Yes, It fully solve this issue.
#10
02/13/2007 (1:09 pm)
@Brian - You do realize that the *fix* is actually an error:

if(inRect)
      {
         r.top  = inRect->point.x;
         r.left = inRect->point.y;
         r.bottom = inRect->point.x + inRect->extent.x;
         r.right  = inRect->point.y + inRect->extent.y;
      }

Notice that the code is saying top/bottom is the X coord... left/right is the Y coord. This was originally a fix i posted over here. I noted that this may affect Atlas as it was the primary user of this code. The code should look like so:

if(inRect)
      {
         r.top  = inRect->point.y;
         r.left = inRect->point.x;
         r.bottom = inRect->point.y + inRect->extent.y;
         r.right  = inRect->point.x + inRect->extent.x;
      }

With x for left/right and y for top/bottom.

Last night i made a fix which leaves the lock() code technically correct, but swaps the x and y coords in the Atlas clipmap code so that it works correctly. I believe Ben has that code, but i'll post it if you need it.

I understand you need to ship stable and you don't want to make any extra changes, so i understand if you don't want to do the "right thing" here. At least add a big fat /// comment to the declaration of the lock() API so that anyone using it between TGEA final and the next release knows that lock() is broken to fix Atlas.
#11
02/13/2007 (1:45 pm)
@Tom : Could you post your fix? I notice that somebody already send screens with bad Atlas terrains due to your x/y swapping.
If you have a better solution I will test it as soon as I have it.
#12
02/13/2007 (6:37 pm)
@Vincent - Talking with Ben the fix i did is now in SVN... so i will be in the release in two days.
#13
02/13/2007 (9:21 pm)
How about a fix (or at least a warning) about the cash when your texture leaf chunks are more than 1024 px?
#14
02/15/2007 (1:00 pm)
Thanks for the fixes just i had bought TGEA and couldn't figure out how to get the .atlas file to load with out crashing. Well now it loads, and i can see a half textured atlas map.