| 64 | } |
| 65 | |
| 66 | void 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 |
nothing calls this directly
no test coverage detected