From c8ab2bf22e360a45a6b3138f0fc76791c0b04f4c Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Mon, 9 Mar 2026 21:00:58 +0100 Subject: [PATCH] crash fix --- implementations/Crafter.Graphics-Window.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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();