Browse Source

Return "success" if attempting to load texture while device is lost. This is so that the texture is not deleted from the resource system due to initial failure.

Lasse Öörni 13 years ago
parent
commit
d1530432fd

+ 8 - 7
Engine/Graphics/Direct3D9/D3D9Texture2D.cpp

@@ -59,6 +59,14 @@ bool Texture2D::Load(Deserializer& source)
     if (!graphics)
         return true;
     
+    // If device is lost, retry later
+    if (graphics_->IsDeviceLost())
+    {
+        LOGWARNING("Texture load while device is lost");
+        dataPending_ = true;
+        return true;
+    }
+    
     // If over the texture budget, see if materials can be freed to allow textures to be freed
     CheckTextureBudget(GetTypeStatic());
     
@@ -286,13 +294,6 @@ bool Texture2D::Load(SharedPtr<Image> image, bool useAlpha)
         return false;
     }
     
-    if (graphics_ && graphics_->IsDeviceLost())
-    {
-        LOGWARNING("Texture load while device is lost");
-        dataPending_ = true;
-        return false;
-    }
-    
     unsigned memoryUse = sizeof(Texture2D);
     
     int quality = QUALITY_HIGH;

+ 8 - 7
Engine/Graphics/Direct3D9/D3D9TextureCube.cpp

@@ -291,6 +291,14 @@ bool TextureCube::Load(Deserializer& source)
     if (!graphics)
         return true;
     
+    // If device is lost, retry later
+    if (graphics_->IsDeviceLost())
+    {
+        LOGWARNING("Texture load while device is lost");
+        dataPending_ = true;
+        return true;
+    }
+    
     // If over the texture budget, see if materials can be freed to allow textures to be freed
     CheckTextureBudget(GetTypeStatic());
     
@@ -345,13 +353,6 @@ bool TextureCube::Load(CubeMapFace face, SharedPtr<Image> image, bool useAlpha)
         return false;
     }
     
-    if (graphics_ && graphics_->IsDeviceLost())
-    {
-        LOGWARNING("Texture load while device is lost");
-        dataPending_ = true;
-        return false;
-    }
-    
     unsigned memoryUse = 0;
     
     int quality = QUALITY_HIGH;

+ 9 - 8
Engine/Graphics/OpenGL/OGLTexture2D.cpp

@@ -59,7 +59,15 @@ bool Texture2D::Load(Deserializer& source)
     Graphics* graphics = GetSubsystem<Graphics>();
     if (!graphics)
         return true;
-
+    
+    // If device is lost, retry later
+    if (graphics_->IsDeviceLost())
+    {
+        LOGWARNING("Texture load while device is lost");
+        dataPending_ = true;
+        return true;
+    }
+    
     // If over the texture budget, see if materials can be freed to allow textures to be freed
     CheckTextureBudget(GetTypeStatic());
     
@@ -233,13 +241,6 @@ bool Texture2D::Load(SharedPtr<Image> image, bool useAlpha)
         return false;
     }
     
-    if (graphics_ && graphics_->IsDeviceLost())
-    {
-        LOGWARNING("Texture load while device is lost");
-        dataPending_ = true;
-        return false;
-    }
-    
     unsigned memoryUse = sizeof(Texture2D);
     
     int quality = QUALITY_HIGH;

+ 8 - 7
Engine/Graphics/OpenGL/OGLTextureCube.cpp

@@ -245,6 +245,14 @@ bool TextureCube::Load(Deserializer& source)
     if (!graphics)
         return true;
     
+    // If device is lost, retry later
+    if (graphics_->IsDeviceLost())
+    {
+        LOGWARNING("Texture load while device is lost");
+        dataPending_ = true;
+        return true;
+    }
+    
     // If over the texture budget, see if materials can be freed to allow textures to be freed
     CheckTextureBudget(GetTypeStatic());
     
@@ -299,13 +307,6 @@ bool TextureCube::Load(CubeMapFace face, SharedPtr<Image> image, bool useAlpha)
         return false;
     }
     
-    if (graphics_ && graphics_->IsDeviceLost())
-    {
-        LOGWARNING("Texture load while device is lost");
-        dataPending_ = true;
-        return false;
-    }
-    
     unsigned memoryUse = 0;
     
     int quality = QUALITY_HIGH;