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

Method CalculateResidency

Source/Engine/Streaming/StreamingHandlers.cpp:36–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36int32 TexturesStreamingHandler::CalculateResidency(StreamableResource* resource, float quality)
37{
38 if (quality < ZeroTolerance)
39 return 0;
40 ASSERT(resource);
41 auto& texture = *(StreamingTexture*)resource;
42 ASSERT(texture.IsInitialized());
43 const TextureHeader& header = *texture.GetHeader();
44
45 const int32 totalMipLevels = texture.TotalMipLevels();
46 int32 mipLevels = Math::CeilToInt(quality * (float)totalMipLevels);
47
48 if (header.TextureGroup >= 0 && header.TextureGroup < Streaming::TextureGroups.Count())
49 {
50 const TextureGroup& group = Streaming::TextureGroups[header.TextureGroup];
51 mipLevels = Math::Clamp(mipLevels + group.MipLevelsBias, group.MipLevelsMin, group.MipLevelsMax);
52#if USE_EDITOR
53 // Simulate per-platform limit in Editor
54 int32 max;
55 if (group.MipLevelsMaxPerPlatform.TryGet(PLATFORM_TYPE, max))
56 mipLevels = Math::Min(mipLevels, max);
57#endif
58 }
59
60 if (mipLevels > 0 && mipLevels < texture._minMipCountBlockCompressed && texture._isBlockCompressed)
61 {
62 // Block compressed textures require minimum size of block size (eg. 4 for BC formats)
63 mipLevels = texture._minMipCountBlockCompressed;
64 }
65
66 return Math::Clamp(mipLevels, 0, totalMipLevels);
67}
68
69int32 TexturesStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency)
70{

Callers 1

UpdateResourceFunction · 0.80

Calls 14

ClampFunction · 0.85
MemoryClearFunction · 0.85
IsInRangeFunction · 0.85
GetBufferStartTimeMethod · 0.80
CeilToIntFunction · 0.50
MinFunction · 0.50
IsInitializedMethod · 0.45
CountMethod · 0.45
TryGetMethod · 0.45
GetLODsCountMethod · 0.45
ClearMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected