MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / FromTextureData

Method FromTextureData

Source/Engine/Graphics/Textures/TextureBase.cpp:1009–1047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1007}
1008
1009void TextureBase::InitData::FromTextureData(const TextureData& textureData, bool generateMips)
1010{
1011 Format = textureData.Format;
1012 Width = textureData.Width;
1013 Height = textureData.Height;
1014 ArraySize = textureData.GetArraySize();
1015 if (generateMips)
1016 Mips.Resize(MipLevelsCount(textureData.Width, textureData.Height));
1017 else
1018 Mips.Resize(textureData.GetMipLevels());
1019
1020 for (int32 mipIndex = 0; mipIndex < textureData.GetMipLevels(); mipIndex++)
1021 {
1022 auto& mip = Mips[mipIndex];
1023 auto& data = *textureData.GetData(0, mipIndex);
1024 mip.Data.Allocate(data.Data.Length() * ArraySize);
1025 mip.RowPitch = data.RowPitch;
1026 mip.SlicePitch = data.Data.Length();
1027
1028 byte* dst = mip.Data.Get();
1029 for (int32 arrayIndex = 0; arrayIndex < ArraySize; arrayIndex++)
1030 {
1031 auto& d = *textureData.GetData(arrayIndex, mipIndex);
1032 ASSERT(data.RowPitch == d.RowPitch);
1033 ASSERT(data.Data.Length() == d.Data.Length());
1034 Platform::MemoryCopy(dst, d.Data.Get(), d.Data.Length());
1035 dst += data.Data.Length();
1036 ASSERT((int32)(dst - mip.Data.Get()) <= mip.Data.Length());
1037 }
1038 }
1039
1040 if (generateMips)
1041 {
1042 for (int32 mipIndex = textureData.GetMipLevels(); mipIndex < Mips.Count(); mipIndex++)
1043 {
1044 GenerateMip(mipIndex, true);
1045 }
1046 }
1047}

Callers 2

LoadFileMethod · 0.80
SetProbeDataMethod · 0.80

Calls 9

MipLevelsCountFunction · 0.85
GetArraySizeMethod · 0.80
GetMipLevelsMethod · 0.80
ResizeMethod · 0.45
GetDataMethod · 0.45
AllocateMethod · 0.45
LengthMethod · 0.45
GetMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected