Commit b99b8298 authored by nadro's avatar nadro

- Fixed issue related to D3D9 device lost and broken render targets. Thanks...

- Fixed issue related to D3D9 device lost and broken render targets. Thanks CuteAlien for report this bug.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5078 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9c337089
......@@ -2833,6 +2833,11 @@ bool CD3D9Driver::reset()
u32 i;
os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION);
for (i = 0; i<RenderTargets.size(); ++i)
{
if (RenderTargets[i]->getDriverType() == EDT_DIRECT3D9)
static_cast<CD3D9RenderTarget*>(RenderTargets[i])->releaseSurfaces();
}
for (i=0; i<Textures.size(); ++i)
{
if (Textures[i].Surface->isRenderTarget())
......@@ -2861,6 +2866,12 @@ bool CD3D9Driver::reset()
if (DepthStencilSurface)
DepthStencilSurface->Release();
if (BackBufferSurface)
{
BackBufferSurface->Release();
BackBufferSurface = 0;
}
DriverWasReset=true;
HRESULT hr = pID3DDevice->Reset(&present);
......@@ -2875,6 +2886,11 @@ bool CD3D9Driver::reset()
if (Textures[i].Surface->isRenderTarget())
((CD3D9Texture*)(Textures[i].Surface))->createRenderTarget();
}
for (i = 0; i<RenderTargets.size(); ++i)
{
if (RenderTargets[i]->getDriverType() == EDT_DIRECT3D9)
static_cast<CD3D9RenderTarget*>(RenderTargets[i])->generateSurfaces();
}
// restore occlusion queries
for (i=0; i<OcclusionQueries.size(); ++i)
......
......@@ -107,7 +107,6 @@ namespace irr
if (DepthStencilSurface)
{
DepthStencilSurface->Release();
DepthStencilSurface = 0;
}
......@@ -180,6 +179,50 @@ namespace irr
{
return DepthStencilSurface;
}
void CD3D9RenderTarget::releaseSurfaces()
{
for (u32 i = 0; i < Surface.size(); ++i)
{
if (Surface[i])
{
Surface[i]->Release();
Surface[i] = 0;
}
}
if (DepthStencilSurface)
{
DepthStencilSurface->Release();
DepthStencilSurface = 0;
}
}
void CD3D9RenderTarget::generateSurfaces()
{
for (u32 i = 0; i < Surface.size(); ++i)
{
if (!Surface[i] && Texture[i])
{
IDirect3DTexture9* currentTexture = static_cast<CD3D9Texture*>(Texture[i])->getDX9Texture();
IDirect3DSurface9* currentSurface = 0;
currentTexture->GetSurfaceLevel(0, &currentSurface);
Surface[i] = currentSurface;
}
}
if (!DepthStencilSurface && DepthStencil)
{
IDirect3DTexture9* currentTexture = static_cast<CD3D9Texture*>(DepthStencil)->getDX9Texture();
IDirect3DSurface9* currentSurface = 0;
currentTexture->GetSurfaceLevel(0, &currentSurface);
DepthStencilSurface = currentSurface;
}
}
}
}
......
......@@ -39,6 +39,10 @@ namespace irr
IDirect3DSurface9* getDepthStencilSurface() const;
void releaseSurfaces();
void generateSurfaces();
protected:
core::dimension2d<u32> Size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment