From c149b9f2ecef5516dbff57b5378e9fd61a66cb2e Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 17 Apr 2023 11:34:37 +0100 Subject: [PATCH] If RestoreDeferredContextState was used a command list is not successful --- renderdoc/driver/d3d11/d3d11_context.cpp | 15 +++++++++++++-- renderdoc/driver/d3d11/d3d11_context_wrap.cpp | 9 +++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index 7a57835a9..54daa219b 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -162,7 +162,6 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real m_ScratchSerialiser.SetUserData(GetResourceManager()); m_ScratchSerialiser.SetVersion(D3D11InitParams::CurrentVersion); - m_SuccessfulCapture = true; m_FailureReason = CaptureSucceeded; m_EmptyCommandList = true; @@ -189,6 +188,8 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real m_CurrentPipelineState->SetImmediatePipeline(m_pDevice); m_MarkedActive = false; + + m_SuccessfulCapture = true; } else { @@ -198,8 +199,16 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real // bool flag rather than "if immediate and not flagged" m_MarkedActive = true; + // deferred contexts are only successful if they were active capturing when they started if(IsCaptureMode(m_State) && RenderDoc::Inst().GetCaptureOptions().captureAllCmdLists) + { m_State = CaptureState::ActiveCapturing; + m_SuccessfulCapture = true; + } + else + { + m_SuccessfulCapture = false; + } } ReplayFakeContext(ResourceId()); @@ -641,8 +650,10 @@ void WrappedID3D11DeviceContext::CleanupCapture() m_MapResourceRecordAllocs.clear(); - if(RenderDoc::Inst().GetCaptureOptions().captureAllCmdLists) + if(RenderDoc::Inst().GetCaptureOptions().captureAllCmdLists || IsActiveCapturing(m_State)) return; + + m_SuccessfulCapture = false; } else { diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index 58ca93e40..90d3eefda 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -5570,6 +5570,15 @@ HRESULT WrappedID3D11DeviceContext::FinishCommandList(BOOL RestoreDeferredContex // we pick up on that. m_EmptyCommandList = true; + // except if we were supposed to restore the deferred context state. Then there would have to + // be some state setting here (which we're not recording). + // This makes the command list immediately unsuccessful and forces a retry - if this happens + // again the restore will be recorded + if(RestoreDeferredContextState) + m_EmptyCommandList = false; + + m_SuccessfulCapture = false; + // still need to propagate up dirty resources to the immediate context wrapped->SwapDirtyResources(m_DeferredDirty);