Skip to content

Commit

Permalink
Rendersync fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
FreezeEngine committed Aug 4, 2024
1 parent 37a7a05 commit 137e3fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/Client/Hook/Hooks/Render/SetupAndRenderHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions src/Client/Hook/Hooks/Render/SwapchainHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/Client/Hook/Hooks/Render/SwapchainHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class SwapchainHook : public Hook {
static inline uint64_t buffersCounts = 0;
static inline std::vector<FrameContext> frameContexts = {};

static inline std::mutex frameTransformsMtx;
static inline std::queue<FrameTransform> FrameTransforms;
static inline int transformDelay = 3;

Expand Down

0 comments on commit 137e3fb

Please sign in to comment.