Game Development Community

StretchRect Errors

by Gary Hoffmann · in Torque 3D Professional · 08/11/2009 (5:40 pm) · 2 replies

While it doesn't seem to cause any problems visually (at least that I'm noticing). In Beta 5, the Debug output is constantly throwing:

Direct3D9: (ERROR) :Same surface specified for both Src and Dest. StretchRect fails
D3D9 Helper: IDirect3DDevice9::StretchRect failed: D3DERR_INVALIDCALL


The error is comming from GFXD3D9TextureTarget::resolve where mTargets[1] has the same memory address as surf.


Callstack:

> TestProject_DEBUG.dll!GFXD3D9TextureTarget::resolve() Line 193 C++
TestProject_DEBUG.dll!RenderTexTargetBinManager::_onPostRender() Line 311 C++
TestProject_DEBUG.dll!AdvancedLightBinManager::render(SceneState * state=0x098ef4b8) Line 304 C++
TestProject_DEBUG.dll!RenderPassManager::render(SceneState * state=0x098ef4b8) Line 293 C++
TestProject_DEBUG.dll!SceneState::renderCurrentImages() Line 160 C++
TestProject_DEBUG.dll!SceneGraph::_traverseSceneTree(SceneState * pState=0x098ef4b8) Line 234 C++
TestProject_DEBUG.dll!SceneGraph::renderScene(SceneState * sceneState=0x098ef4b8, unsigned int objectMask=4294967295) Line 196 C++
TestProject_DEBUG.dll!PlaneReflector::updateReflection(const ReflectParams & params={...}) Line 509 C++
TestProject_DEBUG.dll!ReflectionManager::update(float timeSlice=1.0000000, const Point2I & resolution={...}, const CameraQuery & query={...}) Line 113 C++
TestProject_DEBUG.dll!GuiTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...}) Line 141 C++
TestProject_DEBUG.dll!GameTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...}) Line 140 C++
TestProject_DEBUG.dll!GuiCanvas::renderFrame(bool preRenderOnly=false, bool bufferSwap=true) Line 1498 C++
TestProject_DEBUG.dll!GuiCanvas::handlePaintEvent(unsigned int did=0) Line 206 C++
TestProject_DEBUG.dll!fastdelegate::FastDelegate1<unsigned int,void>::operator()(unsigned int p1=0) Line 993 + 0x1a bytes C++
TestProject_DEBUG.dll!Signal<void __cdecl(unsigned int)>::trigger(unsigned int a=0) Line 323 + 0x17 bytes C++
TestProject_DEBUG.dll!Journal::Call<Signal<void __cdecl(unsigned int)>,unsigned int>(Signal<void __cdecl(unsigned int)> * obj=0x03ebc9b8, void (unsigned int)* method=0x10560e96, unsigned int a=0) Line 541 + 0xa8 bytes C++
TestProject_DEBUG.dll!JournaledSignal<void __cdecl(unsigned int)>::trigger(unsigned int a=0) Line 52 + 0x12 bytes C++
TestProject_DEBUG.dll!GuiCanvas::paint() Line 1329 C++
TestProject_DEBUG.dll!fastdelegate::FastDelegate0<void>::operator()() Line 908 + 0x16 bytes C++
TestProject_DEBUG.dll!Signal<void __cdecl(void)>::trigger() Line 312 + 0x13 bytes C++
TestProject_DEBUG.dll!Process::processEvents() Line 62 C++
TestProject_DEBUG.dll!StandardMainLoop::doMainLoop() Line 517 + 0x5 bytes C++
TestProject_DEBUG.dll!torque_enginetick() Line 78 + 0x5 bytes C++
TestProject_DEBUG.dll!TorqueMain(int argc=2, const char * * argv=0x004eaf18) Line 369 + 0x5 bytes C++
TestProject_DEBUG.dll!torque_winmain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * __formal=0x00000000, char * lpszCmdLine=0x006465fb, HINSTANCE__ * __formal=0x00000000) Line 423 + 0x17 bytes C++
TestProject_DEBUG.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpszCmdLine=0x006465fb, int nCommandShow=1) Line 47 + 0x16 bytes C++
TestProject_DEBUG.exe!__tmainCRTStartup() Line 263 + 0x2c bytes C
TestProject_DEBUG.exe!WinMainCRTStartup() Line 182 C
kernel32.dll!7505eccb()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!7701d24d()
ntdll.dll!7701d45f()

#1
08/17/2009 (3:59 pm)
Logged as THREED-655
#2
08/17/2009 (5:41 pm)
This issue has already been fixed in the trunk.

As a "quick fix", you can replace GFXD3D9TextureTarget::resolve with this:
void GFXD3D9TextureTarget::resolve()
{
   for (U32 i = 0; i < MaxRenderSlotId; i++)
   {
      // We use existance @ mTextures as a flag that we need to copy
      // data from the rendertarget into the texture.
      if (mTextures[i])
      {
         IDirect3DSurface9 *surf;         
         mTextures[i]->get2DTex()->GetSurfaceLevel( 0, &surf );         

         if ( surf != mTargets[i] )
         {
            AssertFatal(dynamic_cast<GFXD3D9Device*>(getOwningDevice()), "Incorrect device type!");
            GFXD3D9Device* d = static_cast<GFXD3D9Device*>(getOwningDevice());
            d->getDevice()->StretchRect(mTargets[i], NULL, surf, NULL, D3DTEXF_NONE );
         }

         surf->Release();
      }
   }