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

Method WaitForAsset

Source/Engine/Particles/ParticleEmitter.cpp:66–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void ParticleEmitter::WaitForAsset(Asset* asset)
67{
68 // TODO: make a tool for it?
69 if (auto* texture = Cast<TextureBase>(asset))
70 {
71 // Wait for asset to be loaded
72 if (!texture->WaitForLoaded() && !IsInMainThread() && texture->GetTexture())
73 {
74 PROFILE_CPU_NAMED("WaitForTexture");
75
76 // Mark as used by rendering and wait for streaming to load it in
77 double waitTimeSeconds = 10000;
78 double now = Platform::GetTimeSeconds();
79 double end = now + waitTimeSeconds;
80 const int32 mipLevels = texture->GetMipLevels();
81 constexpr float requestedResidency = 0.7f;
82 const int32 minMipLevels = Math::Max(Math::Min(mipLevels, 7), (int32)(requestedResidency * (float)mipLevels));
83 while (texture->GetResidentMipLevels() < minMipLevels &&
84 now < end &&
85 !texture->HasStreamingError())
86 {
87 texture->GetTexture()->LastRenderTime = now;
88 Platform::Sleep(1);
89 now = Platform::GetTimeSeconds();
90 }
91 }
92 }
93}
94
95#if COMPILE_WITH_PARTICLE_GPU_GRAPH && COMPILE_WITH_SHADER_COMPILER
96

Callers

nothing calls this directly

Calls 8

IsInMainThreadFunction · 0.85
WaitForLoadedMethod · 0.80
GetTextureMethod · 0.80
GetMipLevelsMethod · 0.80
GetResidentMipLevelsMethod · 0.80
HasStreamingErrorMethod · 0.80
MaxFunction · 0.50
MinFunction · 0.50

Tested by

no test coverage detected