@@ -157,23 +157,19 @@ class GeometryCreatorSampleApp : public ApplicationBase
157
157
video::IGPUObjectFromAssetConverter::SParams cpu2gpuParams;
158
158
core::smart_refctd_ptr<nbl::video::IUtilities> utilities;
159
159
160
- int32_t m_resourceIx = -1 ;
161
160
core::smart_refctd_ptr<video::IGPUFence> m_frameComplete[FRAMES_IN_FLIGHT] = { nullptr };
162
161
core::smart_refctd_ptr<video::IGPUSemaphore> m_imageAcquire[FRAMES_IN_FLIGHT] = { nullptr };
163
162
core::smart_refctd_ptr<video::IGPUSemaphore> m_renderFinished[FRAMES_IN_FLIGHT] = { nullptr };
164
163
core::smart_refctd_ptr<video::IGPUCommandBuffer> m_commandBuffers[FRAMES_IN_FLIGHT];
165
164
166
- std::chrono::system_clock::time_point m_lastTime;
167
- double m_time_sum = 0 ;
168
- size_t m_frame_count = 0ull ;
169
- double m_dtList[NBL_FRAMES_TO_AVERAGE] = {};
170
- bool m_frameDataFilled = false ;
165
+ int32_t m_resourceIx = -1 ;
171
166
uint32_t m_acquiredNextFBO = {};
172
167
173
168
CommonAPI::InputSystem::ChannelReader<IMouseEventChannel> m_mouse;
174
169
CommonAPI::InputSystem::ChannelReader<IKeyboardEventChannel> m_keyboard;
175
170
std::unique_ptr<Camera> m_camera = nullptr ;
176
171
std::unique_ptr<Objects> m_cpuGpuObjects = nullptr ;
172
+ video::CDumbPresentationOracle oracle;
177
173
178
174
public:
179
175
@@ -479,10 +475,8 @@ class GeometryCreatorSampleApp : public ApplicationBase
479
475
core::vectorSIMDf cameraPosition (0 , 5 , -10 );
480
476
matrix4SIMD projectionMatrix = matrix4SIMD::buildProjectionMatrixPerspectiveFovLH (core::radians (60 .0f ), float (WIN_W) / WIN_H, 0.001 , 1000 );
481
477
m_camera = std::make_unique<Camera>(cameraPosition, core::vectorSIMDf (0 , 0 , 0 ), projectionMatrix, 10 .f , 1 .f );
482
- m_lastTime = std::chrono::system_clock::now ();
483
-
484
- for (size_t i = 0ull ; i < NBL_FRAMES_TO_AVERAGE; ++i)
485
- m_dtList[i] = 0.0 ;
478
+
479
+ oracle.reportBeginFrameRecord ();
486
480
487
481
logicalDevice->createCommandBuffers (commandPools[CommonAPI::InitOutput::EQT_GRAPHICS].get (), video::IGPUCommandBuffer::EL_PRIMARY, FRAMES_IN_FLIGHT, m_commandBuffers);
488
482
@@ -530,30 +524,7 @@ class GeometryCreatorSampleApp : public ApplicationBase
530
524
else
531
525
fence = logicalDevice->createFence (static_cast <video::IGPUFence::E_CREATE_FLAGS>(0 ));
532
526
533
- auto renderStart = std::chrono::system_clock::now ();
534
- const auto renderDt = std::chrono::duration_cast<std::chrono::milliseconds>(renderStart - m_lastTime).count ();
535
- m_lastTime = renderStart;
536
- { // Calculate Simple Moving Average for FrameTime
537
- m_time_sum -= m_dtList[m_frame_count];
538
- m_time_sum += renderDt;
539
- m_dtList[m_frame_count] = renderDt;
540
- m_frame_count++;
541
- if (m_frame_count >= NBL_FRAMES_TO_AVERAGE)
542
- {
543
- m_frameDataFilled = true ;
544
- m_frame_count = 0 ;
545
- }
546
-
547
- }
548
- const double averageFrameTime = m_frameDataFilled ? (m_time_sum / (double )NBL_FRAMES_TO_AVERAGE) : (m_time_sum / m_frame_count);
549
-
550
- #ifdef NBL_MORE_LOGS
551
- logger->log (" renderDt = %f ------ averageFrameTime = %f" , system::ILogger::ELL_INFO, renderDt, averageFrameTime);
552
- #endif // NBL_MORE_LOGS
553
-
554
- auto averageFrameTimeDuration = std::chrono::duration<double , std::milli>(averageFrameTime);
555
- auto nextPresentationTime = renderStart + averageFrameTimeDuration;
556
- auto nextPresentationTimeStamp = std::chrono::duration_cast<std::chrono::microseconds>(nextPresentationTime.time_since_epoch ());
527
+ const auto nextPresentationTimeStamp = oracle.acquireNextImage (swapchain.get (), m_imageAcquire[m_resourceIx].get (), nullptr , &m_acquiredNextFBO);
557
528
558
529
inputSystem->getDefaultMouse (&m_mouse);
559
530
inputSystem->getDefaultKeyboard (&m_keyboard);
0 commit comments