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

Method Update

Source/Engine/Renderer/ProbesRenderer.cpp:282–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void ProbesRendererService::Update()
283{
284 PROFILE_MEM(Graphics);
285
286 // Calculate time delta since last update
287 auto timeNow = Time::Update.UnscaledTime;
288 auto timeSinceUpdate = timeNow - _lastProbeUpdate;
289 if (timeSinceUpdate < 0)
290 {
291 _lastProbeUpdate = timeNow;
292 timeSinceUpdate = 0;
293 }
294
295 // Check if render job is done
296 if (_updateFrameNumber > 0 && _updateFrameNumber + PROBES_RENDERER_LATENCY_FRAMES <= Engine::FrameCount)
297 {
298 // Create async job to gather probe data from the GPU
299 GPUTexture* texture = nullptr;
300 switch (_current.Type)
301 {
302 case ProbeEntry::Types::SkyLight:
303 case ProbeEntry::Types::EnvProbe:
304 texture = _probe;
305 break;
306 }
307 ASSERT(texture && _current.UseTextureData());
308 auto taskB = New<DownloadProbeTask>(texture, _current);
309 auto taskA = texture->DownloadDataAsync(taskB->GetData());
310 ASSERT(taskA);
311 taskA->ContinueWith(taskB);
312 taskA->Start();
313
314 // Clear flag
315 _updateFrameNumber = 0;
316 _workStep = 0;
317 _current.Type = ProbeEntry::Types::Invalid;
318 }
319 else if (_current.Type == ProbeEntry::Types::Invalid && timeSinceUpdate > ProbesRenderer::UpdateDelay)
320 {
321 int32 firstValidEntryIndex = -1;
322 auto dt = Time::Update.UnscaledDeltaTime.GetTotalSeconds();
323 for (int32 i = 0; i < _probesToBake.Count(); i++)
324 {
325 auto& e = _probesToBake[i];
326 e.Timeout -= dt;
327 if (e.Timeout <= 0)
328 {
329 firstValidEntryIndex = i;
330 break;
331 }
332 }
333
334 // Check if need to update probe
335 if (firstValidEntryIndex >= 0 && timeSinceUpdate > ProbesRenderer::UpdateDelay)
336 {
337 if (LazyInit())
338 return; // Shader is not yet loaded so try the next frame
339

Callers

nothing calls this directly

Calls 8

DisposeFunction · 0.85
UseTextureDataMethod · 0.80
ContinueWithMethod · 0.80
RemoveAtKeepOrderMethod · 0.80
DownloadDataAsyncMethod · 0.45
GetDataMethod · 0.45
StartMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected