Game Development Community

WaterPlane setup crash on T3D 1.0.1 OSX 10.6.6

by Mat Valadez · in Torque 3D Professional · 02/03/2011 (6:15 pm) · 12 replies

I have a simple project that loads a level with a waterplane and almost nothing else. Everything loads fin until I get try to play the level. It connects OK, I get the join message, but it crashes the first time it tries to render, so that last thing I see is the join GUI.

I get EXC_BAD_ACCESS in void GFXGLWindowTarget::resolveTo(GFXTextureObject* obj), line 40:
glBlitFramebufferEXT(0, 0, getSize().x, getSize().y,
0, 0, glTexture->getWidth(), glTexture->getHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);

Here's the last part of the calstack:
WaterObject::RenderObject() -> WaterPlane::InnerRender() -> ReflectionManager::getRefractTex() -> GFXGLWindowTarget::resolveTo()


The same project works fine on Windows XP.

#1
02/04/2011 (9:00 am)
Tried reproducing this...
I took the Empty Room sample, added a water plane, saved and loaded into it just fine...

Can you send your .mis file and I'll try it here?
#2
02/04/2011 (1:55 pm)
I tried to make a new level in the FPS Example and it looked like all the textures were missing. I was able to create a water plane, but couldn't see it and then it eventually crashed.

www.filefactory.com/file/b548891/n/water_mission.zip
#3
02/04/2011 (3:35 pm)
I have a very similar problem with T3D 1.1 Beta 3 on Windows. If i disable the option "useOcclusionQuery", everything works fine.
#4
03/15/2011 (12:02 pm)
Greetings!

Logged as ticket THREED-1441 for both OSX and Windows.

- Dave
#5
03/29/2011 (5:22 pm)
@Alfio - Can you get me a test level with your crash case? I'm on W7 here and wasn't able to get the test level supplied by Mat to crash with or without UseOcclusionQuery enabled.

Even any repo steps you have for your crash would be helpful.
#6
03/30/2011 (8:23 am)
@Ray - I trying to crashing the T3D with a map that gave me problems earlier, where i due to disable the useOcclusionQuery on the waterplane. But actually now no longer crashes. The only significant changes from the last time it crashed, i think are the ATI drivers (at now 11.2), and the correction of culling like suggested HERE

Edit: I also tried again with a clean version of T3D 1.1 Beta 3, but i have't been able to recreate the error. So it is very likely that the problem was generated from the video drivers.

My configuration:

Windows 7 Ultimate (64bit)
ATI Radeon HD 2600 PRO (drivers 11.2)
#7
03/30/2011 (7:45 pm)
@Alfio

Could possibly be that particle crash bug we had with some video cards and drivers.
#8
03/30/2011 (9:52 pm)
@Tom

I tried just now with the debug version of one of my customers. And effectively when useOcclusionQuery is enabled, i have some error message.

EDIT: In the release version, the errors are not reported.

I'll try to investigate in the coming hours.
#9
03/31/2011 (2:52 pm)
@Alfio - Thanks. The more precise information you can give us, the closer we can get to repoing and fixing it! I believe useOcclusionQuery is enabled by default, and I've never had a crash like the one described. Let me know and we'll look into it more.
#10
03/31/2011 (7:28 pm)
Ok... when i enable the useOcclusionQuery, come this message box:
GFXD3D9OcclusionQuery::getStatus - called on the same frame as begin!

The break is generated on guiTSControl.cpp around the line 294
if ( mReflectPriority > 0 )
   {
      // Get the total reflection priority.
      F32 totalPriority = 0;
      for ( U32 i=0; i < smAwakeTSCtrls.size(); i++ )
         if ( smAwakeTSCtrls[i]->isVisible() )
            totalPriority += smAwakeTSCtrls[i]->mReflectPriority;

      // -----------------------------------------------------------------
      // HERE BORN THE MISTAKE ->
      // -----------------------------------------------------------------
      REFLECTMGR->update(  mReflectPriority / totalPriority,
                           getExtent(),
                           mLastCameraQuery );
      // <- HERE BORN THE MISTAKE
      // -----------------------------------------------------------------
   }

On my case.... the error it seems generated by the 3DRadar gui object. Removing the radar seems that the error does not occur again. =)

