| 219 | } |
| 220 | |
| 221 | void StreamingSystem::Job(int32 index) |
| 222 | { |
| 223 | PROFILE_CPU_NAMED("Streaming.Job"); |
| 224 | PROFILE_MEM(ContentStreaming); |
| 225 | |
| 226 | // TODO: use streaming settings |
| 227 | const double ResourceUpdatesInterval = 0.1; |
| 228 | int32 MaxResourcesPerUpdate = 50; |
| 229 | |
| 230 | // Start update |
| 231 | ScopeLock lock(ResourcesLock); |
| 232 | const int32 resourcesCount = Resources.Count(); |
| 233 | int32 resourcesUpdates = Math::Min(MaxResourcesPerUpdate, resourcesCount); |
| 234 | const double currentTime = Platform::GetTimeSeconds(); |
| 235 | |
| 236 | // Update high priority queue and then rest of the resources |
| 237 | // Note: resources in the update queue are updated always, while others only between specified intervals |
| 238 | int32 resourcesChecks = resourcesCount; |
| 239 | while (resourcesUpdates > 0 && resourcesChecks-- > 0) |
| 240 | { |
| 241 | // Move forward |
| 242 | LastUpdateResourcesIndex++; |
| 243 | if (LastUpdateResourcesIndex >= resourcesCount) |
| 244 | LastUpdateResourcesIndex = 0; |
| 245 | |
| 246 | // Peek resource |
| 247 | const auto resource = Resources[LastUpdateResourcesIndex]; |
| 248 | |
| 249 | // Try to update it |
| 250 | if (currentTime - resource->Streaming.LastUpdateTime >= ResourceUpdatesInterval && resource->CanBeUpdated()) |
| 251 | { |
| 252 | UpdateResource(resource, currentTime); |
| 253 | resourcesUpdates--; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | // TODO: add StreamingManager stats, update time per frame, updates per frame, etc. |
| 258 | } |
| 259 | |
| 260 | void StreamingSystem::Execute(TaskGraph* graph) |
| 261 | { |
nothing calls this directly
no test coverage detected