Fix crash when streaming texture with unsupported format by the GPU driver
This commit is contained in:
@@ -497,6 +497,8 @@ bool GPUTexture::Init(const GPUTextureDescription& desc)
|
||||
if (OnInit())
|
||||
{
|
||||
ReleaseGPU();
|
||||
_desc.Clear();
|
||||
_residentMipLevels = 0;
|
||||
LOG(Warning, "Cannot initialize texture. Description: {0}", desc.ToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -155,6 +155,13 @@ void UpdateResource(StreamableResource* resource, DateTime now, double currentTi
|
||||
resource->RequestStreamingUpdate();
|
||||
return;
|
||||
}
|
||||
else if (resource->GetAllocatedResidency() < targetResidency)
|
||||
{
|
||||
// Allocation failed (eg. texture format is not supported or run out of memory)
|
||||
resource->Streaming.TargetResidency = 0;
|
||||
resource->Streaming.LastUpdate = DateTime::MaxValue().Ticks;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate residency level to stream in (resources may want to increase/decrease it's quality in steps rather than at once)
|
||||
|
||||
Reference in New Issue
Block a user