public void NotifyOnDeviceLost( D3D9.Device d3d9Device ) { //Entering critical section this.LockDeviceAccess(); if ( this._d3dPool == D3D9.Pool.Default ) { var textureResources = _getTextureResources( d3d9Device ); if ( textureResources != null ) { LogManager.Instance.Write( "D3D9 device: 0x[{0}] lost. Releasing D3D9 texture: {1}", d3d9Device.ToString(), _name ); // Just free any internal resources, don't call unload() here // because we want the un-touched resource to keep its unloaded status // after device reset. _freeTextureResources( d3d9Device, textureResources ); LogManager.Instance.Write( "Released D3D9 texture: {0}", _name ); } } //Leaving critical section this.UnlockDeviceAccess(); }
public void NotifyOnDeviceDestroy( D3D9.Device d3d9Device ) { //Entering critical section this.LockDeviceAccess(); var textureResources = _getTextureResources( d3d9Device ); if ( textureResources != null ) { LogManager.Instance.Write( "D3D9 device: 0x[{0}] destroy. Releasing D3D9 texture: {1}", d3d9Device.ToString(), _name ); // Destroy surfaces from each mip level. foreach ( var i in this._surfaceList ) { i.DestroyBufferResources( d3d9Device ); } // Just free any internal resources, don't call unload() here // because we want the un-touched resource to keep its unloaded status // after device reset. _freeTextureResources( d3d9Device, textureResources ); textureResources.SafeDispose(); this._mapDeviceToTextureResources.Remove( d3d9Device ); LogManager.Instance.Write( "Released D3D9 texture: {0}", _name ); } //Leaving critical section this.UnlockDeviceAccess(); }