From e040249398c88f618f0e6d2625ce5213f2de6526 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 2 Nov 2016 17:51:00 +0100 Subject: [PATCH] When selecting the final swapchain present, use present target * It was using the last bound render target, which could be empty if state was reset before presentation. Instead we use the copy target listed in the present drawcall as the actual swap buffer presented to. --- renderdoc/driver/d3d11/d3d11_context.cpp | 2 ++ renderdoc/driver/d3d11/d3d11_device.cpp | 2 ++ renderdoc/driver/d3d11/d3d11_device.h | 3 +++ renderdocui/Windows/TextureViewer.cs | 4 ++-- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index c1040c653..c62836212 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -797,6 +797,8 @@ void WrappedID3D11DeviceContext::ProcessChunk(uint64_t offset, D3D11ChunkType ch draw.name = "Present()"; draw.flags |= eDraw_Present; + draw.copyDestination = m_pDevice->GetBackbufferResourceID(); + AddDrawcall(draw, true); } } diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 8a8bcae21..bc228789f 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -2500,6 +2500,8 @@ bool WrappedID3D11Device::Serialise_WrapSwapchainBuffer(WrappedIDXGISwapChain4 * SERIALISE_ELEMENT(uint32_t, BuffNum, buffer); SERIALISE_ELEMENT(ResourceId, pTexture, GetIDForResource(pTex)); + m_BBID = pTexture; + if(m_State >= WRITING) { D3D11_TEXTURE2D_DESC desc; diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 341e9b26f..aaae564bb 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -340,6 +340,8 @@ private: D3D11InitParams m_InitParams; + ResourceId m_BBID; + ID3D11Device *m_pDevice; ID3D11Device1 *m_pDevice1; ID3D11Device2 *m_pDevice2; @@ -525,6 +527,7 @@ public: void ReleaseSwapchainResources(WrappedIDXGISwapChain4 *swap, UINT QueueCount, IUnknown *const *ppPresentQueue, IUnknown **unwrappedQueues); + ResourceId GetBackbufferResourceID() { return m_BBID; } void InternalRef() { InterlockedIncrement(&m_InternalRefcount); } void InternalRelease() { InterlockedDecrement(&m_InternalRefcount); } void SoftRef() { m_SoftRefCounter.AddRef(); } diff --git a/renderdocui/Windows/TextureViewer.cs b/renderdocui/Windows/TextureViewer.cs index 54c49de65..5de03056b 100644 --- a/renderdocui/Windows/TextureViewer.cs +++ b/renderdocui/Windows/TextureViewer.cs @@ -98,7 +98,7 @@ namespace renderdocui.Windows public static void GetDrawContext(Core core, out bool copy, out bool compute) { var curDraw = core.CurDrawcall; - copy = curDraw != null && (curDraw.flags & (DrawcallFlags.Copy | DrawcallFlags.Resolve)) != 0; + copy = curDraw != null && (curDraw.flags & (DrawcallFlags.Copy | DrawcallFlags.Resolve | DrawcallFlags.Present)) != 0; compute = curDraw != null && (curDraw.flags & DrawcallFlags.Dispatch) != 0 && core.CurPipelineState.GetShader(ShaderStageType.Compute) != ResourceId.Null; } @@ -1420,7 +1420,7 @@ namespace renderdocui.Windows int roIndex = 0; var curDraw = m_Core.GetDrawcall(eventID); - bool copy = curDraw != null && (curDraw.flags & (DrawcallFlags.Copy|DrawcallFlags.Resolve)) != 0; + bool copy = curDraw != null && (curDraw.flags & (DrawcallFlags.Copy|DrawcallFlags.Resolve|DrawcallFlags.Present)) != 0; bool compute = curDraw != null && (curDraw.flags & (DrawcallFlags.Dispatch)) != 0; for(int rt=0; rt < RTs.Length; rt++)