Fix deadlock in asset thumbnails rendering queue when texture streaming fails

#2057
This commit is contained in:
Wojtek Figat
2023-12-14 16:05:15 +01:00
parent 60202a3add
commit d7b17ae0a6
7 changed files with 37 additions and 8 deletions

View File

@@ -296,6 +296,7 @@ Task* StreamingTexture::UpdateAllocation(int32 residency)
// Setup texture
if (texture->Init(desc))
{
Streaming.Error = true;
LOG(Error, "Cannot allocate texture {0}.", ToString());
}
if (allocatedResidency != 0)

View File

@@ -223,6 +223,11 @@ void TextureBase::SetTextureGroup(int32 textureGroup)
}
}
bool TextureBase::HasStreamingError() const
{
return _texture.Streaming.Error;
}
BytesContainer TextureBase::GetMipData(int32 mipIndex, int32& rowPitch, int32& slicePitch)
{
BytesContainer result;

View File

@@ -148,6 +148,11 @@ public:
/// </summary>
API_PROPERTY() void SetTextureGroup(int32 textureGroup);
/// <summary>
/// Returns true if texture streaming failed (eg. pixel format is unsupported or texture data cannot be uploaded to GPU due to memory limit).
/// </summary>
API_PROPERTY() bool HasStreamingError() const;
public:
/// <summary>
/// Gets the mip data.

View File

@@ -111,8 +111,9 @@ public:
struct StreamingCache
{
int64 LastUpdate = 0;
int32 TargetResidency = 0;
int64 TargetResidencyChange = 0;
int32 TargetResidency = 0;
bool Error = false;
SamplesBuffer<float, 5> QualitySamples;
};
@@ -131,7 +132,8 @@ public:
/// <summary>
/// Stops the streaming (eg. on streaming fail).
/// </summary>
void ResetStreaming();
/// <param name="error">True if streaming failed.</param>
void ResetStreaming(bool error = true);
protected:

View File

@@ -84,8 +84,9 @@ void StreamableResource::RequestStreamingUpdate()
Streaming.LastUpdate = 0;
}
void StreamableResource::ResetStreaming()
void StreamableResource::ResetStreaming(bool error)
{
Streaming.Error = error;
Streaming.TargetResidency = 0;
Streaming.LastUpdate = DateTime::MaxValue().Ticks;
}