EDIT: I tried to enable again the radar and remove the WaterPlane. The error does not occur if the WaterPlane isn't in scene.
#11
03/31/2011 (10:43 pm)
Well that explains why we haven't been able to reproduce it.
#12
04/02/2011 (7:05 am)
On gui/3d/guiTSControl.h:
static const U32& getFrameCount() { return smFrameCount; }
On gui/3d/guiTSControl.cpp:
void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect) 
{
   ....

   if ( mReflectPriority > 0 )
   {
      // Get the total reflection priority.
      F32 totalPriority = 0;
      for ( U32 i=0; i < smAwakeTSCtrls.size(); i++ )
         if ( smAwakeTSCtrls[i]->isVisible() )
            totalPriority += smAwakeTSCtrls[i]->mReflectPriority;

      // -----------------------------------------------------------
      // FOLLOWING THE CALL STACK ->
      // -----------------------------------------------------------
      REFLECTMGR->update(  mReflectPriority / totalPriority,
                           getExtent(),
                           mLastCameraQuery );
      // -----------------------------------------------------------
      // <- FOLLOWING THE CALL STACK
      // -----------------------------------------------------------
   }

   ....

   smFrameCount++;
}
On sceneGraph/reflectionManager.cpp:
void ReflectionManager::update(  F32 timeSlice, 
                                 const Point2I &resolution, 
                                 const CameraQuery &query )
{
   ....

   // Update the reflection score.
   ReflectorList::iterator reflectorIter = mReflectors.begin();
   for ( ; reflectorIter != mReflectors.end(); reflectorIter++ )

      // -----------------------------------------------------------
      // FOLLOWING THE CALL STACK ->
      // -----------------------------------------------------------
      (*reflectorIter)->calcScore( refparams );
      // -----------------------------------------------------------
      // <- FOLLOWING THE CALL STACK
      // -----------------------------------------------------------

   ....
}
On sceneGraph/reflector.cpp:
F32 ReflectorBase::calcScore( const ReflectParams &params )
{
   ....
   // First check the occlusion query to see if we're hidden.
   if (  mDesc->useOcclusionQuery && 
         mOcclusionQuery )
   {

      // -----------------------------------------------------------
      // FOLLOWING THE CALL STACK ->
      // -----------------------------------------------------------
      GFXOcclusionQuery::OcclusionQueryStatus status = mOcclusionQuery->getStatus( false );
      // -----------------------------------------------------------
      // <- FOLLOWING THE CALL STACK
      // -----------------------------------------------------------

      if ( status == GFXOcclusionQuery::Waiting )

   ....
}
On gfx/D3D9/gfxD3D9OcclusionQuery.cpp:
GFXD3D9OcclusionQuery::OcclusionQueryStatus GFXD3D9OcclusionQuery::getStatus( bool block, U32 *data )
{
   ....

#ifdef TORQUE_GATHER_METRICS

      // -----------------------------------------------------------
      // FOLLOWING THE CALL STACK ->
      // -----------------------------------------------------------
   AssertFatal( mBeginFrame < GuiTSCtrl::getFrameCount(), "GFXD3D9OcclusionQuery::getStatus - called on the same frame as begin!" );
      // -----------------------------------------------------------
      // <- FOLLOWING THE CALL STACK
      // -----------------------------------------------------------

   //U32 mTimeSinceEnd = mTimer->getElapsedMs();
   //AssertFatal( mTimeSinceEnd >= 5, "GFXD3DOcculsionQuery::getStatus - less than TickMs since called ::end!" );
#endif

   ....
}
bool GFXD3D9OcclusionQuery::begin()
{
   ....

#ifdef TORQUE_GATHER_METRICS
   mBeginFrame = GuiTSCtrl::getFrameCount();
#endif

   return true;
}

On GuiTSCtrl:OnRender, smFrameCount often is not incremented, then in GFXD3D9OcclusionQuery::GetStatus() is not passed the inspection:
mBeginFrame < GuiTSCtrl:getFrameCount()

Possibbile fix:
Increase smFrameCount at the beginning of the call GuiTSCtrl:OnRender, instead of increase it at the end of the call.