From 137e3fbbdfc2c56e5b6b00a11aaab5535a8ca39e Mon Sep 17 00:00:00 2001 From: FreezeEngine Date: Sun, 4 Aug 2024 20:54:56 +0300 Subject: [PATCH] Rendersync fix? --- src/Client/Hook/Hooks/Render/SetupAndRenderHook.hpp | 3 +++ src/Client/Hook/Hooks/Render/SwapchainHook.cpp | 12 +++++++----- src/Client/Hook/Hooks/Render/SwapchainHook.hpp | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Client/Hook/Hooks/Render/SetupAndRenderHook.hpp b/src/Client/Hook/Hooks/Render/SetupAndRenderHook.hpp index 3d765029..c152d609 100644 --- a/src/Client/Hook/Hooks/Render/SetupAndRenderHook.hpp +++ b/src/Client/Hook/Hooks/Render/SetupAndRenderHook.hpp @@ -93,7 +93,10 @@ class SetUpAndRenderHook : public Hook } FrameTransform transform = { SDK::clientInstance->getviewMatrix(), origin, SDK::clientInstance->getFov(), pos}; + + SwapchainHook::frameTransformsMtx.lock(); SwapchainHook::FrameTransforms.push(transform); + SwapchainHook::frameTransformsMtx.unlock(); if(layer == "debug_screen" || layer == "hud_screen" || layer == "start_screen") { SetupAndRenderEvent event(muirc); diff --git a/src/Client/Hook/Hooks/Render/SwapchainHook.cpp b/src/Client/Hook/Hooks/Render/SwapchainHook.cpp index 0638daac..8a36c131 100644 --- a/src/Client/Hook/Hooks/Render/SwapchainHook.cpp +++ b/src/Client/Hook/Hooks/Render/SwapchainHook.cpp @@ -244,11 +244,13 @@ HRESULT SwapchainHook::swapchainCallback(IDXGISwapChain3 *pSwapChain, UINT syncI /* RENDER SYNC */ - if(init && initImgui) - while(FrameTransforms.size() > transformDelay) - { - MC::Transform = FrameTransforms.front(); - FrameTransforms.pop(); + if(init && initImgui) { + frameTransformsMtx.lock(); + while (FrameTransforms.size() > transformDelay) { + MC::Transform = FrameTransforms.front(); + FrameTransforms.pop(); + } + frameTransformsMtx.unlock(); } /* RENDER SYNC */ diff --git a/src/Client/Hook/Hooks/Render/SwapchainHook.hpp b/src/Client/Hook/Hooks/Render/SwapchainHook.hpp index d7cbb4f6..4f6cbc66 100644 --- a/src/Client/Hook/Hooks/Render/SwapchainHook.hpp +++ b/src/Client/Hook/Hooks/Render/SwapchainHook.hpp @@ -73,6 +73,7 @@ class SwapchainHook : public Hook { static inline uint64_t buffersCounts = 0; static inline std::vector frameContexts = {}; + static inline std::mutex frameTransformsMtx; static inline std::queue FrameTransforms; static inline int transformDelay = 3;