diff --git a/Source/Editor/Cooker/Steps/CookAssetsStep.cpp b/Source/Editor/Cooker/Steps/CookAssetsStep.cpp index 703b4179a..3e00b8c99 100644 --- a/Source/Editor/Cooker/Steps/CookAssetsStep.cpp +++ b/Source/Editor/Cooker/Steps/CookAssetsStep.cpp @@ -631,7 +631,7 @@ bool ProcessTextureBase(CookAssetsStep::AssetCookData& data) LOG(Error, "Failed to convert texture {0} from format {1} to {2}", asset->ToString(), (int32)format, (int32)targetFormat); return true; } - textureData = &textureDataSrc; + textureData = &textureDataTmp1; } if (assetHeader->MipLevels > mipLevelsMax) @@ -656,7 +656,9 @@ bool ProcessTextureBase(CookAssetsStep::AssetCookData& data) } // Adjust texture header + data.InitData.CustomData.Allocate(sizeof(TextureHeader)); auto& header = *(TextureHeader*)data.InitData.CustomData.Get(); + header = *assetHeader; header.Width = textureData->Width; header.Height = textureData->Height; header.Depth = textureData->Depth; @@ -664,7 +666,7 @@ bool ProcessTextureBase(CookAssetsStep::AssetCookData& data) header.MipLevels = textureData->GetMipLevels(); // Serialize texture data into the asset chunks - for (int32 mipIndex = 0; mipIndex < textureData->GetMipLevels(); mipIndex++) + for (int32 mipIndex = 0; mipIndex < header.MipLevels; mipIndex++) { auto chunk = New(); data.InitData.Header.Chunks[mipIndex] = chunk; diff --git a/Source/Engine/Graphics/Textures/StreamingTexture.cpp b/Source/Engine/Graphics/Textures/StreamingTexture.cpp index e8e7835f3..f5a2a2ed2 100644 --- a/Source/Engine/Graphics/Textures/StreamingTexture.cpp +++ b/Source/Engine/Graphics/Textures/StreamingTexture.cpp @@ -361,6 +361,7 @@ protected: if (!_streamingTexture->GetOwner()->GetMipDataCustomPitch(absoluteMipIndex, rowPitch, slicePitch)) texture->ComputePitch(_mipIndex, rowPitch, slicePitch); _data.Link(data); + ASSERT(data.Length() >= slicePitch * arraySize); // Update all array slices const byte* dataSource = data.Get();