From 33312a5d01b656318a8275c2295ac6e1545a48d5 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Mon, 9 Mar 2026 21:16:14 +0100 Subject: [PATCH] crash fix --- implementations/Crafter.Graphics-Window.cpp | 24 ++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/implementations/Crafter.Graphics-Window.cpp b/implementations/Crafter.Graphics-Window.cpp index f0afeab..2b65ee1 100644 --- a/implementations/Crafter.Graphics-Window.cpp +++ b/implementations/Crafter.Graphics-Window.cpp @@ -622,7 +622,18 @@ void Window::Update() { } void Window::Render() { -// Acquire the next image from the swap chain + #ifdef CRAFTER_GRAPHICS_RENDERER_SOFTWARE + // elements.erase(std::remove(elements.begin(), elements.end(), static_cast(nullptr)), elements.end()); + // std::sort(elements.begin(), elements.end(), [](Transform* a, Transform* b){ return a->anchor.z < b->anchor.z; }); + renderer.Render(); + #ifdef CRAFTER_GRAPHICS_WINDOW_WAYLAND + wl_surface_attach(surface, buffer, 0, 0); + wl_surface_commit(surface); + wl_surface_damage(surface, 0, 0, 10000, 100000); + #endif + #endif + #ifdef CRAFTER_GRAPHICS_RENDERER_VULKAN + // Acquire the next image from the swap chain Device::CheckVkResult(vkAcquireNextImageKHR(Device::device, swapChain, UINT64_MAX, semaphores.presentComplete, (VkFence)nullptr, ¤tBuffer)); submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; @@ -653,6 +664,16 @@ 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({startTime, startTime-lastFrameBegin}); + #ifdef CRAFTER_TIMING + totalUpdate = std::chrono::nanoseconds(0); + updateTimings.clear(); + for (const std::pair*, std::chrono::nanoseconds>& entry : onUpdate.listenerTimes) { + updateTimings.push_back(entry); + totalUpdate += entry.second; + } + #endif + vkCmdBindPipeline(drawCmdBuffers[currentBuffer], VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, rtPipeline); VkBindDescriptorSetsInfo bindDescriptorSetsInfo{ .sType = VK_STRUCTURE_TYPE_BIND_DESCRIPTOR_SETS_INFO, @@ -704,6 +725,7 @@ void Window::Render() { Device::CheckVkResult(result); } Device::CheckVkResult(vkQueueWaitIdle(Device::queue)); + #endif } #ifdef CRAFTER_TIMING