During the startup process my application creates 2 windows on 2 monitors. During the startup it also creates an RTT texture.
When the RTT texture is created for the 2 devices Ogre creates a texture surface for each device. It then attempts to copy the content of the surfaces from one to the other. This causes a crash.
The copying of the textures is done by the D3DXLoadSurfaceFromSurface() function in D3D9HardwarePixelBuffer::blitToMemory which is called from D3D9HardwarePixelBuffer::bind function. The function fails to load the surface reporting a "loss device" and as a consequece throws an exception which crashes the system.
As far as I can tell this copying action is ment to ensure that manually loaded textures have the same content on newly created devices as in the original device. However the RTT at this point has never been rendered end therefor has no content to copy.
To fix this in the function D3D9HardwarePixelBuffer::bind (line 111) I changed the statement
Code: Select all
if (isNewBuffer && mOwnerTexture->isManuallyLoaded())
Code: Select all
if (isNewBuffer && mOwnerTexture->isLoaded() && mOwnerTexture->isManuallyLoaded())
Questions:
1. Does this look like a correct analysis of the problem?
2. Notice that the fix does not relate to RTT textures specifically but rather to all unloaded textures. Is this correct or should I limit the fix to RTT textures only? (I haven't seen the crash in non-RTT textures. However, if my analysis is correct, then executing the copying code on non-initialized textures seems silly)
I have not pushed this fix to the repo. I await your comments
P.S.
Another interesting but probably irrelavent point is that if I create my windows with anti-alias (FSAA) enabled. The crash does not occur.