From 23efaed29ed2d11e47449d56a96cd43e013231ae Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 24 May 2024 14:58:57 +0200 Subject: [PATCH] Fix Model SDF texture streaming to properly mark highest loaded mip as resident --- .../Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h b/Source/Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h index 2fa98da52..9b87fb636 100644 --- a/Source/Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h +++ b/Source/Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h @@ -83,12 +83,16 @@ protected: auto texture = _texture.Get(); if (texture) { - // Check if the new mips has been just uploaded if (_mipIndex == texture->HighestResidentMipIndex() - 1) { - // Mark as mip loaded + // Mark the new mip as loaded texture->SetResidentMipLevels(texture->ResidentMipLevels() + 1); } + else + { + // Mark the new mip and all lower ones as loaded (eg. when loading Model SDF texture mips at once but out of order) + texture->SetResidentMipLevels(Math::Max(texture->ResidentMipLevels(), texture->MipLevels() - _mipIndex)); + } } // Base