Commit d42ce617 authored by hybrid's avatar hybrid

Added a check method to query the device reset event for D3D drivers. Since in...

Added a check method to query the device reset event for D3D drivers. Since in the case of a reset the content of all RTTs are lost, it's required to become aware of this fact.
The current solution is just a simply check which works with lots about the drivers. A cleaner solution would return all structures which have to be regenerated. A new enum is already created for this reason, but not yet implemented. However, the interface of the new checkDriverReset method might change in the near future...

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1630 dfc29bdd-3216-0410-991c-e03cc46cb475
parent be924b27
...@@ -65,6 +65,17 @@ namespace video ...@@ -65,6 +65,17 @@ namespace video
ETS_COUNT ETS_COUNT
}; };
enum E_LOST_RESSOURCE
{
//! The whole device/driver is lost
ELR_DEVICE = 1,
//! All texture are lost, rare problem
ELR_TEXTURES = 2,
//! The Render Target Textures are lost, typical problem for D3D
ELR_RTTS = 4,
//! The HW buffers are lost, will be recreated automatically, but might require some more time this frame
ELR_HW_BUFFERS = 8
};
//! Interface to driver which is able to perform 2d and 3d graphics functions. //! Interface to driver which is able to perform 2d and 3d graphics functions.
/** This interface is one of the most important interfaces of /** This interface is one of the most important interfaces of
...@@ -122,6 +133,12 @@ namespace video ...@@ -122,6 +133,12 @@ namespace video
\param flag When true the feature is disabled, otherwise it is enabled. */ \param flag When true the feature is disabled, otherwise it is enabled. */
virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0; virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
//! Check if the driver was recently reset.
/** For d3d devices you will need to recreate the RTTs if the
driver was reset. Should be queried right after beginScene().
*/
virtual bool checkDriverReset() =0;
//! Sets transformation matrices. //! Sets transformation matrices.
/** \param state Transformation type to be set, e.g. view, /** \param state Transformation type to be set, e.g. view,
world, or projection. world, or projection.
......
...@@ -33,7 +33,8 @@ CD3D8Driver::CD3D8Driver(const core::dimension2d<s32>& screenSize, HWND window, ...@@ -33,7 +33,8 @@ CD3D8Driver::CD3D8Driver(const core::dimension2d<s32>& screenSize, HWND window,
D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0),
WindowId(0), SceneSourceRect(0), WindowId(0), SceneSourceRect(0),
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0), LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0),
MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false) MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false),
DriverWasReset(true)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CD3D8Driver"); setDebugName("CD3D8Driver");
...@@ -441,6 +442,7 @@ bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color, ...@@ -441,6 +442,7 @@ bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color,
bool CD3D8Driver::endScene() bool CD3D8Driver::endScene()
{ {
CNullDriver::endScene(); CNullDriver::endScene();
DriverWasReset=false;
HRESULT hr = pID3DDevice->EndScene(); HRESULT hr = pID3DDevice->EndScene();
if (FAILED(hr)) if (FAILED(hr))
...@@ -491,6 +493,7 @@ bool CD3D8Driver::reset() ...@@ -491,6 +493,7 @@ bool CD3D8Driver::reset()
tex->Release(); tex->Release();
} }
} }
DriverWasReset=true;
HRESULT hr = pID3DDevice->Reset(&present); HRESULT hr = pID3DDevice->Reset(&present);
......
...@@ -202,6 +202,7 @@ namespace video ...@@ -202,6 +202,7 @@ namespace video
//! \param enable: If true, enable the clipping plane else disable it. //! \param enable: If true, enable the clipping plane else disable it.
virtual void enableClipPlane(u32 index, bool enable); virtual void enableClipPlane(u32 index, bool enable);
virtual bool checkDriverReset() {return DriverWasReset;}
private: private:
// enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
...@@ -293,6 +294,7 @@ namespace video ...@@ -293,6 +294,7 @@ namespace video
f32 MaxLightDistance; f32 MaxLightDistance;
s32 LastSetLight; s32 LastSetLight;
bool DeviceLost; bool DeviceLost;
bool DriverWasReset;
SColorf AmbientLight; SColorf AmbientLight;
}; };
......
...@@ -33,7 +33,7 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<s32>& screenSize, HWND window, ...@@ -33,7 +33,7 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<s32>& screenSize, HWND window,
WindowId(0), SceneSourceRect(0), WindowId(0), SceneSourceRect(0),
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0), LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0),
MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false), MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false),
Fullscreen(fullscreen) Fullscreen(fullscreen), DriverWasReset(true)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CD3D9Driver"); setDebugName("CD3D9Driver");
...@@ -510,6 +510,7 @@ bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color, ...@@ -510,6 +510,7 @@ bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color,
bool CD3D9Driver::endScene() bool CD3D9Driver::endScene()
{ {
CNullDriver::endScene(); CNullDriver::endScene();
DriverWasReset=false;
HRESULT hr = pID3DDevice->EndScene(); HRESULT hr = pID3DDevice->EndScene();
if (FAILED(hr)) if (FAILED(hr))
...@@ -2267,6 +2268,7 @@ bool CD3D9Driver::reset() ...@@ -2267,6 +2268,7 @@ bool CD3D9Driver::reset()
tex->Release(); tex->Release();
} }
} }
DriverWasReset=true;
HRESULT hr = pID3DDevice->Reset(&present); HRESULT hr = pID3DDevice->Reset(&present);
......
...@@ -223,8 +223,10 @@ namespace video ...@@ -223,8 +223,10 @@ namespace video
virtual void enableClipPlane(u32 index, bool enable); virtual void enableClipPlane(u32 index, bool enable);
//! Returns the graphics card vendor name. //! Returns the graphics card vendor name.
virtual core::stringc getVendorInfo() {return vendorName;}; virtual core::stringc getVendorInfo() {return vendorName;}
//! Check if the driver was recently reset.
virtual bool checkDriverReset() {return DriverWasReset;}
private: private:
// enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
...@@ -330,6 +332,7 @@ namespace video ...@@ -330,6 +332,7 @@ namespace video
s32 LastSetLight; s32 LastSetLight;
bool DeviceLost; bool DeviceLost;
bool Fullscreen; bool Fullscreen;
bool DriverWasReset;
SColorf AmbientLight; SColorf AmbientLight;
......
...@@ -502,7 +502,7 @@ namespace video ...@@ -502,7 +502,7 @@ namespace video
virtual void enableClipPlane(u32 index, bool enable); virtual void enableClipPlane(u32 index, bool enable);
//! Returns the graphics card vendor name. //! Returns the graphics card vendor name.
virtual core::stringc getVendorInfo() {return "Not available on this driver.";}; virtual core::stringc getVendorInfo() {return "Not available on this driver.";}
//! Only used by the engine internally. //! Only used by the engine internally.
virtual void setAllowZWriteOnTransparent(bool flag) virtual void setAllowZWriteOnTransparent(bool flag)
...@@ -512,6 +512,7 @@ namespace video ...@@ -512,6 +512,7 @@ namespace video
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size,
const c8* name=0); const c8* name=0);
virtual bool checkDriverReset() {return false;}
protected: protected:
//! deletes all textures //! deletes all textures
......
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