|
|
@@ -74,20 +74,32 @@ void TextureCube::OnDeviceLost()
|
|
|
void TextureCube::OnDeviceReset()
|
|
|
{
|
|
|
// If has a file name, reload through the resource cache. Otherwise just recreate.
|
|
|
- if (!GetName().Trimmed().Empty())
|
|
|
- dataLost_ = !GetSubsystem<ResourceCache>()->ReloadResource(this);
|
|
|
- else
|
|
|
+ if (!object_)
|
|
|
+ {
|
|
|
+ if (!GetName().Trimmed().Empty())
|
|
|
+ dataLost_ = !GetSubsystem<ResourceCache>()->ReloadResource(this);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Create();
|
|
|
+ dataLost_ = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (dataPending_)
|
|
|
{
|
|
|
- Create();
|
|
|
- dataLost_ = true;
|
|
|
+ if (!GetName().Trimmed().Empty())
|
|
|
+ dataLost_ = !GetSubsystem<ResourceCache>()->ReloadResource(this);
|
|
|
+ else
|
|
|
+ dataLost_ = true;
|
|
|
}
|
|
|
+
|
|
|
+ dataPending_ = false;
|
|
|
}
|
|
|
|
|
|
void TextureCube::Release()
|
|
|
{
|
|
|
if (object_)
|
|
|
{
|
|
|
- if (!graphics_)
|
|
|
+ if (!graphics_ || graphics_->IsDeviceLost())
|
|
|
return;
|
|
|
|
|
|
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
|
|
|
@@ -172,6 +184,13 @@ bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int wi
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if (graphics_->IsDeviceLost())
|
|
|
+ {
|
|
|
+ LOGWARNING("Texture data assignment while device is lost");
|
|
|
+ dataPending_ = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
if (IsCompressed())
|
|
|
{
|
|
|
x &= ~3;
|
|
|
@@ -225,7 +244,7 @@ bool TextureCube::Load(Deserializer& source)
|
|
|
Graphics* graphics = GetSubsystem<Graphics>();
|
|
|
if (!graphics)
|
|
|
return true;
|
|
|
-
|
|
|
+
|
|
|
// If over the texture budget, see if materials can be freed to allow textures to be freed
|
|
|
CheckTextureBudget(GetTypeStatic());
|
|
|
|
|
|
@@ -280,6 +299,13 @@ 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;
|
|
|
@@ -455,6 +481,12 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if (graphics_->IsDeviceLost())
|
|
|
+ {
|
|
|
+ LOGWARNING("Getting texture data while device is lost");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
graphics_->SetTextureForUpdate(const_cast<TextureCube*>(this));
|
|
|
|
|
|
if (!IsCompressed())
|
|
|
@@ -465,7 +497,7 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
graphics_->SetTexture(0, 0);
|
|
|
return true;
|
|
|
#else
|
|
|
- LOGERROR("Get texture data not supported");
|
|
|
+ LOGERROR("Getting texture data not supported");
|
|
|
return false;
|
|
|
#endif
|
|
|
}
|
|
|
@@ -474,11 +506,14 @@ bool TextureCube::Create()
|
|
|
{
|
|
|
Release();
|
|
|
|
|
|
- if (!graphics_)
|
|
|
+ if (!graphics_ || !width_ || !height_)
|
|
|
return false;
|
|
|
|
|
|
- if (!width_ || !height_)
|
|
|
+ if (graphics_->IsDeviceLost())
|
|
|
+ {
|
|
|
+ LOGWARNING("Texture creation while device is lost");
|
|
|
return false;
|
|
|
+ }
|
|
|
|
|
|
glGenTextures(1, &object_);
|
|
|
|