diff --git a/implementations/Crafter.Graphics-Window.cpp b/implementations/Crafter.Graphics-Window.cpp index 0cbd526..7020a86 100644 --- a/implementations/Crafter.Graphics-Window.cpp +++ b/implementations/Crafter.Graphics-Window.cpp @@ -590,10 +590,12 @@ void Window::StopUpdate() { updating = false; } +std::chrono::time_point startTime; + void Window::Update() { - auto start = std::chrono::high_resolution_clock::now(); + startTime = std::chrono::high_resolution_clock::now(); #ifdef CRAFTER_TIMING - vblank = duration_cast(start - frameEnd); + vblank = duration_cast(startTime - frameEnd); #endif #ifdef CRAFTER_TIMING @@ -616,7 +618,7 @@ void Window::Update() { frameTimes.erase(frameTimes.begin()); } #endif - lastFrameBegin = start; + lastFrameBegin = startTime; } void Window::Render() { @@ -662,7 +664,7 @@ void Window::Render() { vkCmdPipelineBarrier(drawCmdBuffers[currentBuffer], VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); - onUpdate.Invoke({start, start-lastFrameBegin}); + onUpdate.Invoke({startTime, startTime-lastFrameBegin}); #ifdef CRAFTER_TIMING totalUpdate = std::chrono::nanoseconds(0); updateTimings.clear();