From 7a88a49f1ccea121233f7353a990f109870187aa Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 16 Mar 2025 19:37:03 +0000 Subject: [PATCH] [idd] handle frame re-send for when a new client connects --- idd/LGIdd/CIndirectDeviceContext.cpp | 8 +++++--- idd/LGIdd/CIndirectDeviceContext.h | 9 +++++---- idd/LGIdd/CIndirectMonitorContext.h | 6 ------ idd/LGIdd/CSwapChainProcessor.cpp | 19 ------------------- idd/LGIdd/CSwapChainProcessor.h | 2 -- 5 files changed, 10 insertions(+), 34 deletions(-) diff --git a/idd/LGIdd/CIndirectDeviceContext.cpp b/idd/LGIdd/CIndirectDeviceContext.cpp index d02ea992..886c1fe9 100644 --- a/idd/LGIdd/CIndirectDeviceContext.cpp +++ b/idd/LGIdd/CIndirectDeviceContext.cpp @@ -339,6 +339,8 @@ bool CIndirectDeviceContext::SetupLGMP(size_t alignSize) void CIndirectDeviceContext::DeInitLGMP() { + m_hasFrame = false; + if (m_lgmp == nullptr) return; @@ -394,9 +396,8 @@ void CIndirectDeviceContext::LGMPTimer() if (lgmpHostQueueNewSubs(m_frameQueue) && m_monitor) { - auto* wrapper = WdfObjectGet_CIndirectMonitorContextWrapper(m_monitor); - if (wrapper) - wrapper->context->ResendLastFrame(); + if (m_hasFrame) + lgmpHostQueuePost(m_frameQueue, 0, m_frameMemory[m_frameIndex]); } if (lgmpHostQueueNewSubs(m_pointerQueue)) @@ -478,6 +479,7 @@ CIndirectDeviceContext::PreparedFrameBuffer CIndirectDeviceContext::PrepareFrame result.frameIndex = m_frameIndex; result.mem = fb->data; + m_hasFrame = true; return result; } diff --git a/idd/LGIdd/CIndirectDeviceContext.h b/idd/LGIdd/CIndirectDeviceContext.h index 0ec38a9c..c84f0d28 100644 --- a/idd/LGIdd/CIndirectDeviceContext.h +++ b/idd/LGIdd/CIndirectDeviceContext.h @@ -63,10 +63,11 @@ private: uint32_t m_frameSerial = 0; PLGMPMemory m_frameMemory[LGMP_Q_FRAME_LEN] = {}; - int m_width = 0; - int m_height = 0; - int m_pitch = 0; - DXGI_FORMAT m_format = DXGI_FORMAT_UNKNOWN; + int m_width = 0; + int m_height = 0; + int m_pitch = 0; + DXGI_FORMAT m_format = DXGI_FORMAT_UNKNOWN; + bool m_hasFrame = false; void DeInitLGMP(); void LGMPTimer(); diff --git a/idd/LGIdd/CIndirectMonitorContext.h b/idd/LGIdd/CIndirectMonitorContext.h index 0681cb9e..4e6822b5 100644 --- a/idd/LGIdd/CIndirectMonitorContext.h +++ b/idd/LGIdd/CIndirectMonitorContext.h @@ -58,12 +58,6 @@ public: void AssignSwapChain(IDDCX_SWAPCHAIN swapChain, LUID renderAdapter, HANDLE newFrameEvent); void UnassignSwapChain(); - - inline void ResendLastFrame() - { - if (m_swapChain) - m_swapChain->ResendLastFrame(); - } }; struct CIndirectMonitorContextWrapper diff --git a/idd/LGIdd/CSwapChainProcessor.cpp b/idd/LGIdd/CSwapChainProcessor.cpp index e5415efa..db609450 100644 --- a/idd/LGIdd/CSwapChainProcessor.cpp +++ b/idd/LGIdd/CSwapChainProcessor.cpp @@ -217,23 +217,4 @@ void CSwapChainProcessor::SwapChainNewFrame(ComPtr acquiredBuffer m_dx12Device->GetCopyQueue().Reset(); m_devContext->FinalizeFrameBuffer(); -} - -void CSwapChainProcessor::ResendLastFrame() -{ -/* - LOCK_CONTEXT() - StagingTexture & st = m_cpuTex[m_lastIndex]; - LOCK_ST(st); - UNLOCK_CONTEXT(); - - if (!st.map.pData) - { - UNLOCK_ST(st); - return; - } - - m_devContext->SendFrame(st.width, st.height, st.map.RowPitch, st.format, st.map.pData); - UNLOCK_ST(st); -*/ } \ No newline at end of file diff --git a/idd/LGIdd/CSwapChainProcessor.h b/idd/LGIdd/CSwapChainProcessor.h index 8ac17bdf..deab8af7 100644 --- a/idd/LGIdd/CSwapChainProcessor.h +++ b/idd/LGIdd/CSwapChainProcessor.h @@ -63,6 +63,4 @@ public: CIndirectDeviceContext * GetDevice() { return m_devContext; } std::shared_ptr GetD3D12Device() { return m_dx12Device; } - - void ResendLastFrame(); }; \ No newline at end of file