From d671c66bea7bbad2eca3905a7c5edfcf0efd65f1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 10 Sep 2020 14:45:46 +0100 Subject: [PATCH] Remove reliance on wrapped pool IsAlloc * In most cases we either know the type, or we can use the generic parent WrappedDeviceChild11 to get what we want. --- renderdoc/driver/d3d11/d3d11_context.cpp | 17 +- .../driver/d3d11/d3d11_context1_wrap.cpp | 411 +++++------------- renderdoc/driver/d3d11/d3d11_context_wrap.cpp | 368 ++++++++-------- renderdoc/driver/d3d11/d3d11_debug.cpp | 6 +- renderdoc/driver/d3d11/d3d11_device.cpp | 16 +- renderdoc/driver/d3d11/d3d11_device1_wrap.cpp | 7 +- renderdoc/driver/d3d11/d3d11_device3_wrap.cpp | 87 ++-- renderdoc/driver/d3d11/d3d11_device_wrap.cpp | 185 +++----- renderdoc/driver/d3d11/d3d11_initstate.cpp | 6 +- renderdoc/driver/d3d11/d3d11_manager.cpp | 22 +- renderdoc/driver/d3d11/d3d11_manager.h | 12 +- renderdoc/driver/d3d11/d3d11_renderstate.cpp | 40 +- renderdoc/driver/d3d11/d3d11_replay.cpp | 46 +- renderdoc/driver/d3d11/d3d11_resources.cpp | 112 +---- renderdoc/driver/d3d11/d3d11_resources.h | 121 +----- renderdoc/driver/d3d11/d3d11_serialise.cpp | 2 +- renderdoc/driver/d3d11/d3d11_video.cpp | 50 +-- 17 files changed, 499 insertions(+), 1009 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index 104cb0c80..253ee808e 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -153,7 +153,6 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real if(!RenderDoc::Inst().IsReplayApp()) { m_ContextRecord = m_pDevice->GetResourceManager()->AddResourceRecord(m_ResourceID); - m_ContextRecord->ResType = Resource_DeviceContext; m_ContextRecord->DataInSerialiser = false; m_ContextRecord->InternalResource = true; m_ContextRecord->Length = 0; @@ -328,7 +327,7 @@ bool WrappedID3D11DeviceContext::Serialise_BeginCaptureFrame(SerialiserType &ser if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); if(m_StreamOutCounters[id].running) { @@ -372,7 +371,7 @@ bool WrappedID3D11DeviceContext::Serialise_BeginCaptureFrame(SerialiserType &ser if(buf && restart[b]) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); // release any previous query as the hidden counter is overwritten SAFE_RELEASE(m_StreamOutCounters[id].query); @@ -1005,12 +1004,12 @@ void WrappedID3D11DeviceContext::AddUsage(const DrawcallDescription &d) // IA if(d.flags & DrawFlags::Indexed && pipe->IA.IndexBuffer != NULL) - m_ResourceUses[GetIDForResource(pipe->IA.IndexBuffer)].push_back( + m_ResourceUses[GetIDForDeviceChild(pipe->IA.IndexBuffer)].push_back( EventUsage(e, ResourceUsage::IndexBuffer)); for(int i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) if(pipe->IA.Used_VB(m_pDevice, i)) - m_ResourceUses[GetIDForResource(pipe->IA.VBs[i])].push_back( + m_ResourceUses[GetIDForDeviceChild(pipe->IA.VBs[i])].push_back( EventUsage(e, ResourceUsage::VertexBuffer)); ////////////////////////////// @@ -1025,7 +1024,8 @@ void WrappedID3D11DeviceContext::AddUsage(const DrawcallDescription &d) for(int i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++) if(sh.Used_CB(i)) - m_ResourceUses[GetIDForResource(sh.ConstantBuffers[i])].push_back(EventUsage(e, CBUsage(s))); + m_ResourceUses[GetIDForDeviceChild(sh.ConstantBuffers[i])].push_back( + EventUsage(e, CBUsage(s))); for(int i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; i++) { @@ -1061,7 +1061,7 @@ void WrappedID3D11DeviceContext::AddUsage(const DrawcallDescription &d) for(int i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) if(pipe->SO.Buffers[i]) // assuming for now that any SO target bound is used. - m_ResourceUses[GetIDForResource(pipe->SO.Buffers[i])].push_back( + m_ResourceUses[GetIDForDeviceChild(pipe->SO.Buffers[i])].push_back( EventUsage(e, ResourceUsage::StreamOut)); ////////////////////////////// @@ -1358,8 +1358,7 @@ void WrappedID3D11DeviceContext::ClearMaps() ID3D11Resource *res = (ID3D11Resource *)m_pDevice->GetResourceManager()->GetLiveResource(it->first.resource); - m_pRealContext->Unmap(m_pDevice->GetResourceManager()->UnwrapResource(res), - it->first.subresource); + m_pRealContext->Unmap(UnwrapResource(res), it->first.subresource); } m_OpenMaps.clear(); diff --git a/renderdoc/driver/d3d11/d3d11_context1_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context1_wrap.cpp index eb08b3db5..deef28726 100644 --- a/renderdoc/driver/d3d11/d3d11_context1_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context1_wrap.cpp @@ -91,7 +91,7 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( if(ser.IsWriting()) { - record = m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pDstResource)); + record = m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstResource)); if(record && record->NumSubResources > (int)DstSubresource) record = (D3D11ResourceRecord *)record->SubResources[DstSubresource]; @@ -113,7 +113,10 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( { RDCASSERT(record); - if(WrappedID3D11Buffer::IsAlloc(pDstResource)) + D3D11_RESOURCE_DIMENSION dstDim; + pDstResource->GetType(&dstDim); + + if(dstDim == D3D11_RESOURCE_DIMENSION_BUFFER) { SourceDataLength = (uint32_t)record->Length; @@ -122,13 +125,13 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( } else { - WrappedID3D11Texture1D *tex1 = WrappedID3D11Texture1D::IsAlloc(pDstResource) + WrappedID3D11Texture1D *tex1 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE1D ? (WrappedID3D11Texture1D *)pDstResource : NULL; - WrappedID3D11Texture2D1 *tex2 = WrappedID3D11Texture2D1::IsAlloc(pDstResource) + WrappedID3D11Texture2D1 *tex2 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE2D ? (WrappedID3D11Texture2D1 *)pDstResource : NULL; - WrappedID3D11Texture3D1 *tex3 = WrappedID3D11Texture3D1::IsAlloc(pDstResource) + WrappedID3D11Texture3D1 *tex3 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D ? (WrappedID3D11Texture3D1 *)pDstResource : NULL; @@ -199,17 +202,15 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( // don't need to apply update subresource workaround here because we never replay on // deferred contexts, so the bug doesn't arise (we don't record-in the workaround). - m_pRealContext->UpdateSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, pDstBox, - pSrcData, SrcRowPitch, SrcDepthPitch); + m_pRealContext->UpdateSubresource(UnwrapResource(pDstResource), DstSubresource, pDstBox, + pSrcData, SrcRowPitch, SrcDepthPitch); } else { if(m_pRealContext1) { - m_pRealContext1->UpdateSubresource1( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, - pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, CopyFlags); + m_pRealContext1->UpdateSubresource1(UnwrapResource(pDstResource), DstSubresource, pDstBox, + pSrcData, SrcRowPitch, SrcDepthPitch, CopyFlags); } else if(CopyFlags == 0) { @@ -217,9 +218,8 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( // according to the docs. The only case is the deferred context bug workaround // isn't needed, but this wasn't properly handled before, and now this ambiguity // is resolved by passing ~0U as the flags to indicate a 'real' call to UpdateSubresource - m_pRealContext->UpdateSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, - pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch); + m_pRealContext->UpdateSubresource(UnwrapResource(pDstResource), DstSubresource, pDstBox, + pSrcData, SrcRowPitch, SrcDepthPitch); } else { @@ -233,7 +233,7 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( if(IsLoading(m_State)) { - m_ResourceUses[GetIDForResource(pDstResource)].push_back( + m_ResourceUses[GetIDForDeviceChild(pDstResource)].push_back( EventUsage(m_CurEventID, ResourceUsage::CPUWrite)); } } @@ -269,13 +269,16 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( if(IsReplayingAndReading() && pDstResource) { - WrappedID3D11Texture1D *tex1 = WrappedID3D11Texture1D::IsAlloc(pDstResource) + D3D11_RESOURCE_DIMENSION dstDim; + pDstResource->GetType(&dstDim); + + WrappedID3D11Texture1D *tex1 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE1D ? (WrappedID3D11Texture1D *)pDstResource : NULL; - WrappedID3D11Texture2D1 *tex2 = WrappedID3D11Texture2D1::IsAlloc(pDstResource) + WrappedID3D11Texture2D1 *tex2 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE2D ? (WrappedID3D11Texture2D1 *)pDstResource : NULL; - WrappedID3D11Texture3D1 *tex3 = WrappedID3D11Texture3D1::IsAlloc(pDstResource) + WrappedID3D11Texture3D1 *tex3 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D ? (WrappedID3D11Texture3D1 *)pDstResource : NULL; @@ -321,17 +324,15 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( // idly to the record's data pointer). if(CopyFlags == ~0U) { - m_pRealContext->UpdateSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, NULL, - Contents, SourceRowPitch, SourceDepthPitch); + m_pRealContext->UpdateSubresource(UnwrapResource(pDstResource), DstSubresource, NULL, + Contents, SourceRowPitch, SourceDepthPitch); } else { if(m_pRealContext1) { - m_pRealContext1->UpdateSubresource1( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, NULL, - Contents, SourceRowPitch, SourceDepthPitch, CopyFlags); + m_pRealContext1->UpdateSubresource1(UnwrapResource(pDstResource), DstSubresource, NULL, + Contents, SourceRowPitch, SourceDepthPitch, CopyFlags); } else if(CopyFlags == 0) { @@ -339,9 +340,8 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( // according to the docs. The only case is the deferred context bug workaround // isn't needed, but this wasn't properly handled before, and now this ambiguity // is resolved by passing ~0U as the flags to indicate a 'real' call to UpdateSubresource - m_pRealContext->UpdateSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, NULL, - Contents, SourceRowPitch, SourceDepthPitch); + m_pRealContext->UpdateSubresource(UnwrapResource(pDstResource), DstSubresource, NULL, + Contents, SourceRowPitch, SourceDepthPitch); } else { @@ -355,7 +355,7 @@ bool WrappedID3D11DeviceContext::Serialise_UpdateSubresource1( if(IsLoading(m_State)) { - m_ResourceUses[GetIDForResource(pDstResource)].push_back( + m_ResourceUses[GetIDForDeviceChild(pDstResource)].push_back( EventUsage(m_CurEventID, ResourceUsage::CPUWrite)); } } @@ -378,9 +378,9 @@ void WrappedID3D11DeviceContext::UpdateSubresource1(ID3D11Resource *pDstResource m_EmptyCommandList = false; - SERIALISE_TIME_CALL(m_pRealContext1->UpdateSubresource1( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, pDstBox, - pSrcData, SrcRowPitch, SrcDepthPitch, CopyFlags)); + SERIALISE_TIME_CALL(m_pRealContext1->UpdateSubresource1(UnwrapResource(pDstResource), + DstSubresource, pDstBox, pSrcData, + SrcRowPitch, SrcDepthPitch, CopyFlags)); if(IsActiveCapturing(m_State)) { @@ -390,16 +390,16 @@ void WrappedID3D11DeviceContext::UpdateSubresource1(ID3D11Resource *pDstResource Serialise_UpdateSubresource1(ser, pDstResource, DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, CopyFlags); - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_PartialWrite); - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); m_ContextRecord->AddChunk(scope.Get()); } else { // just mark dirty - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); } } @@ -425,16 +425,16 @@ bool WrappedID3D11DeviceContext::Serialise_CopySubresourceRegion1( { if(m_pRealContext1) { - m_pRealContext1->CopySubresourceRegion1( - GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, DstX, DstY, DstZ, - GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, pSrcBox, CopyFlags); + m_pRealContext1->CopySubresourceRegion1(UnwrapResource(pDstResource), DstSubresource, DstX, + DstY, DstZ, UnwrapResource(pSrcResource), + SrcSubresource, pSrcBox, CopyFlags); } else if(CopyFlags == 0) { // CopyFlags == 0 just degrades to the old CopySubresourceRegion - m_pRealContext->CopySubresourceRegion( - GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, DstX, DstY, DstZ, - GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, pSrcBox); + m_pRealContext->CopySubresourceRegion(UnwrapResource(pDstResource), DstSubresource, DstX, + DstY, DstZ, UnwrapResource(pSrcResource), + SrcSubresource, pSrcBox); } else { @@ -447,8 +447,8 @@ bool WrappedID3D11DeviceContext::Serialise_CopySubresourceRegion1( if(IsLoading(m_State)) { - ResourceId dstLiveID = GetIDForResource(pDstResource); - ResourceId srcLiveID = GetIDForResource(pSrcResource); + ResourceId dstLiveID = GetIDForDeviceChild(pDstResource); + ResourceId srcLiveID = GetIDForDeviceChild(pSrcResource); ResourceId dstOrigID = GetResourceManager()->GetOriginalID(dstLiveID); ResourceId srcOrigID = GetResourceManager()->GetOriginalID(srcLiveID); @@ -506,8 +506,8 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion1(ID3D11Resource *pDstReso m_EmptyCommandList = false; SERIALISE_TIME_CALL(m_pRealContext1->CopySubresourceRegion1( - GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, DstX, DstY, DstZ, - GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, pSrcBox, CopyFlags)); + UnwrapResource(pDstResource), DstSubresource, DstX, DstY, DstZ, UnwrapResource(pSrcResource), + SrcSubresource, pSrcBox, CopyFlags)); if(IsActiveCapturing(m_State)) { @@ -517,7 +517,7 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion1(ID3D11Resource *pDstReso Serialise_CopySubresourceRegion1(ser, pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox, CopyFlags); - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); m_ContextRecord->AddChunk(scope.Get()); } @@ -525,10 +525,10 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion1(ID3D11Resource *pDstReso { // just mark dirty D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(pDstResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstResource)); RDCASSERT(record); - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); } } @@ -548,32 +548,9 @@ bool WrappedID3D11DeviceContext::Serialise_ClearView(SerialiserType &ser, ID3D11 if(ser.IsReading()) { - ResourceId resid; - if(IsReplayMode(m_State) && pView) { - ID3D11View *real = NULL; - - if(WrappedID3D11RenderTargetView1::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11RenderTargetView1, pView); - resid = ((WrappedID3D11RenderTargetView1 *)pView)->GetResourceID(); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11DepthStencilView, pView); - resid = ((WrappedID3D11DepthStencilView *)pView)->GetResourceID(); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11ShaderResourceView1, pView); - resid = ((WrappedID3D11ShaderResourceView1 *)pView)->GetResourceID(); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11UnorderedAccessView1, pView); - resid = ((WrappedID3D11UnorderedAccessView1 *)pView)->GetResourceID(); - } + ID3D11View *real = (ID3D11View *)UnwrapResource(pView); RDCASSERT(real); @@ -591,44 +568,17 @@ bool WrappedID3D11DeviceContext::Serialise_ClearView(SerialiserType &ser, ID3D11 ColorRGBA[1], ColorRGBA[2], ColorRGBA[3], NumRects); draw.flags |= DrawFlags::Clear; + ResourceId resid = GetViewResourceResID(pView); + if(resid != ResourceId()) { - m_ResourceUses[resid].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear, resid)); + m_ResourceUses[resid].push_back( + EventUsage(m_CurEventID, ResourceUsage::Clear, GetIDForDeviceChild(pView))); draw.copyDestination = GetResourceManager()->GetOriginalID(resid); draw.copyDestinationSubresource = Subresource(); - if(WrappedID3D11RenderTargetView1::IsAlloc(pView)) - { - WrappedID3D11RenderTargetView1 *view = (WrappedID3D11RenderTargetView1 *)pView; - D3D11_RENDER_TARGET_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForRtv(viewDesc), GetSliceForRtv(viewDesc)); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pView)) - { - WrappedID3D11DepthStencilView *view = (WrappedID3D11DepthStencilView *)pView; - D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForDsv(viewDesc), GetSliceForDsv(viewDesc)); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pView)) - { - WrappedID3D11ShaderResourceView1 *view = (WrappedID3D11ShaderResourceView1 *)pView; - D3D11_SHADER_RESOURCE_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForSrv(viewDesc), GetSliceForSrv(viewDesc)); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pView)) - { - WrappedID3D11UnorderedAccessView1 *view = (WrappedID3D11UnorderedAccessView1 *)pView; - D3D11_UNORDERED_ACCESS_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForUav(viewDesc), GetSliceForUav(viewDesc)); - } + const ResourceRange &range = GetResourceRange(pView); + draw.copyDestinationSubresource = Subresource(range.GetMinMip(), range.GetMinSlice()); } AddDrawcall(draw, true); @@ -658,23 +608,7 @@ void WrappedID3D11DeviceContext::ClearView(ID3D11View *pView, const FLOAT Color[ { ID3D11View *real = NULL; - if(WrappedID3D11RenderTargetView1::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11RenderTargetView1, pView); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11DepthStencilView, pView); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11ShaderResourceView1, pView); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pView)) - { - real = UNWRAP(WrappedID3D11UnorderedAccessView1, pView); - } - else if(WrappedID3D11VideoDecoderOutputView::IsAlloc(pView)) + if(WrappedID3D11VideoDecoderOutputView::IsAlloc(pView)) { real = UNWRAP(WrappedID3D11VideoDecoderOutputView, pView); isVideo = true; @@ -689,6 +623,10 @@ void WrappedID3D11DeviceContext::ClearView(ID3D11View *pView, const FLOAT Color[ real = UNWRAP(WrappedID3D11VideoProcessorOutputView, pView); isVideo = true; } + else + { + real = (ID3D11View *)UnwrapResource(pView); + } RDCASSERT(real); @@ -709,8 +647,8 @@ void WrappedID3D11DeviceContext::ClearView(ID3D11View *pView, const FLOAT Color[ ID3D11Resource *viewRes = NULL; pView->GetResource(&viewRes); - MarkDirtyResource(GetIDForResource(viewRes)); - MarkResourceReferenced(GetIDForResource(viewRes), eFrameRef_PartialWrite); + MarkDirtyResource(GetIDForDeviceChild(viewRes)); + MarkResourceReferenced(GetIDForDeviceChild(viewRes), eFrameRef_PartialWrite); SAFE_RELEASE(viewRes); @@ -721,7 +659,7 @@ void WrappedID3D11DeviceContext::ClearView(ID3D11View *pView, const FLOAT Color[ ID3D11Resource *viewRes = NULL; pView->GetResource(&viewRes); - MarkDirtyResource(GetIDForResource(viewRes)); + MarkDirtyResource(GetIDForDeviceChild(viewRes)); SAFE_RELEASE(viewRes); } @@ -807,7 +745,7 @@ void WrappedID3D11DeviceContext::VSSetConstantBuffers1(UINT StartSlot, UINT NumB if(ppConstantBuffers && ppConstantBuffers[i]) { if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -938,7 +876,7 @@ void WrappedID3D11DeviceContext::HSSetConstantBuffers1(UINT StartSlot, UINT NumB if(ppConstantBuffers && ppConstantBuffers[i]) { if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1069,7 +1007,7 @@ void WrappedID3D11DeviceContext::DSSetConstantBuffers1(UINT StartSlot, UINT NumB if(ppConstantBuffers && ppConstantBuffers[i]) { if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1200,7 +1138,7 @@ void WrappedID3D11DeviceContext::GSSetConstantBuffers1(UINT StartSlot, UINT NumB if(ppConstantBuffers && ppConstantBuffers[i]) { if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1331,7 +1269,7 @@ void WrappedID3D11DeviceContext::PSSetConstantBuffers1(UINT StartSlot, UINT NumB if(ppConstantBuffers && ppConstantBuffers[i]) { if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1462,7 +1400,7 @@ void WrappedID3D11DeviceContext::CSSetConstantBuffers1(UINT StartSlot, UINT NumB if(ppConstantBuffers && ppConstantBuffers[i]) { if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1793,12 +1731,12 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardResource(SerialiserType &ser, } else if(m_pRealContext1) { - m_pRealContext1->DiscardResource(GetResourceManager()->UnwrapResource(pResource)); + m_pRealContext1->DiscardResource(UnwrapResource(pResource)); } if(IsLoading(m_State)) { - ResourceId dstLiveID = GetIDForResource(pResource); + ResourceId dstLiveID = GetIDForDeviceChild(pResource); ResourceId dstOrigID = GetResourceManager()->GetOriginalID(dstLiveID); AddEvent(); @@ -1835,16 +1773,7 @@ void WrappedID3D11DeviceContext::DiscardResource(ID3D11Resource *pResource) m_EmptyCommandList = false; { - ID3D11Resource *real = NULL; - - if(WrappedID3D11Buffer::IsAlloc(pResource)) - real = UNWRAP(WrappedID3D11Buffer, pResource); - else if(WrappedID3D11Texture1D::IsAlloc(pResource)) - real = UNWRAP(WrappedID3D11Texture1D, pResource); - else if(WrappedID3D11Texture2D1::IsAlloc(pResource)) - real = UNWRAP(WrappedID3D11Texture2D1, pResource); - else if(WrappedID3D11Texture3D1::IsAlloc(pResource)) - real = UNWRAP(WrappedID3D11Texture3D1, pResource); + ID3D11Resource *real = UnwrapResource(pResource); RDCASSERT(real); @@ -1859,14 +1788,14 @@ void WrappedID3D11DeviceContext::DiscardResource(ID3D11Resource *pResource) SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_DiscardResource(ser, pResource); - MarkDirtyResource(GetIDForResource(pResource)); - MarkResourceReferenced(GetIDForResource(pResource), eFrameRef_PartialWrite); + MarkDirtyResource(GetIDForDeviceChild(pResource)); + MarkResourceReferenced(GetIDForDeviceChild(pResource), eFrameRef_PartialWrite); m_ContextRecord->AddChunk(scope.Get()); } else if(IsCaptureMode(m_State)) { - MarkDirtyResource(GetIDForResource(pResource)); + MarkDirtyResource(GetIDForDeviceChild(pResource)); } } @@ -1888,16 +1817,7 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView(SerialiserType &ser, ID3D } else if(m_pRealContext1) { - ID3D11View *real = NULL; - - if(WrappedID3D11RenderTargetView1::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11RenderTargetView1, pResourceView); - else if(WrappedID3D11DepthStencilView::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11DepthStencilView, pResourceView); - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11ShaderResourceView1, pResourceView); - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11UnorderedAccessView1, pResourceView); + ID3D11View *real = (ID3D11View *)UnwrapResource(pResourceView); RDCASSERT(real); @@ -1914,55 +1834,12 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView(SerialiserType &ser, ID3D draw.copyDestinationSubresource = Subresource(); if(pResourceView) { - if(WrappedID3D11RenderTargetView1::IsAlloc(pResourceView)) - { - WrappedID3D11RenderTargetView1 *view = (WrappedID3D11RenderTargetView1 *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_RENDER_TARGET_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForRtv(viewDesc), GetSliceForRtv(viewDesc)); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pResourceView)) - { - WrappedID3D11DepthStencilView *view = (WrappedID3D11DepthStencilView *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForDsv(viewDesc), GetSliceForDsv(viewDesc)); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pResourceView)) - { - WrappedID3D11ShaderResourceView1 *view = (WrappedID3D11ShaderResourceView1 *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_SHADER_RESOURCE_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForSrv(viewDesc), GetSliceForSrv(viewDesc)); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pResourceView)) - { - WrappedID3D11UnorderedAccessView1 *view = - (WrappedID3D11UnorderedAccessView1 *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_UNORDERED_ACCESS_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForUav(viewDesc), GetSliceForUav(viewDesc)); - } + const ResourceRange &range = GetResourceRange(pResourceView); + ResourceId resid = GetViewResourceResID(pResourceView); + draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(resid); + draw.copyDestinationSubresource = Subresource(range.GetMinMip(), range.GetMinSlice()); + m_ResourceUses[resid].push_back( + EventUsage(m_CurEventID, ResourceUsage::Discard, GetIDForDeviceChild(pResourceView))); } draw.name = StringFormat::Fmt("DiscardView(%s)", ToStr(draw.copyDestination).c_str()); @@ -1993,23 +1870,7 @@ void WrappedID3D11DeviceContext::DiscardView(ID3D11View *pResourceView) { ID3D11View *real = NULL; - if(WrappedID3D11RenderTargetView1::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11RenderTargetView1, pResourceView); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11DepthStencilView, pResourceView); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11ShaderResourceView1, pResourceView); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11UnorderedAccessView1, pResourceView); - } - else if(WrappedID3D11VideoDecoderOutputView::IsAlloc(pResourceView)) + if(WrappedID3D11VideoDecoderOutputView::IsAlloc(pResourceView)) { real = UNWRAP(WrappedID3D11VideoDecoderOutputView, pResourceView); isVideo = true; @@ -2024,6 +1885,10 @@ void WrappedID3D11DeviceContext::DiscardView(ID3D11View *pResourceView) real = UNWRAP(WrappedID3D11VideoProcessorOutputView, pResourceView); isVideo = true; } + else + { + real = (ID3D11View *)UnwrapResource(pResourceView); + } RDCASSERT(real); @@ -2044,9 +1909,9 @@ void WrappedID3D11DeviceContext::DiscardView(ID3D11View *pResourceView) ID3D11Resource *viewRes = NULL; pResourceView->GetResource(&viewRes); - MarkDirtyResource(GetIDForResource(viewRes)); - MarkResourceReferenced(GetIDForResource(viewRes), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pResourceView), eFrameRef_Read); + MarkDirtyResource(GetIDForDeviceChild(viewRes)); + MarkResourceReferenced(GetIDForDeviceChild(viewRes), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pResourceView), eFrameRef_Read); SAFE_RELEASE(viewRes); @@ -2057,7 +1922,7 @@ void WrappedID3D11DeviceContext::DiscardView(ID3D11View *pResourceView) ID3D11Resource *viewRes = NULL; pResourceView->GetResource(&viewRes); - MarkDirtyResource(GetIDForResource(viewRes)); + MarkDirtyResource(GetIDForDeviceChild(viewRes)); SAFE_RELEASE(viewRes); } @@ -2088,16 +1953,7 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView1(SerialiserType &ser, } else if(m_pRealContext1) { - ID3D11View *real = NULL; - - if(WrappedID3D11RenderTargetView1::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11RenderTargetView1, pResourceView); - else if(WrappedID3D11DepthStencilView::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11DepthStencilView, pResourceView); - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11ShaderResourceView1, pResourceView); - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pResourceView)) - real = UNWRAP(WrappedID3D11UnorderedAccessView1, pResourceView); + ID3D11View *real = (ID3D11View *)UnwrapResource(pResourceView); RDCASSERT(real); @@ -2115,55 +1971,12 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView1(SerialiserType &ser, if(pResourceView) { - if(WrappedID3D11RenderTargetView1::IsAlloc(pResourceView)) - { - WrappedID3D11RenderTargetView1 *view = (WrappedID3D11RenderTargetView1 *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_RENDER_TARGET_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForRtv(viewDesc), GetSliceForRtv(viewDesc)); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pResourceView)) - { - WrappedID3D11DepthStencilView *view = (WrappedID3D11DepthStencilView *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForDsv(viewDesc), GetSliceForDsv(viewDesc)); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pResourceView)) - { - WrappedID3D11ShaderResourceView1 *view = (WrappedID3D11ShaderResourceView1 *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_SHADER_RESOURCE_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForSrv(viewDesc), GetSliceForSrv(viewDesc)); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pResourceView)) - { - WrappedID3D11UnorderedAccessView1 *view = - (WrappedID3D11UnorderedAccessView1 *)pResourceView; - m_ResourceUses[view->GetResourceResID()].push_back( - EventUsage(m_CurEventID, ResourceUsage::Discard, view->GetResourceID())); - draw.copyDestination = - m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID()); - D3D11_UNORDERED_ACCESS_VIEW_DESC viewDesc; - view->GetDesc(&viewDesc); - draw.copyDestinationSubresource = - Subresource(GetMipForUav(viewDesc), GetSliceForUav(viewDesc)); - } + const ResourceRange &range = GetResourceRange(pResourceView); + ResourceId resid = GetViewResourceResID(pResourceView); + draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(resid); + draw.copyDestinationSubresource = Subresource(range.GetMinMip(), range.GetMinSlice()); + m_ResourceUses[resid].push_back( + EventUsage(m_CurEventID, ResourceUsage::Discard, GetIDForDeviceChild(pResourceView))); } draw.name = StringFormat::Fmt("DiscardView1(%s)", ToStr(draw.copyDestination).c_str()); @@ -2195,23 +2008,7 @@ void WrappedID3D11DeviceContext::DiscardView1(ID3D11View *pResourceView, const D { ID3D11View *real = NULL; - if(WrappedID3D11RenderTargetView1::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11RenderTargetView1, pResourceView); - } - else if(WrappedID3D11DepthStencilView::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11DepthStencilView, pResourceView); - } - else if(WrappedID3D11ShaderResourceView1::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11ShaderResourceView1, pResourceView); - } - else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pResourceView)) - { - real = UNWRAP(WrappedID3D11UnorderedAccessView1, pResourceView); - } - else if(WrappedID3D11VideoDecoderOutputView::IsAlloc(pResourceView)) + if(WrappedID3D11VideoDecoderOutputView::IsAlloc(pResourceView)) { real = UNWRAP(WrappedID3D11VideoDecoderOutputView, pResourceView); isVideo = true; @@ -2226,6 +2023,10 @@ void WrappedID3D11DeviceContext::DiscardView1(ID3D11View *pResourceView, const D real = UNWRAP(WrappedID3D11VideoProcessorOutputView, pResourceView); isVideo = true; } + else + { + real = (ID3D11View *)UnwrapResource(pResourceView); + } RDCASSERT(real); @@ -2246,9 +2047,9 @@ void WrappedID3D11DeviceContext::DiscardView1(ID3D11View *pResourceView, const D ID3D11Resource *viewRes = NULL; pResourceView->GetResource(&viewRes); - MarkDirtyResource(GetIDForResource(viewRes)); - MarkResourceReferenced(GetIDForResource(viewRes), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pResourceView), eFrameRef_Read); + MarkDirtyResource(GetIDForDeviceChild(viewRes)); + MarkResourceReferenced(GetIDForDeviceChild(viewRes), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pResourceView), eFrameRef_Read); SAFE_RELEASE(viewRes); @@ -2259,7 +2060,7 @@ void WrappedID3D11DeviceContext::DiscardView1(ID3D11View *pResourceView, const D ID3D11Resource *viewRes = NULL; pResourceView->GetResource(&viewRes); - MarkDirtyResource(GetIDForResource(viewRes)); + MarkDirtyResource(GetIDForDeviceChild(viewRes)); SAFE_RELEASE(viewRes); } diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index 63aa51547..db2c1ac7f 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -430,7 +430,7 @@ void WrappedID3D11DeviceContext::IASetInputLayout(ID3D11InputLayout *pInputLayou SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_IASetInputLayout(GET_SERIALISER, pInputLayout); - MarkResourceReferenced(GetIDForResource(pInputLayout), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pInputLayout), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -491,7 +491,7 @@ void WrappedID3D11DeviceContext::IASetVertexBuffers(UINT StartSlot, UINT NumBuff for(UINT i = 0; i < NumBuffers; i++) { if(ppVertexBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppVertexBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppVertexBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppVertexBuffers[i]); } @@ -566,7 +566,7 @@ void WrappedID3D11DeviceContext::IASetIndexBuffer(ID3D11Buffer *pIndexBuffer, DX } if(pIndexBuffer && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(pIndexBuffer), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pIndexBuffer), eFrameRef_Read); m_CurrentPipelineState->ChangeRefRead(m_CurrentPipelineState->IA.IndexBuffer, pIndexBuffer); m_CurrentPipelineState->Change(m_CurrentPipelineState->IA.IndexFormat, Format); @@ -733,7 +733,7 @@ void WrappedID3D11DeviceContext::VSSetConstantBuffers(UINT StartSlot, UINT NumBu for(UINT i = 0; i < NumBuffers; i++) { if(ppConstantBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -804,7 +804,7 @@ void WrappedID3D11DeviceContext::VSSetShaderResources( { if(ppShaderResourceViews[i] && IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppShaderResourceViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppShaderResourceViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppShaderResourceViews[i]), eFrameRef_Read); } @@ -872,7 +872,7 @@ void WrappedID3D11DeviceContext::VSSetSamplers(UINT StartSlot, UINT NumSamplers, for(UINT i = 0; i < NumSamplers; i++) { if(ppSamplers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppSamplers[i]), eFrameRef_Read); samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); } @@ -955,7 +955,7 @@ void WrappedID3D11DeviceContext::VSSetShader(ID3D11VertexShader *pVertexShader, SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_VSSetShader(GET_SERIALISER, pVertexShader, ppClassInstances, NumClassInstances); - MarkResourceReferenced(GetIDForResource(pVertexShader), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pVertexShader), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -1128,7 +1128,7 @@ void WrappedID3D11DeviceContext::HSSetConstantBuffers(UINT StartSlot, UINT NumBu for(UINT i = 0; i < NumBuffers; i++) { if(ppConstantBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1199,7 +1199,7 @@ void WrappedID3D11DeviceContext::HSSetShaderResources( { if(ppShaderResourceViews[i] && IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppShaderResourceViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppShaderResourceViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppShaderResourceViews[i]), eFrameRef_Read); } @@ -1267,7 +1267,7 @@ void WrappedID3D11DeviceContext::HSSetSamplers(UINT StartSlot, UINT NumSamplers, for(UINT i = 0; i < NumSamplers; i++) { if(ppSamplers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppSamplers[i]), eFrameRef_Read); samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); } @@ -1349,7 +1349,7 @@ void WrappedID3D11DeviceContext::HSSetShader(ID3D11HullShader *pHullShader, SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_HSSetShader(GET_SERIALISER, pHullShader, ppClassInstances, NumClassInstances); - MarkResourceReferenced(GetIDForResource(pHullShader), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pHullShader), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -1522,7 +1522,7 @@ void WrappedID3D11DeviceContext::DSSetConstantBuffers(UINT StartSlot, UINT NumBu for(UINT i = 0; i < NumBuffers; i++) { if(ppConstantBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1593,7 +1593,7 @@ void WrappedID3D11DeviceContext::DSSetShaderResources( { if(ppShaderResourceViews[i] && IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppShaderResourceViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppShaderResourceViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppShaderResourceViews[i]), eFrameRef_Read); } @@ -1661,7 +1661,7 @@ void WrappedID3D11DeviceContext::DSSetSamplers(UINT StartSlot, UINT NumSamplers, for(UINT i = 0; i < NumSamplers; i++) { if(ppSamplers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppSamplers[i]), eFrameRef_Read); samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); } @@ -1744,7 +1744,7 @@ void WrappedID3D11DeviceContext::DSSetShader(ID3D11DomainShader *pDomainShader, SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_DSSetShader(GET_SERIALISER, pDomainShader, ppClassInstances, NumClassInstances); - MarkResourceReferenced(GetIDForResource(pDomainShader), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDomainShader), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -1918,7 +1918,7 @@ void WrappedID3D11DeviceContext::GSSetConstantBuffers(UINT StartSlot, UINT NumBu for(UINT i = 0; i < NumBuffers; i++) { if(ppConstantBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -1989,7 +1989,7 @@ void WrappedID3D11DeviceContext::GSSetShaderResources( { if(ppShaderResourceViews[i] && IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppShaderResourceViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppShaderResourceViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppShaderResourceViews[i]), eFrameRef_Read); } @@ -2057,7 +2057,7 @@ void WrappedID3D11DeviceContext::GSSetSamplers(UINT StartSlot, UINT NumSamplers, for(UINT i = 0; i < NumSamplers; i++) { if(ppSamplers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppSamplers[i]), eFrameRef_Read); samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); } @@ -2140,7 +2140,7 @@ void WrappedID3D11DeviceContext::GSSetShader(ID3D11GeometryShader *pShader, SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_GSSetShader(GET_SERIALISER, pShader, ppClassInstances, NumClassInstances); - MarkResourceReferenced(GetIDForResource(pShader), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pShader), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -2210,7 +2210,7 @@ bool WrappedID3D11DeviceContext::Serialise_SOSetTargets(SerialiserType &ser, UIN if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); if(m_StreamOutCounters[id].running) { @@ -2227,7 +2227,7 @@ bool WrappedID3D11DeviceContext::Serialise_SOSetTargets(SerialiserType &ser, UIN if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); // release any previous query as the hidden counter is overwritten SAFE_RELEASE(m_StreamOutCounters[id].query); @@ -2281,9 +2281,9 @@ void WrappedID3D11DeviceContext::SOSetTargets(UINT NumBuffers, ID3D11Buffer *con // to avoid having to track "possibly" dirty resources. // Besides, it's unlikely an application will set an output then not draw to it if(IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSOTargets[i]), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(ppSOTargets[i]), eFrameRef_PartialWrite); - MarkDirtyResource(GetIDForResource(ppSOTargets[i])); + MarkDirtyResource(GetIDForDeviceChild(ppSOTargets[i])); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppSOTargets[i]); } } @@ -2319,7 +2319,7 @@ void WrappedID3D11DeviceContext::SOSetTargets(UINT NumBuffers, ID3D11Buffer *con if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); if(m_StreamOutCounters[id].running) { @@ -2336,7 +2336,7 @@ void WrappedID3D11DeviceContext::SOSetTargets(UINT NumBuffers, ID3D11Buffer *con if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); // release any previous query as the hidden counter is overwritten SAFE_RELEASE(m_StreamOutCounters[id].query); @@ -2551,7 +2551,7 @@ void WrappedID3D11DeviceContext::RSSetState(ID3D11RasterizerState *pRasterizerSt SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_RSSetState(GET_SERIALISER, pRasterizerState); - MarkResourceReferenced(GetIDForResource(pRasterizerState), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pRasterizerState), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -2720,7 +2720,7 @@ void WrappedID3D11DeviceContext::PSSetConstantBuffers(UINT StartSlot, UINT NumBu for(UINT i = 0; i < NumBuffers; i++) { if(ppConstantBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -2791,7 +2791,7 @@ void WrappedID3D11DeviceContext::PSSetShaderResources( { if(ppShaderResourceViews[i] && IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppShaderResourceViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppShaderResourceViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppShaderResourceViews[i]), eFrameRef_Read); } @@ -2859,7 +2859,7 @@ void WrappedID3D11DeviceContext::PSSetSamplers(UINT StartSlot, UINT NumSamplers, for(UINT i = 0; i < NumSamplers; i++) { if(ppSamplers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppSamplers[i]), eFrameRef_Read); samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); } @@ -2942,7 +2942,7 @@ void WrappedID3D11DeviceContext::PSSetShader(ID3D11PixelShader *pPixelShader, SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_PSSetShader(GET_SERIALISER, pPixelShader, ppClassInstances, NumClassInstances); - MarkResourceReferenced(GetIDForResource(pPixelShader), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pPixelShader), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -3234,14 +3234,14 @@ void WrappedID3D11DeviceContext::OMSetRenderTargets(UINT NumViews, { if(ppRenderTargetViews && ppRenderTargetViews[i]) { - MarkResourceReferenced(GetIDForResource(ppRenderTargetViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppRenderTargetViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppRenderTargetViews[i]), eFrameRef_PartialWrite); } } if(pDepthStencilView) { - MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDepthStencilView), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(pDepthStencilView), eFrameRef_PartialWrite); } } @@ -3534,14 +3534,14 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews( { if(ppRenderTargetViews && ppRenderTargetViews[i]) { - MarkResourceReferenced(GetIDForResource(ppRenderTargetViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppRenderTargetViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppRenderTargetViews[i]), eFrameRef_Read); } } if(pDepthStencilView) { - MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDepthStencilView), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(pDepthStencilView), eFrameRef_Read); } } @@ -3575,7 +3575,7 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews( { if(UAVs[i]) { - MarkResourceReferenced(GetIDForResource(UAVs[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(UAVs[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(UAVs[i]), eFrameRef_Read); } } @@ -3682,7 +3682,7 @@ void WrappedID3D11DeviceContext::OMSetBlendState(ID3D11BlendState *pBlendState, SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_OMSetBlendState(GET_SERIALISER, pBlendState, BlendFactor, SampleMask); - MarkResourceReferenced(GetIDForResource(pBlendState), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pBlendState), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -3743,7 +3743,7 @@ void WrappedID3D11DeviceContext::OMSetDepthStencilState(ID3D11DepthStencilState SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_OMSetDepthStencilState(GET_SERIALISER, pDepthStencilState, StencilRef); - MarkResourceReferenced(GetIDForResource(pDepthStencilState), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDepthStencilState), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -4090,7 +4090,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawAuto(SerialiserType &ser) } else { - ResourceId id = GetIDForResource(m_CurrentPipelineState->IA.VBs[0]); + ResourceId id = GetIDForDeviceChild(m_CurrentPipelineState->IA.VBs[0]); StreamOutData &data = m_StreamOutCounters[id]; @@ -4267,7 +4267,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawIndexedInstancedIndirect(Serialis } } - m_ResourceUses[GetIDForResource(pBufferForArgs)].push_back( + m_ResourceUses[GetIDForDeviceChild(pBufferForArgs)].push_back( EventUsage(m_CurEventID, ResourceUsage::Indirect)); } @@ -4311,7 +4311,7 @@ void WrappedID3D11DeviceContext::DrawIndexedInstancedIndirect(ID3D11Buffer *pBuf } if(pBufferForArgs && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(pBufferForArgs), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pBufferForArgs), eFrameRef_Read); } template @@ -4396,7 +4396,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawInstancedIndirect(SerialiserType } } - m_ResourceUses[GetIDForResource(pBufferForArgs)].push_back( + m_ResourceUses[GetIDForDeviceChild(pBufferForArgs)].push_back( EventUsage(m_CurEventID, ResourceUsage::Indirect)); } @@ -4439,7 +4439,7 @@ void WrappedID3D11DeviceContext::DrawInstancedIndirect(ID3D11Buffer *pBufferForA } if(pBufferForArgs && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(pBufferForArgs), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pBufferForArgs), eFrameRef_Read); } #pragma endregion Draw @@ -4623,7 +4623,7 @@ void WrappedID3D11DeviceContext::CSSetConstantBuffers(UINT StartSlot, UINT NumBu for(UINT i = 0; i < NumBuffers; i++) { if(ppConstantBuffers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppConstantBuffers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppConstantBuffers[i]), eFrameRef_Read); bufs[i] = UNWRAP(WrappedID3D11Buffer, ppConstantBuffers[i]); } @@ -4694,7 +4694,7 @@ void WrappedID3D11DeviceContext::CSSetShaderResources( { if(ppShaderResourceViews[i] && IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppShaderResourceViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppShaderResourceViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppShaderResourceViews[i]), eFrameRef_Read); } @@ -4768,7 +4768,7 @@ void WrappedID3D11DeviceContext::CSSetUnorderedAccessViews( { if(IsActiveCapturing(m_State)) { - MarkResourceReferenced(GetIDForResource(ppUnorderedAccessViews[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppUnorderedAccessViews[i]), eFrameRef_Read); MarkResourceReferenced(GetViewResourceResID(ppUnorderedAccessViews[i]), eFrameRef_Read); } @@ -4841,7 +4841,7 @@ void WrappedID3D11DeviceContext::CSSetSamplers(UINT StartSlot, UINT NumSamplers, for(UINT i = 0; i < NumSamplers; i++) { if(ppSamplers[i] && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(ppSamplers[i]), eFrameRef_Read); samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); } @@ -4924,7 +4924,7 @@ void WrappedID3D11DeviceContext::CSSetShader(ID3D11ComputeShader *pComputeShader SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_CSSetShader(GET_SERIALISER, pComputeShader, ppClassInstances, NumClassInstances); - MarkResourceReferenced(GetIDForResource(pComputeShader), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pComputeShader), eFrameRef_Read); m_ContextRecord->AddChunk(scope.Get()); } @@ -5103,7 +5103,7 @@ bool WrappedID3D11DeviceContext::Serialise_DispatchIndirect(SerialiserType &ser, } } - m_ResourceUses[GetIDForResource(pBufferForArgs)].push_back( + m_ResourceUses[GetIDForDeviceChild(pBufferForArgs)].push_back( EventUsage(m_CurEventID, ResourceUsage::Indirect)); } @@ -5145,7 +5145,7 @@ void WrappedID3D11DeviceContext::DispatchIndirect(ID3D11Buffer *pBufferForArgs, } if(pBufferForArgs && IsActiveCapturing(m_State)) - MarkResourceReferenced(GetIDForResource(pBufferForArgs), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pBufferForArgs), eFrameRef_Read); } #pragma endregion Dispatch @@ -5157,7 +5157,7 @@ bool WrappedID3D11DeviceContext::Serialise_ExecuteCommandList(SerialiserType &se ID3D11CommandList *pCommandList, BOOL RestoreContextState_) { - SERIALISE_ELEMENT_LOCAL(CommandList, GetIDForResource(pCommandList)) + SERIALISE_ELEMENT_LOCAL(CommandList, GetIDForDeviceChild(pCommandList)) .TypedAs("ID3D11CommandList *"_lit); SERIALISE_ELEMENT_LOCAL(RestoreContextState, bool(RestoreContextState_ == TRUE)); @@ -5199,7 +5199,7 @@ bool WrappedID3D11DeviceContext::Serialise_PostExecuteCommandList(SerialiserType ID3D11CommandList *pCommandList, BOOL RestoreContextState_) { - SERIALISE_ELEMENT_LOCAL(CommandList, GetIDForResource(pCommandList)) + SERIALISE_ELEMENT_LOCAL(CommandList, GetIDForDeviceChild(pCommandList)) .TypedAs("ID3D11CommandList *"_lit); SERIALISE_ELEMENT_LOCAL(RestoreContextState, bool(RestoreContextState_ == TRUE)); @@ -5309,7 +5309,7 @@ bool WrappedID3D11DeviceContext::Serialise_FinishCommandList(SerialiserType &ser ID3D11CommandList **ppCommandList) { SERIALISE_ELEMENT_LOCAL(RestoreDeferredContextState, bool(RestoreDeferredContextState_ == TRUE)); - SERIALISE_ELEMENT_LOCAL(pCommandList, GetIDForResource(*ppCommandList)) + SERIALISE_ELEMENT_LOCAL(pCommandList, GetIDForDeviceChild(*ppCommandList)) .TypedAs("ID3D11CommandList *"_lit); Serialise_DebugMessages(GET_SERIALISER); @@ -5341,7 +5341,7 @@ template bool WrappedID3D11DeviceContext::Serialise_PostFinishCommandListSet(SerialiserType &ser, ID3D11CommandList *pCommandList) { - SERIALISE_ELEMENT_LOCAL(CommandList, GetIDForResource(pCommandList)) + SERIALISE_ELEMENT_LOCAL(CommandList, GetIDForDeviceChild(pCommandList)) .TypedAs("ID3D11CommandList *"_lit); D3D11RenderState RenderState(*m_CurrentPipelineState); @@ -5395,7 +5395,6 @@ HRESULT WrappedID3D11DeviceContext::FinishCommandList(BOOL RestoreDeferredContex D3D11ResourceRecord *record = m_pDevice->GetResourceManager()->AddResourceRecord(wrapped->GetResourceID()); - record->ResType = Resource_CommandList; record->Length = 0; record->InternalResource = true; @@ -5576,15 +5575,15 @@ bool WrappedID3D11DeviceContext::Serialise_CopySubresourceRegion( { if(pDstResource && pSrcResource) { - m_pRealContext->CopySubresourceRegion( - GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, DstX, DstY, DstZ, - GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, pSrcBox); + m_pRealContext->CopySubresourceRegion(UnwrapResource(pDstResource), DstSubresource, DstX, + DstY, DstZ, UnwrapResource(pSrcResource), + SrcSubresource, pSrcBox); } if(IsLoading(m_State)) { - ResourceId dstLiveID = GetIDForResource(pDstResource); - ResourceId srcLiveID = GetIDForResource(pSrcResource); + ResourceId dstLiveID = GetIDForDeviceChild(pDstResource); + ResourceId srcLiveID = GetIDForDeviceChild(pSrcResource); ResourceId dstOrigID = GetResourceManager()->GetOriginalID(dstLiveID); ResourceId srcOrigID = GetResourceManager()->GetOriginalID(srcLiveID); @@ -5639,8 +5638,8 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion(ID3D11Resource *pDstResou m_EmptyCommandList = false; SERIALISE_TIME_CALL(m_pRealContext->CopySubresourceRegion( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, DstX, DstY, - DstZ, m_pDevice->GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, pSrcBox)); + UnwrapResource(pDstResource), DstSubresource, DstX, DstY, DstZ, UnwrapResource(pSrcResource), + SrcSubresource, pSrcBox)); if(IsActiveCapturing(m_State)) { @@ -5652,37 +5651,41 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion(ID3D11Resource *pDstResou pSrcResource, SrcSubresource, pSrcBox); D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pDstResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstResource)); RDCASSERT(record); D3D11ResourceRecord *srcRecord = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pSrcResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pSrcResource)); RDCASSERT(srcRecord); record->AddParent(srcRecord); m_ContextRecord->AddChunk(scope.Get()); - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); // assume partial update - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_Read); - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pSrcResource), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pSrcResource), eFrameRef_Read); } else if(IsBackgroundCapturing(m_State)) { D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pDstResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstResource)); RDCASSERT(record); D3D11ResourceRecord *srcRecord = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pSrcResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pSrcResource)); RDCASSERT(srcRecord); - if(m_pDevice->GetResourceManager()->IsResourceDirty(GetIDForResource(pSrcResource))) + D3D11_RESOURCE_DIMENSION srcDim, dstDim; + pDstResource->GetType(&dstDim); + pSrcResource->GetType(&srcDim); + + if(m_pDevice->GetResourceManager()->IsResourceDirty(GetIDForDeviceChild(pSrcResource))) { - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); } - else if(WrappedID3D11Buffer::IsAlloc(pDstResource) && WrappedID3D11Buffer::IsAlloc(pSrcResource)) + else if(srcDim == D3D11_RESOURCE_DIMENSION_BUFFER && dstDim == D3D11_RESOURCE_DIMENSION_BUFFER) { // perform copy manually (since we have buffer contents locally) @@ -5711,7 +5714,7 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion(ID3D11Resource *pDstResou { // GPU dirty. Just let initial state handle this. - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); } } } @@ -5732,14 +5735,13 @@ bool WrappedID3D11DeviceContext::Serialise_CopyResource(SerialiserType &ser, { if(pDstResource && pSrcResource) { - m_pRealContext->CopyResource(m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), - m_pDevice->GetResourceManager()->UnwrapResource(pSrcResource)); + m_pRealContext->CopyResource(UnwrapResource(pDstResource), UnwrapResource(pSrcResource)); } if(IsLoading(m_State)) { - ResourceId dstLiveID = GetIDForResource(pDstResource); - ResourceId srcLiveID = GetIDForResource(pSrcResource); + ResourceId dstLiveID = GetIDForDeviceChild(pDstResource); + ResourceId srcLiveID = GetIDForDeviceChild(pSrcResource); ResourceId dstOrigID = GetResourceManager()->GetOriginalID(dstLiveID); ResourceId srcOrigID = GetResourceManager()->GetOriginalID(srcLiveID); @@ -5787,8 +5789,7 @@ void WrappedID3D11DeviceContext::CopyResource(ID3D11Resource *pDstResource, m_EmptyCommandList = false; SERIALISE_TIME_CALL( - m_pRealContext->CopyResource(m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), - m_pDevice->GetResourceManager()->UnwrapResource(pSrcResource))); + m_pRealContext->CopyResource(UnwrapResource(pDstResource), UnwrapResource(pSrcResource))); if(IsActiveCapturing(m_State)) { @@ -5799,38 +5800,42 @@ void WrappedID3D11DeviceContext::CopyResource(ID3D11Resource *pDstResource, Serialise_CopyResource(GET_SERIALISER, pDstResource, pSrcResource); D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pDstResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstResource)); RDCASSERT(record); D3D11ResourceRecord *srcRecord = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pSrcResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pSrcResource)); RDCASSERT(srcRecord); record->AddParent(srcRecord); m_ContextRecord->AddChunk(scope.Get()); - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pSrcResource), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pSrcResource), eFrameRef_Read); } else if(IsBackgroundCapturing(m_State)) { D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pDstResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstResource)); RDCASSERT(record); D3D11ResourceRecord *srcRecord = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pSrcResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pSrcResource)); RDCASSERT(srcRecord); record->UpdateCount++; + D3D11_RESOURCE_DIMENSION srcDim, dstDim; + pDstResource->GetType(&dstDim); + pSrcResource->GetType(&srcDim); + if(record->UpdateCount > 5 || - m_pDevice->GetResourceManager()->IsResourceDirty(GetIDForResource(pSrcResource))) + m_pDevice->GetResourceManager()->IsResourceDirty(GetIDForDeviceChild(pSrcResource))) { - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); } - else if(WrappedID3D11Buffer::IsAlloc(pDstResource) && WrappedID3D11Buffer::IsAlloc(pSrcResource)) + else if(srcDim == D3D11_RESOURCE_DIMENSION_BUFFER && dstDim == D3D11_RESOURCE_DIMENSION_BUFFER) { // perform copy manually (since we have buffer contents locally) @@ -5842,12 +5847,7 @@ void WrappedID3D11DeviceContext::CopyResource(ID3D11Resource *pDstResource, memcpy(to, from, (size_t)record->Length); } - else if((WrappedID3D11Texture1D::IsAlloc(pDstResource) && - WrappedID3D11Texture1D::IsAlloc(pSrcResource)) || - (WrappedID3D11Texture2D1::IsAlloc(pDstResource) && - WrappedID3D11Texture2D1::IsAlloc(pSrcResource)) || - (WrappedID3D11Texture3D1::IsAlloc(pDstResource) && - WrappedID3D11Texture3D1::IsAlloc(pSrcResource))) + else if(srcDim != D3D11_RESOURCE_DIMENSION_BUFFER && dstDim != D3D11_RESOURCE_DIMENSION_BUFFER) { if(record->DataInSerialiser && srcRecord->DataInSerialiser) { @@ -5902,8 +5902,7 @@ void WrappedID3D11DeviceContext::UpdateSubresource(ID3D11Resource *pDstResource, m_EmptyCommandList = false; SERIALISE_TIME_CALL(m_pRealContext->UpdateSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, pDstBox, - pSrcData, SrcRowPitch, SrcDepthPitch)); + UnwrapResource(pDstResource), DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch)); if(pDstBox && m_NeedUpdateSubWorkaround && GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) { @@ -5914,28 +5913,27 @@ void WrappedID3D11DeviceContext::UpdateSubresource(ID3D11Resource *pDstResource, DXGI_FORMAT fmt = DXGI_FORMAT_UNKNOWN; - if(WrappedID3D11Texture1D::IsAlloc(pDstResource)) + D3D11_RESOURCE_DIMENSION dstDim; + pDstResource->GetType(&dstDim); + + if(dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { D3D11_TEXTURE1D_DESC desc; ((WrappedID3D11Texture1D *)pDstResource)->GetDesc(&desc); fmt = desc.Format; } - else if(WrappedID3D11Texture2D1::IsAlloc(pDstResource)) + else if(dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { D3D11_TEXTURE2D_DESC desc; ((WrappedID3D11Texture2D1 *)pDstResource)->GetDesc(&desc); fmt = desc.Format; } - else if(WrappedID3D11Texture3D1::IsAlloc(pDstResource)) + else if(dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { D3D11_TEXTURE3D_DESC desc; ((WrappedID3D11Texture3D1 *)pDstResource)->GetDesc(&desc); fmt = desc.Format; } - else - { - RDCASSERT(WrappedID3D11Buffer::IsAlloc(pDstResource)); - } // convert from pixels to blocks if(IsBlockFormat(fmt)) @@ -5962,21 +5960,24 @@ void WrappedID3D11DeviceContext::UpdateSubresource(ID3D11Resource *pDstResource, Serialise_UpdateSubresource(GET_SERIALISER, pDstResource, DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch); - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_PartialWrite); - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); m_ContextRecord->AddChunk(scope.Get()); } else if(IsBackgroundCapturing(m_State)) { - ResourceId idx = GetIDForResource(pDstResource); + ResourceId idx = GetIDForDeviceChild(pDstResource); D3D11ResourceRecord *record = m_pDevice->GetResourceManager()->GetResourceRecord(idx); RDCASSERT(record); + D3D11_RESOURCE_DIMENSION dstDim; + pDstResource->GetType(&dstDim); + // buffers MUST update the whole resource, and don't have any subresources, // so this effectively becomes just a map/unmap pair. - if(WrappedID3D11Buffer::IsAlloc(pDstResource)) + if(dstDim == D3D11_RESOURCE_DIMENSION_BUFFER) { RDCASSERT(record->NumSubResources == 0); @@ -5994,9 +5995,7 @@ void WrappedID3D11DeviceContext::UpdateSubresource(ID3D11Resource *pDstResource, memcpy(ptr, pSrcData, length); } - else if(WrappedID3D11Texture1D::IsAlloc(pDstResource) || - WrappedID3D11Texture2D1::IsAlloc(pDstResource) || - WrappedID3D11Texture3D1::IsAlloc(pDstResource)) + else if(dstDim != D3D11_RESOURCE_DIMENSION_UNKNOWN) { RDCASSERT(record->Length == 1 && record->NumSubResources > 0); @@ -6037,13 +6036,13 @@ void WrappedID3D11DeviceContext::UpdateSubresource(ID3D11Resource *pDstResource, } else { - WrappedID3D11Texture1D *tex1 = WrappedID3D11Texture1D::IsAlloc(pDstResource) + WrappedID3D11Texture1D *tex1 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE1D ? (WrappedID3D11Texture1D *)pDstResource : NULL; - WrappedID3D11Texture2D1 *tex2 = WrappedID3D11Texture2D1::IsAlloc(pDstResource) + WrappedID3D11Texture2D1 *tex2 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE2D ? (WrappedID3D11Texture2D1 *)pDstResource : NULL; - WrappedID3D11Texture3D1 *tex3 = WrappedID3D11Texture3D1::IsAlloc(pDstResource) + WrappedID3D11Texture3D1 *tex3 = dstDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D ? (WrappedID3D11Texture3D1 *)pDstResource : NULL; @@ -6182,7 +6181,7 @@ bool WrappedID3D11DeviceContext::Serialise_CopyStructureCount(SerialiserType &se { WrappedID3D11UnorderedAccessView1 *view = (WrappedID3D11UnorderedAccessView1 *)pSrcView; - ResourceId dstLiveID = GetIDForResource(pDstBuffer); + ResourceId dstLiveID = GetIDForDeviceChild(pDstBuffer); ResourceId srcLiveID = view->GetResourceResID(); ResourceId dstOrigID = GetResourceManager()->GetOriginalID(dstLiveID); ResourceId srcOrigID = GetResourceManager()->GetOriginalID(srcLiveID); @@ -6241,28 +6240,28 @@ void WrappedID3D11DeviceContext::CopyStructureCount(ID3D11Buffer *pDstBuffer, m_ContextRecord->AddChunk(scope.Get()); - MarkDirtyResource(GetIDForResource(pDstBuffer)); + MarkDirtyResource(GetIDForDeviceChild(pDstBuffer)); - MarkResourceReferenced(GetIDForResource(pDstBuffer), eFrameRef_Read); - MarkResourceReferenced(GetIDForResource(pDstBuffer), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pDstBuffer), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDstBuffer), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pSrcView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pSrcView), eFrameRef_Read); } else if(IsBackgroundCapturing(m_State)) { // needs to go into device serialiser D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pDstBuffer)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pDstBuffer)); RDCASSERT(record); D3D11ResourceRecord *srcRecord = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pSrcView)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pSrcView)); RDCASSERT(srcRecord); record->AddParent(srcRecord); - MarkDirtyResource(GetIDForResource(pDstBuffer)); + MarkDirtyResource(GetIDForDeviceChild(pDstBuffer)); } } @@ -6287,15 +6286,14 @@ bool WrappedID3D11DeviceContext::Serialise_ResolveSubresource(SerialiserType &se { if(pDstResource && pSrcResource) { - m_pRealContext->ResolveSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, - m_pDevice->GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, Format); + m_pRealContext->ResolveSubresource(UnwrapResource(pDstResource), DstSubresource, + UnwrapResource(pSrcResource), SrcSubresource, Format); } if(IsLoading(m_State)) { - ResourceId dstLiveID = GetIDForResource(pDstResource); - ResourceId srcLiveID = GetIDForResource(pSrcResource); + ResourceId dstLiveID = GetIDForDeviceChild(pDstResource); + ResourceId srcLiveID = GetIDForDeviceChild(pSrcResource); ResourceId dstOrigID = GetResourceManager()->GetOriginalID(dstLiveID); ResourceId srcOrigID = GetResourceManager()->GetOriginalID(srcLiveID); @@ -6347,9 +6345,9 @@ void WrappedID3D11DeviceContext::ResolveSubresource(ID3D11Resource *pDstResource m_EmptyCommandList = false; - SERIALISE_TIME_CALL(m_pRealContext->ResolveSubresource( - m_pDevice->GetResourceManager()->UnwrapResource(pDstResource), DstSubresource, - m_pDevice->GetResourceManager()->UnwrapResource(pSrcResource), SrcSubresource, Format)); + SERIALISE_TIME_CALL( + m_pRealContext->ResolveSubresource(UnwrapResource(pDstResource), DstSubresource, + UnwrapResource(pSrcResource), SrcSubresource, Format)); if(IsActiveCapturing(m_State)) { @@ -6362,14 +6360,14 @@ void WrappedID3D11DeviceContext::ResolveSubresource(ID3D11Resource *pDstResource m_ContextRecord->AddChunk(scope.Get()); - MarkDirtyResource(GetIDForResource(pDstResource)); - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_Read); - MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pSrcResource), eFrameRef_Read); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDstResource), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForDeviceChild(pSrcResource), eFrameRef_Read); } else if(IsBackgroundCapturing(m_State)) { - MarkDirtyResource(GetIDForResource(pDstResource)); + MarkDirtyResource(GetIDForDeviceChild(pDstResource)); } } @@ -6406,7 +6404,7 @@ bool WrappedID3D11DeviceContext::Serialise_GenerateMips(SerialiserType &ser, DrawcallDescription draw; draw.name = "GenerateMips(" + - ToStr(GetResourceManager()->GetOriginalID(GetIDForResource(pShaderResourceView))) + ")"; + ToStr(GetResourceManager()->GetOriginalID(GetIDForDeviceChild(pShaderResourceView))) + ")"; draw.flags |= DrawFlags::GenMips; AddDrawcall(draw, true); @@ -6446,7 +6444,7 @@ void WrappedID3D11DeviceContext::GenerateMips(ID3D11ShaderResourceView *pShaderR MarkResourceReferenced(id, eFrameRef_Read); MarkResourceReferenced(id, eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pShaderResourceView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pShaderResourceView), eFrameRef_Read); } else if(IsBackgroundCapturing(m_State)) { @@ -6470,7 +6468,7 @@ bool WrappedID3D11DeviceContext::Serialise_ClearState(SerialiserType &ser) if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); if(m_StreamOutCounters[id].running) { @@ -6514,7 +6512,7 @@ void WrappedID3D11DeviceContext::ClearState() if(buf) { - ResourceId id = GetIDForResource(buf); + ResourceId id = GetIDForDeviceChild(buf); if(m_StreamOutCounters[id].running) { @@ -6601,7 +6599,7 @@ void WrappedID3D11DeviceContext::ClearRenderTargetView(ID3D11RenderTargetView *p Serialise_ClearRenderTargetView(GET_SERIALISER, pRenderTargetView, ColorRGBA); MarkResourceReferenced(GetViewResourceResID(pRenderTargetView), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pRenderTargetView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pRenderTargetView), eFrameRef_Read); MarkDirtyResource(GetViewResourceResID(pRenderTargetView)); m_ContextRecord->AddChunk(scope.Get()); @@ -6680,7 +6678,7 @@ void WrappedID3D11DeviceContext::ClearUnorderedAccessViewUint( if(pUnorderedAccessView) { MarkResourceReferenced(GetViewResourceResID(pUnorderedAccessView), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pUnorderedAccessView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pUnorderedAccessView), eFrameRef_Read); } MarkDirtyResource(GetViewResourceResID(pUnorderedAccessView)); @@ -6761,7 +6759,7 @@ void WrappedID3D11DeviceContext::ClearUnorderedAccessViewFloat( if(pUnorderedAccessView) { MarkResourceReferenced(GetViewResourceResID(pUnorderedAccessView), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pUnorderedAccessView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pUnorderedAccessView), eFrameRef_Read); } MarkDirtyResource(GetViewResourceResID(pUnorderedAccessView)); @@ -6856,7 +6854,7 @@ void WrappedID3D11DeviceContext::ClearDepthStencilView(ID3D11DepthStencilView *p Serialise_ClearDepthStencilView(GET_SERIALISER, pDepthStencilView, ClearFlags, Depth, Stencil); MarkResourceReferenced(GetViewResourceResID(pDepthStencilView), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read); + MarkResourceReferenced(GetIDForDeviceChild(pDepthStencilView), eFrameRef_Read); MarkDirtyResource(GetViewResourceResID(pDepthStencilView)); m_ContextRecord->AddChunk(scope.Get()); @@ -7088,7 +7086,7 @@ void WrappedID3D11DeviceContext::SetPredication(ID3D11Predicate *pPredicate, BOO FLOAT WrappedID3D11DeviceContext::GetResourceMinLOD(ID3D11Resource *pResource) { - return m_pRealContext->GetResourceMinLOD(m_pDevice->GetResourceManager()->UnwrapResource(pResource)); + return m_pRealContext->GetResourceMinLOD(UnwrapResource(pResource)); } template @@ -7103,8 +7101,7 @@ bool WrappedID3D11DeviceContext::Serialise_SetResourceMinLOD(SerialiserType &ser if(IsReplayingAndReading()) { if(pResource) - m_pRealContext->SetResourceMinLOD(m_pDevice->GetResourceManager()->UnwrapResource(pResource), - MinLOD); + m_pRealContext->SetResourceMinLOD(UnwrapResource(pResource), MinLOD); } return true; @@ -7116,8 +7113,7 @@ void WrappedID3D11DeviceContext::SetResourceMinLOD(ID3D11Resource *pResource, FL m_EmptyCommandList = false; - SERIALISE_TIME_CALL(m_pRealContext->SetResourceMinLOD( - m_pDevice->GetResourceManager()->UnwrapResource(pResource), MinLOD)); + SERIALISE_TIME_CALL(m_pRealContext->SetResourceMinLOD(UnwrapResource(pResource), MinLOD)); if(IsActiveCapturing(m_State)) { @@ -7185,13 +7181,16 @@ void MapIntercept::SetD3D(D3D11_MAPPED_SUBRESOURCE d3dMap) void MapIntercept::InitWrappedResource(ID3D11Resource *res, UINT sub, void *appMemory) { - if(WrappedID3D11Buffer::IsAlloc(res)) + D3D11_RESOURCE_DIMENSION dim; + res->GetType(&dim); + + if(dim == D3D11_RESOURCE_DIMENSION_BUFFER) Init((ID3D11Buffer *)res, appMemory); - else if(WrappedID3D11Texture1D::IsAlloc(res)) + else if(dim == D3D11_RESOURCE_DIMENSION_TEXTURE1D) Init((ID3D11Texture1D *)res, sub, appMemory); - else if(WrappedID3D11Texture2D1::IsAlloc(res)) + else if(dim == D3D11_RESOURCE_DIMENSION_TEXTURE2D) Init((ID3D11Texture2D *)res, sub, appMemory); - else if(WrappedID3D11Texture3D1::IsAlloc(res)) + else if(dim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) Init((ID3D11Texture3D *)res, sub, appMemory); else RDCERR("Unexpected resource type"); @@ -7400,7 +7399,7 @@ bool WrappedID3D11DeviceContext::Serialise_Map(SerialiserType &ser, ID3D11Resour mappedResource = *pMappedResource; D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(record); @@ -7413,7 +7412,7 @@ bool WrappedID3D11DeviceContext::Serialise_Map(SerialiserType &ser, ID3D11Resour if(IsActiveCapturing(m_State) || !record->DataInSerialiser) { - ResourceId Resource = GetIDForResource(pResource); + ResourceId Resource = GetIDForDeviceChild(pResource); RDCASSERT(m_OpenMaps.find(MappedResource(Resource, Subresource)) == m_OpenMaps.end()); @@ -7447,7 +7446,10 @@ bool WrappedID3D11DeviceContext::Serialise_Map(SerialiserType &ser, ID3D11Resour if(initial) { - if(WrappedID3D11Buffer::IsAlloc(pResource)) + D3D11_RESOURCE_DIMENSION dim; + pResource->GetType(&dim); + + if(dim == D3D11_RESOURCE_DIMENSION_BUFFER) { ID3D11Buffer *stage = (ID3D11Buffer *)initial; @@ -7530,7 +7532,7 @@ bool WrappedID3D11DeviceContext::Serialise_Map(SerialiserType &ser, ID3D11Resour { size_t ctxMapID = 0; - ResourceId Resource = GetIDForResource(pResource); + ResourceId Resource = GetIDForDeviceChild(pResource); if(GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) { @@ -7561,7 +7563,7 @@ bool WrappedID3D11DeviceContext::Serialise_Map(SerialiserType &ser, ID3D11Resour *pMappedResource = intercept.app; - m_OpenMaps[MappedResource(GetIDForResource(pResource), Subresource)] = intercept; + m_OpenMaps[MappedResource(GetIDForDeviceChild(pResource), Subresource)] = intercept; } else { @@ -7600,13 +7602,13 @@ HRESULT WrappedID3D11DeviceContext::Map(ID3D11Resource *pResource, UINT Subresou m_EmptyCommandList = false; - ResourceId id = GetIDForResource(pResource); + ResourceId id = GetIDForDeviceChild(pResource); bool directMap = false; if(m_HighTrafficResources.find(id) != m_HighTrafficResources.end() && !IsActiveCapturing(m_State)) directMap = true; - if(m_pDevice->GetResourceManager()->IsResourceDirty(GetIDForResource(pResource)) && + if(m_pDevice->GetResourceManager()->IsResourceDirty(GetIDForDeviceChild(pResource)) && !IsActiveCapturing(m_State)) directMap = true; @@ -7621,14 +7623,14 @@ HRESULT WrappedID3D11DeviceContext::Map(ID3D11Resource *pResource, UINT Subresou if(directMap && IsBackgroundCapturing(m_State)) { - ID3D11Resource *unwrapped = m_pDevice->GetResourceManager()->UnwrapResource(pResource); + ID3D11Resource *unwrapped = UnwrapResource(pResource); return m_pRealContext->Map(unwrapped, Subresource, MapType, MapFlags, pMappedResource); } // can't promise no-overwrite as we're going to blat the whole buffer! HRESULT ret; SERIALISE_TIME_CALL(ret = m_pRealContext->Map( - m_pDevice->GetResourceManager()->UnwrapResource(pResource), Subresource, + UnwrapResource(pResource), Subresource, MapType == D3D11_MAP_WRITE_NO_OVERWRITE ? D3D11_MAP_WRITE_DISCARD : MapType, MapFlags, pMappedResource)); @@ -7642,11 +7644,11 @@ HRESULT WrappedID3D11DeviceContext::Map(ID3D11Resource *pResource, UINT Subresou intercept.MapType = MapType; intercept.MapFlags = MapFlags; - m_OpenMaps[MappedResource(GetIDForResource(pResource), Subresource)] = intercept; + m_OpenMaps[MappedResource(GetIDForDeviceChild(pResource), Subresource)] = intercept; } else { - GetResourceManager()->MarkDirtyResource(GetIDForResource(pResource)); + GetResourceManager()->MarkDirtyResource(GetIDForDeviceChild(pResource)); // create a chunk purely for the user's benefit USE_SCRATCH_SERIALISER(); @@ -7659,12 +7661,7 @@ HRESULT WrappedID3D11DeviceContext::Map(ID3D11Resource *pResource, UINT Subresou } else // IsIdleCapturing(m_State) { - RDCASSERT(WrappedID3D11Buffer::IsAlloc(pResource) || - WrappedID3D11Texture1D::IsAlloc(pResource) || - WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource)); - - ResourceId Id = GetIDForResource(pResource); + ResourceId Id = GetIDForDeviceChild(pResource); D3D11ResourceRecord *record = m_pDevice->GetResourceManager()->GetResourceRecord(Id); RDCASSERT(record); @@ -7700,7 +7697,7 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT(Subresource); - MappedResource mapIdx(GetIDForResource(pResource), Subresource); + MappedResource mapIdx(GetIDForDeviceChild(pResource), Subresource); MapIntercept intercept; size_t ctxMapID = 0; D3D11ResourceRecord *record = NULL; @@ -7714,7 +7711,7 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso // handle book-keeping during capture mode if(ser.IsWriting()) { - record = m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + record = m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(record); if((int)Subresource < record->NumSubResources) @@ -7787,9 +7784,12 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso diffStart = (uint32_t)s; diffEnd = (uint32_t)e; + D3D11_RESOURCE_DIMENSION dim; + pResource->GetType(&dim); + // structured buffers must have copies aligned to their structure width, so we align down and // up the detected diff start/end region to match. - if(WrappedID3D11Buffer::IsAlloc(pResource)) + if(dim == D3D11_RESOURCE_DIMENSION_BUFFER) { D3D11_BUFFER_DESC bufdesc = {}; ((WrappedID3D11Buffer *)pResource)->GetDesc(&bufdesc); @@ -7888,7 +7888,6 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso } else if(intercept.MapType == D3D11_MAP_WRITE_NO_OVERWRITE) { - RDCASSERT(WrappedID3D11Buffer::IsAlloc(pResource)); ID3D11Buffer *mapContents = NULL; D3D11_BUFFER_DESC bdesc; @@ -7912,9 +7911,8 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso } else { - m_pRealContext->CopySubresourceRegion(GetResourceManager()->UnwrapResource(pResource), - mapIdx.subresource, diffStart, 0, 0, mapContents, 0, - NULL); + m_pRealContext->CopySubresourceRegion(UnwrapResource(pResource), mapIdx.subresource, + diffStart, 0, 0, mapContents, 0, NULL); SAFE_RELEASE(mapContents); } @@ -7925,8 +7923,8 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso UINT flags = intercept.MapFlags & ~D3D11_MAP_FLAG_DO_NOT_WAIT; - HRESULT hr = m_pRealContext->Map(GetResourceManager()->UnwrapResource(pResource), - mapIdx.subresource, intercept.MapType, flags, &mappedResource); + HRESULT hr = m_pRealContext->Map(UnwrapResource(pResource), mapIdx.subresource, + intercept.MapType, flags, &mappedResource); RDCASSERT(mappedResource.pData); @@ -7941,8 +7939,7 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso intercept.CopyToD3D(diffStart, diffEnd); - m_pRealContext->Unmap(m_pDevice->GetResourceManager()->UnwrapResource(pResource), - mapIdx.subresource); + m_pRealContext->Unmap(UnwrapResource(pResource), mapIdx.subresource); } } @@ -7960,7 +7957,7 @@ void WrappedID3D11DeviceContext::Unmap(ID3D11Resource *pResource, UINT Subresour m_EmptyCommandList = false; - ResourceId id = GetIDForResource(pResource); + ResourceId id = GetIDForDeviceChild(pResource); auto it = m_OpenMaps.find(MappedResource(id, Subresource)); @@ -8015,13 +8012,8 @@ void WrappedID3D11DeviceContext::Unmap(ID3D11Resource *pResource, UINT Subresour } else // IsIdleCapturing(m_State) { - RDCASSERT(WrappedID3D11Buffer::IsAlloc(pResource) || - WrappedID3D11Texture1D::IsAlloc(pResource) || - WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource)); - D3D11ResourceRecord *record = - m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + m_pDevice->GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(record); D3D11ResourceRecord *baserecord = record; @@ -8056,7 +8048,7 @@ void WrappedID3D11DeviceContext::Unmap(ID3D11Resource *pResource, UINT Subresour } } - m_pRealContext->Unmap(m_pDevice->GetResourceManager()->UnwrapResource(pResource), Subresource); + m_pRealContext->Unmap(UnwrapResource(pResource), Subresource); } #pragma endregion Map diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index 51336e364..6617e339d 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -369,7 +369,7 @@ void D3D11DebugManager::FillWithDiscardPattern(DiscardType type, ID3D11Resource UINT mip, const D3D11_RECT *pRect, UINT NumRects) { D3D11MarkerRegion region(StringFormat::Fmt("FillWithDiscardPattern %s slice %u mip %u", - ToStr(GetIDForResource(res)).c_str(), slice, mip)); + ToStr(GetIDForDeviceChild(res)).c_str(), slice, mip)); D3D11_RECT all = {0, 0, 65536, 65536}; if(NumRects == 0) @@ -763,8 +763,8 @@ void D3D11DebugManager::FillWithDiscardPattern(DiscardType type, ID3D11Resource void D3D11DebugManager::FillWithDiscardPattern(DiscardType type, ID3D11View *view, const D3D11_RECT *pRect, UINT NumRects) { - D3D11MarkerRegion region( - StringFormat::Fmt("FillWithDiscardPattern view %s", ToStr(GetIDForResource(view)).c_str())); + D3D11MarkerRegion region(StringFormat::Fmt("FillWithDiscardPattern view %s", + ToStr(GetIDForDeviceChild(view)).c_str())); ResourceRange range = ResourceRange::Null; diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 60fec09fc..02b0b1df7 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -122,7 +122,6 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device *realDevice, D3D11InitPara if(!RenderDoc::Inst().IsReplayApp()) { m_DeviceRecord = GetResourceManager()->AddResourceRecord(m_ResourceID); - m_DeviceRecord->ResType = Resource_Unknown; m_DeviceRecord->DataInSerialiser = false; m_DeviceRecord->InternalResource = true; m_DeviceRecord->Length = 0; @@ -1334,7 +1333,7 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store for(const BufferDescription &b : counterBuffers) { ID3D11UnorderedAccessView *uav = GetDebugManager()->GetCounterBufferUAV(b.resourceId); - ResourceId uavId = GetResourceManager()->GetOriginalID(GetIDForResource(uav)); + ResourceId uavId = GetResourceManager()->GetOriginalID(GetIDForDeviceChild(uav)); ResourceDescription &uavDesc = GetReplay()->GetResourceDesc(uavId); ResourceDescription &bufDesc = GetReplay()->GetResourceDesc(b.resourceId); @@ -1575,7 +1574,6 @@ IUnknown *WrappedID3D11Device::WrapSwapchainBuffer(IDXGISwapper *swapper, DXGI_F if(IsCaptureMode(m_State)) { D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = Resource_Texture2D; record->DataInSerialiser = false; record->Length = 0; record->NumSubResources = 0; @@ -2539,7 +2537,7 @@ void WrappedID3D11Device::AddResourceCurChunk(ResourceId id) void WrappedID3D11Device::DerivedResource(ID3D11DeviceChild *parent, ResourceId child) { - ResourceId parentId = GetResourceManager()->GetOriginalID(GetIDForResource(parent)); + ResourceId parentId = GetResourceManager()->GetOriginalID(GetIDForDeviceChild(parent)); GetReplay()->GetResourceDesc(parentId).derivedResources.push_back(child); GetReplay()->GetResourceDesc(child).parentResources.push_back(parentId); @@ -2556,11 +2554,11 @@ bool WrappedID3D11Device::Serialise_SetShaderDebugPath(SerialiserType &ser, if(IsReplayingAndReading() && pResource) { - ResourceId resId = GetResourceManager()->GetOriginalID(GetIDForResource(pResource)); + ResourceId resId = GetResourceManager()->GetOriginalID(GetIDForDeviceChild(pResource)); AddResourceCurChunk(resId); - auto it = WrappedShader::m_ShaderList.find(GetIDForResource(pResource)); + auto it = WrappedShader::m_ShaderList.find(GetIDForDeviceChild(pResource)); if(it != WrappedShader::m_ShaderList.end()) it->second->SetDebugInfoPath(Path); @@ -2573,7 +2571,7 @@ HRESULT WrappedID3D11Device::SetShaderDebugPath(ID3D11DeviceChild *pResource, co { if(IsCaptureMode(m_State)) { - ResourceId idx = GetIDForResource(pResource); + ResourceId idx = GetIDForDeviceChild(pResource); D3D11ResourceRecord *record = GetResourceManager()->GetResourceRecord(idx); if(record == NULL) @@ -2610,7 +2608,7 @@ bool WrappedID3D11Device::Serialise_SetResourceName(SerialiserType &ser, if(IsReplayingAndReading() && pResource) { ResourceDescription &descr = GetReplay()->GetResourceDesc( - GetResourceManager()->GetOriginalID(GetIDForResource(pResource))); + GetResourceManager()->GetOriginalID(GetIDForDeviceChild(pResource))); if(Name && Name[0]) descr.SetCustomName(Name); AddResourceCurChunk(descr); @@ -2628,7 +2626,7 @@ void WrappedID3D11Device::SetResourceName(ID3D11DeviceChild *pResource, const ch if(IsCaptureMode(m_State) && !WrappedID3D11DeviceContext::IsAlloc(pResource) && !WrappedID3D11CommandList::IsAlloc(pResource)) { - ResourceId idx = GetIDForResource(pResource); + ResourceId idx = GetIDForDeviceChild(pResource); D3D11ResourceRecord *record = GetResourceManager()->GetResourceRecord(idx); if(record == NULL) diff --git a/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp index 089ae9e4b..d7fd71825 100644 --- a/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp @@ -73,7 +73,7 @@ bool WrappedID3D11Device::Serialise_CreateBlendState1(SerialiserType &ser, ID3D11BlendState1 **ppBlendState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pBlendStateDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppBlendState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppBlendState)) .TypedAs("ID3D11BlendState1 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -163,7 +163,6 @@ HRESULT WrappedID3D11Device::CreateBlendState1(const D3D11_BLEND_DESC1 *pBlendSt RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); record->Length = 0; record->AddChunk(scope.Get()); @@ -181,7 +180,7 @@ bool WrappedID3D11Device::Serialise_CreateRasterizerState1( ID3D11RasterizerState1 **ppRasterizerState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pRasterizerDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppRasterizerState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppRasterizerState)) .TypedAs("ID3D11RasterizerState1 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -271,7 +270,7 @@ HRESULT WrappedID3D11Device::CreateRasterizerState1(const D3D11_RASTERIZER_DESC1 RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); diff --git a/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp index 2bd90673e..352cc50c5 100644 --- a/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp @@ -48,7 +48,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture2D1(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pInitialData, pInitialData ? numSubresources : 0); } - SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture2D)) + SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForDeviceChild(*ppTexture2D)) .TypedAs("ID3D11Texture2D *"_lit); rdcarray descs = @@ -152,7 +152,7 @@ HRESULT WrappedID3D11Device::CreateTexture2D1(const D3D11_TEXTURE2D_DESC1 *pDesc } D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(wrapped)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(wrapped)); RDCASSERT(record); record->AddChunk(chunk); @@ -188,7 +188,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture3D1(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pInitialData, pInitialData ? numSubresources : 0); } - SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture3D)) + SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForDeviceChild(*ppTexture3D)) .TypedAs("ID3D11Texture3D *"_lit); rdcarray descs = @@ -292,7 +292,7 @@ HRESULT WrappedID3D11Device::CreateTexture3D1(const D3D11_TEXTURE3D_DESC1 *pDesc } D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(wrapped)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(wrapped)); RDCASSERT(record); record->AddChunk(chunk); @@ -318,7 +318,7 @@ bool WrappedID3D11Device::Serialise_CreateShaderResourceView1( { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppSRView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppSRView)) .TypedAs("ID3D11ShaderResourceView1 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -366,8 +366,7 @@ bool WrappedID3D11Device::Serialise_CreateShaderResourceView1( if(m_pDevice3) { - hr = m_pDevice3->CreateShaderResourceView1(GetResourceManager()->UnwrapResource(pResource), - pSRVDesc, &ret); + hr = m_pDevice3->CreateShaderResourceView1(UnwrapResource(pResource), pSRVDesc, &ret); } else { @@ -402,14 +401,13 @@ HRESULT WrappedID3D11Device::CreateShaderResourceView1(ID3D11Resource *pResource // validation, returns S_FALSE for valid params, or an error code if(ppSRView == NULL) - return m_pDevice3->CreateShaderResourceView1(GetResourceManager()->UnwrapResource(pResource), - pDesc, NULL); + return m_pDevice3->CreateShaderResourceView1(UnwrapResource(pResource), pDesc, NULL); ID3D11ShaderResourceView1 *real = NULL; ID3D11ShaderResourceView1 *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice3->CreateShaderResourceView1( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice3->CreateShaderResourceView1(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -427,11 +425,9 @@ HRESULT WrappedID3D11Device::CreateShaderResourceView1(ID3D11Resource *pResource chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -441,19 +437,12 @@ HRESULT WrappedID3D11Device::CreateShaderResourceView1(ID3D11Resource *pResource RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); record->Length = 0; record->AddParent(parent); record->AddChunk(chunk); } - else - { - RDCERR("Unexpected resource type in SRV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppSRView = wrapped; @@ -469,7 +458,7 @@ bool WrappedID3D11Device::Serialise_CreateRenderTargetView1(SerialiserType &ser, { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppRTView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppRTView)) .TypedAs("ID3D11RenderTargetView1 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -513,8 +502,7 @@ bool WrappedID3D11Device::Serialise_CreateRenderTargetView1(SerialiserType &ser, if(m_pDevice3) { - hr = m_pDevice3->CreateRenderTargetView1(GetResourceManager()->UnwrapResource(pResource), - pRTVDesc, &ret); + hr = m_pDevice3->CreateRenderTargetView1(UnwrapResource(pResource), pRTVDesc, &ret); } else { @@ -549,14 +537,13 @@ HRESULT WrappedID3D11Device::CreateRenderTargetView1(ID3D11Resource *pResource, // validation, returns S_FALSE for valid params, or an error code if(ppRTView == NULL) - return m_pDevice3->CreateRenderTargetView1(GetResourceManager()->UnwrapResource(pResource), - pDesc, NULL); + return m_pDevice3->CreateRenderTargetView1(UnwrapResource(pResource), pDesc, NULL); ID3D11RenderTargetView1 *real = NULL; ID3D11RenderTargetView1 *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice3->CreateRenderTargetView1( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice3->CreateRenderTargetView1(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -574,11 +561,9 @@ HRESULT WrappedID3D11Device::CreateRenderTargetView1(ID3D11Resource *pResource, chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -588,19 +573,13 @@ HRESULT WrappedID3D11Device::CreateRenderTargetView1(ID3D11Resource *pResource, RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddParent(parent); record->AddChunk(chunk); } - else - { - RDCERR("Unexpected resource type in RTV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppRTView = wrapped; @@ -616,7 +595,7 @@ bool WrappedID3D11Device::Serialise_CreateUnorderedAccessView1( { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppUAView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppUAView)) .TypedAs("ID3D11UnorderedAccessView1 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -629,8 +608,7 @@ bool WrappedID3D11Device::Serialise_CreateUnorderedAccessView1( if(m_pDevice3) { - hr = m_pDevice3->CreateUnorderedAccessView1(GetResourceManager()->UnwrapResource(pResource), - pDesc, &ret); + hr = m_pDevice3->CreateUnorderedAccessView1(UnwrapResource(pResource), pDesc, &ret); } else { @@ -678,14 +656,13 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView1(ID3D11Resource *pResourc // validation, returns S_FALSE for valid params, or an error code if(ppUAView == NULL) - return m_pDevice3->CreateUnorderedAccessView1(GetResourceManager()->UnwrapResource(pResource), - pDesc, NULL); + return m_pDevice3->CreateUnorderedAccessView1(UnwrapResource(pResource), pDesc, NULL); ID3D11UnorderedAccessView1 *real = NULL; ID3D11UnorderedAccessView1 *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice3->CreateUnorderedAccessView1( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice3->CreateUnorderedAccessView1(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -703,11 +680,9 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView1(ID3D11Resource *pResourc chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -717,19 +692,13 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView1(ID3D11Resource *pResourc RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddParent(parent); record->AddChunk(chunk); } - else - { - RDCERR("Unexpected resource type in UAV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppUAView = wrapped; @@ -743,7 +712,7 @@ bool WrappedID3D11Device::Serialise_CreateRasterizerState2( ID3D11RasterizerState2 **ppRasterizerState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pRasterizerDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppRasterizerState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppRasterizerState)) .TypedAs("ID3D11RasterizerState2 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -835,7 +804,7 @@ HRESULT WrappedID3D11Device::CreateRasterizerState2(const D3D11_RASTERIZER_DESC2 RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -853,7 +822,7 @@ bool WrappedID3D11Device::Serialise_CreateQuery1(SerialiserType &ser, ID3D11Query1 **ppQuery) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pQueryDesc); - SERIALISE_ELEMENT_LOCAL(pQuery, GetIDForResource(*ppQuery)).TypedAs("ID3D11Query1 *"_lit); + SERIALISE_ELEMENT_LOCAL(pQuery, GetIDForDeviceChild(*ppQuery)).TypedAs("ID3D11Query1 *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -917,7 +886,7 @@ HRESULT WrappedID3D11Device::CreateQuery1(const D3D11_QUERY_DESC1 *pQueryDesc, I RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); diff --git a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp index e36ec5bfe..b9419bd71 100644 --- a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp @@ -36,7 +36,7 @@ bool WrappedID3D11Device::Serialise_CreateBuffer(SerialiserType &ser, const D3D1 SERIALISE_ELEMENT_LOCAL(Descriptor, *pDesc).Named("pDesc"_lit); // unused, just for the sake of the user SERIALISE_ELEMENT_OPT(pInitialData); - SERIALISE_ELEMENT_LOCAL(pBuffer, GetIDForResource(*ppBuffer)).TypedAs("ID3D11Buffer *"_lit); + SERIALISE_ELEMENT_LOCAL(pBuffer, GetIDForDeviceChild(*ppBuffer)).TypedAs("ID3D11Buffer *"_lit); D3D11_SUBRESOURCE_DATA fakeData; RDCEraseEl(fakeData); @@ -83,7 +83,6 @@ bool WrappedID3D11Device::Serialise_CreateBuffer(SerialiserType &ser, const D3D1 RDCASSERT(GetResourceManager()->GetResourceRecord(pBuffer) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(pBuffer); - record->ResType = Resource_Buffer; record->SetDataOffset(offs); record->DataInSerialiser = true; record->Length = Descriptor.ByteWidth; @@ -225,7 +224,7 @@ HRESULT WrappedID3D11Device::CreateBuffer(const D3D11_BUFFER_DESC *pDesc, } D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(wrapped)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(wrapped)); RDCASSERT(record); record->AddChunk(chunk); record->SetDataPtr(chunk->GetData()); @@ -283,7 +282,6 @@ rdcarray WrappedID3D11Device::Serialise_CreateTextureDat RDCASSERT(record == NULL); record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(tex); record->Length = 1; if(HasData) @@ -294,7 +292,6 @@ rdcarray WrappedID3D11Device::Serialise_CreateTextureDat for(UINT s = 0; s < numSubresources; s++) { record->SubResources[s] = new D3D11ResourceRecord(ResourceId()); - record->SubResources[s]->ResType = record->ResType; record->SubResources[s]->DataInSerialiser = HasData; } } @@ -382,7 +379,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture1D(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pInitialData, pInitialData ? numSubresources : 0); } - SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture1D)) + SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForDeviceChild(*ppTexture1D)) .TypedAs("ID3D11Texture1D *"_lit); rdcarray descs = Serialise_CreateTextureData( @@ -480,7 +477,7 @@ HRESULT WrappedID3D11Device::CreateTexture1D(const D3D11_TEXTURE1D_DESC *pDesc, } D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(wrapped)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(wrapped)); RDCASSERT(record); record->AddChunk(chunk); @@ -517,7 +514,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture2D(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pInitialData, pInitialData ? numSubresources : 0); } - SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture2D)) + SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForDeviceChild(*ppTexture2D)) .TypedAs("ID3D11Texture2D *"_lit); rdcarray descs = @@ -616,7 +613,7 @@ HRESULT WrappedID3D11Device::CreateTexture2D(const D3D11_TEXTURE2D_DESC *pDesc, } D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(wrapped)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(wrapped)); RDCASSERT(record); record->AddChunk(chunk); @@ -652,7 +649,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture3D(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pInitialData, pInitialData ? numSubresources : 0); } - SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture3D)) + SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForDeviceChild(*ppTexture3D)) .TypedAs("ID3D11Texture3D *"_lit); rdcarray descs = @@ -751,7 +748,7 @@ HRESULT WrappedID3D11Device::CreateTexture3D(const D3D11_TEXTURE3D_DESC *pDesc, } D3D11ResourceRecord *record = - GetResourceManager()->GetResourceRecord(GetIDForResource(wrapped)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(wrapped)); RDCASSERT(record); record->AddChunk(chunk); @@ -777,7 +774,7 @@ bool WrappedID3D11Device::Serialise_CreateShaderResourceView( { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppSRView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppSRView)) .TypedAs("ID3D11ShaderResourceView *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -823,8 +820,7 @@ bool WrappedID3D11Device::Serialise_CreateShaderResourceView( if(pSRVDesc) APIProps.YUVTextures |= IsYUVFormat(pSRVDesc->Format); - HRESULT hr = m_pDevice->CreateShaderResourceView( - GetResourceManager()->UnwrapResource(pResource), pSRVDesc, &ret); + HRESULT hr = m_pDevice->CreateShaderResourceView(UnwrapResource(pResource), pSRVDesc, &ret); if(FAILED(hr)) { @@ -851,14 +847,13 @@ HRESULT WrappedID3D11Device::CreateShaderResourceView(ID3D11Resource *pResource, { // validation, returns S_FALSE for valid params, or an error code if(ppSRView == NULL) - return m_pDevice->CreateShaderResourceView(GetResourceManager()->UnwrapResource(pResource), - pDesc, NULL); + return m_pDevice->CreateShaderResourceView(UnwrapResource(pResource), pDesc, NULL); ID3D11ShaderResourceView *real = NULL; ID3D11ShaderResourceView *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice->CreateShaderResourceView( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice->CreateShaderResourceView(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -877,11 +872,9 @@ HRESULT WrappedID3D11Device::CreateShaderResourceView(ID3D11Resource *pResource, chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -891,19 +884,12 @@ HRESULT WrappedID3D11Device::CreateShaderResourceView(ID3D11Resource *pResource, RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); record->Length = 0; record->AddParent(parent); record->AddChunk(chunk); } - else - { - RDCERR("Unexpected resource type in SRV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppSRView = wrapped; @@ -919,7 +905,7 @@ bool WrappedID3D11Device::Serialise_CreateUnorderedAccessView( { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppUAView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppUAView)) .TypedAs("ID3D11UnorderedAccessView *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -957,8 +943,7 @@ bool WrappedID3D11Device::Serialise_CreateUnorderedAccessView( pUAVDesc->Format = tex2d->m_RealDescriptor->Format; } - HRESULT hr = m_pDevice->CreateUnorderedAccessView( - GetResourceManager()->UnwrapResource(pResource), pUAVDesc, &ret); + HRESULT hr = m_pDevice->CreateUnorderedAccessView(UnwrapResource(pResource), pUAVDesc, &ret); if(FAILED(hr)) { @@ -998,14 +983,13 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView(ID3D11Resource *pResource { // validation, returns S_FALSE for valid params, or an error code if(ppUAView == NULL) - return m_pDevice->CreateUnorderedAccessView(GetResourceManager()->UnwrapResource(pResource), - pDesc, NULL); + return m_pDevice->CreateUnorderedAccessView(UnwrapResource(pResource), pDesc, NULL); ID3D11UnorderedAccessView *real = NULL; ID3D11UnorderedAccessView *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice->CreateUnorderedAccessView( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice->CreateUnorderedAccessView(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -1024,11 +1008,9 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView(ID3D11Resource *pResource chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -1038,7 +1020,7 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView(ID3D11Resource *pResource RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddParent(parent); @@ -1053,12 +1035,6 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView(ID3D11Resource *pResource GetResourceManager()->MarkDirtyResource(id); } } - else - { - RDCERR("Unexpected resource type in UAV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppUAView = wrapped; @@ -1074,7 +1050,7 @@ bool WrappedID3D11Device::Serialise_CreateRenderTargetView(SerialiserType &ser, { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppRTView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppRTView)) .TypedAs("ID3D11RenderTargetView *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1113,8 +1089,7 @@ bool WrappedID3D11Device::Serialise_CreateRenderTargetView(SerialiserType &ser, pRTVDesc->Format = tex2d->m_RealDescriptor->Format; } - HRESULT hr = m_pDevice->CreateRenderTargetView(GetResourceManager()->UnwrapResource(pResource), - pRTVDesc, &ret); + HRESULT hr = m_pDevice->CreateRenderTargetView(UnwrapResource(pResource), pRTVDesc, &ret); if(FAILED(hr)) { @@ -1141,14 +1116,13 @@ HRESULT WrappedID3D11Device::CreateRenderTargetView(ID3D11Resource *pResource, { // validation, returns S_FALSE for valid params, or an error code if(ppRTView == NULL) - return m_pDevice->CreateRenderTargetView(GetResourceManager()->UnwrapResource(pResource), pDesc, - NULL); + return m_pDevice->CreateRenderTargetView(UnwrapResource(pResource), pDesc, NULL); ID3D11RenderTargetView *real = NULL; ID3D11RenderTargetView *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice->CreateRenderTargetView( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice->CreateRenderTargetView(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -1167,11 +1141,9 @@ HRESULT WrappedID3D11Device::CreateRenderTargetView(ID3D11Resource *pResource, chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -1181,19 +1153,13 @@ HRESULT WrappedID3D11Device::CreateRenderTargetView(ID3D11Resource *pResource, RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddParent(parent); record->AddChunk(chunk); } - else - { - RDCERR("Unexpected resource type in RTV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppRTView = wrapped; @@ -1209,7 +1175,7 @@ bool WrappedID3D11Device::Serialise_CreateDepthStencilView( { SERIALISE_ELEMENT(pResource); SERIALISE_ELEMENT_OPT(pDesc); - SERIALISE_ELEMENT_LOCAL(pView, GetIDForResource(*ppDepthStencilView)) + SERIALISE_ELEMENT_LOCAL(pView, GetIDForDeviceChild(*ppDepthStencilView)) .TypedAs("ID3D11DepthStencilView *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1218,8 +1184,7 @@ bool WrappedID3D11Device::Serialise_CreateDepthStencilView( { ID3D11DepthStencilView *ret; - HRESULT hr = m_pDevice->CreateDepthStencilView(GetResourceManager()->UnwrapResource(pResource), - pDesc, &ret); + HRESULT hr = m_pDevice->CreateDepthStencilView(UnwrapResource(pResource), pDesc, &ret); if(FAILED(hr)) { @@ -1246,14 +1211,13 @@ HRESULT WrappedID3D11Device::CreateDepthStencilView(ID3D11Resource *pResource, { // validation, returns S_FALSE for valid params, or an error code if(ppDepthStencilView == NULL) - return m_pDevice->CreateDepthStencilView(GetResourceManager()->UnwrapResource(pResource), pDesc, - NULL); + return m_pDevice->CreateDepthStencilView(UnwrapResource(pResource), pDesc, NULL); ID3D11DepthStencilView *real = NULL; ID3D11DepthStencilView *wrapped = NULL; HRESULT ret; - SERIALISE_TIME_CALL(ret = m_pDevice->CreateDepthStencilView( - GetResourceManager()->UnwrapResource(pResource), pDesc, &real)); + SERIALISE_TIME_CALL( + ret = m_pDevice->CreateDepthStencilView(UnwrapResource(pResource), pDesc, &real)); if(SUCCEEDED(ret)) { @@ -1272,11 +1236,9 @@ HRESULT WrappedID3D11Device::CreateDepthStencilView(ID3D11Resource *pResource, chunk = scope.Get(); - if(WrappedID3D11Texture1D::IsAlloc(pResource) || WrappedID3D11Texture2D1::IsAlloc(pResource) || - WrappedID3D11Texture3D1::IsAlloc(pResource) || WrappedID3D11Buffer::IsAlloc(pResource)) { D3D11ResourceRecord *parent = - GetResourceManager()->GetResourceRecord(GetIDForResource(pResource)); + GetResourceManager()->GetResourceRecord(GetIDForDeviceChild(pResource)); RDCASSERT(parent); @@ -1286,19 +1248,13 @@ HRESULT WrappedID3D11Device::CreateDepthStencilView(ID3D11Resource *pResource, RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddParent(parent); record->AddChunk(chunk); } - else - { - RDCERR("Unexpected resource type in DSV creation"); - - m_DeviceRecord->AddChunk(chunk); - } } *ppDepthStencilView = wrapped; @@ -1317,7 +1273,7 @@ bool WrappedID3D11Device::Serialise_CreateInputLayout( SERIALISE_ELEMENT(NumElements); SERIALISE_ELEMENT_ARRAY(pShaderBytecodeWithInputSignature, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); - SERIALISE_ELEMENT_LOCAL(pInputLayout, GetIDForResource(*ppInputLayout)) + SERIALISE_ELEMENT_LOCAL(pInputLayout, GetIDForDeviceChild(*ppInputLayout)) .TypedAs("ID3D11InputLayout *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1351,7 +1307,7 @@ bool WrappedID3D11Device::Serialise_CreateInputLayout( m_LayoutDescs[ret] = rdcarray(pInputElementDescs, NumElements); if(BytecodeLength > 0 && pShaderBytecodeWithInputSignature) - m_LayoutShaders[ret] = new WrappedShader(this, pInputLayout, GetIDForResource(ret), + m_LayoutShaders[ret] = new WrappedShader(this, pInputLayout, GetIDForDeviceChild(ret), (const byte *)pShaderBytecodeWithInputSignature, (size_t)BytecodeLength); } @@ -1397,7 +1353,7 @@ HRESULT WrappedID3D11Device::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *p RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -1419,7 +1375,7 @@ bool WrappedID3D11Device::Serialise_CreateVertexShader(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pShaderBytecode, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppVertexShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppVertexShader)) .TypedAs("ID3D11VertexShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1488,7 +1444,7 @@ HRESULT WrappedID3D11Device::CreateVertexShader(const void *pShaderBytecode, SIZ RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -1516,7 +1472,7 @@ bool WrappedID3D11Device::Serialise_CreateGeometryShader(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pShaderBytecode, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppGeometryShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppGeometryShader)) .TypedAs("ID3D11GeometryShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1585,7 +1541,7 @@ HRESULT WrappedID3D11Device::CreateGeometryShader(const void *pShaderBytecode, S RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -1619,7 +1575,7 @@ bool WrappedID3D11Device::Serialise_CreateGeometryShaderWithStreamOutput( SERIALISE_ELEMENT(NumStrides); SERIALISE_ELEMENT(RasterizedStream); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppGeometryShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppGeometryShader)) .TypedAs("ID3D11GeometryShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1693,7 +1649,7 @@ HRESULT WrappedID3D11Device::CreateGeometryShaderWithStreamOutput( RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -1722,7 +1678,7 @@ bool WrappedID3D11Device::Serialise_CreatePixelShader(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pShaderBytecode, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppPixelShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppPixelShader)) .TypedAs("ID3D11PixelShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1789,7 +1745,7 @@ HRESULT WrappedID3D11Device::CreatePixelShader(const void *pShaderBytecode, SIZE RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -1816,7 +1772,7 @@ bool WrappedID3D11Device::Serialise_CreateHullShader(SerialiserType &ser, const SERIALISE_ELEMENT_ARRAY(pShaderBytecode, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppHullShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppHullShader)) .TypedAs("ID3D11HullShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1883,7 +1839,7 @@ HRESULT WrappedID3D11Device::CreateHullShader(const void *pShaderBytecode, SIZE_ RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -1911,7 +1867,7 @@ bool WrappedID3D11Device::Serialise_CreateDomainShader(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pShaderBytecode, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppDomainShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppDomainShader)) .TypedAs("ID3D11DomainShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -1980,7 +1936,7 @@ HRESULT WrappedID3D11Device::CreateDomainShader(const void *pShaderBytecode, SIZ RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2008,7 +1964,7 @@ bool WrappedID3D11Device::Serialise_CreateComputeShader(SerialiserType &ser, SERIALISE_ELEMENT_ARRAY(pShaderBytecode, BytecodeLength_); SERIALISE_ELEMENT_LOCAL(BytecodeLength, uint64_t(BytecodeLength_)); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pShader, GetIDForResource(*ppComputeShader)) + SERIALISE_ELEMENT_LOCAL(pShader, GetIDForDeviceChild(*ppComputeShader)) .TypedAs("ID3D11ComputeShader *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2077,7 +2033,7 @@ HRESULT WrappedID3D11Device::CreateComputeShader(const void *pShaderBytecode, SI RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2111,7 +2067,7 @@ bool WrappedID3D11Device::Serialise_CreateClassInstance(SerialiserType &ser, LPC SERIALISE_ELEMENT(TextureOffset); SERIALISE_ELEMENT(SamplerOffset); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pInstance, GetIDForResource(*ppInstance)) + SERIALISE_ELEMENT_LOCAL(pInstance, GetIDForDeviceChild(*ppInstance)) .TypedAs("ID3D11ClassInstance *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2185,7 +2141,7 @@ bool WrappedID3D11Device::Serialise_GetClassInstance(SerialiserType &ser, LPCSTR SERIALISE_ELEMENT(pClassInstanceName); SERIALISE_ELEMENT(InstanceIndex); SERIALISE_ELEMENT(pClassLinkage); - SERIALISE_ELEMENT_LOCAL(pInstance, GetIDForResource(*ppInstance)) + SERIALISE_ELEMENT_LOCAL(pInstance, GetIDForDeviceChild(*ppInstance)) .TypedAs("ID3D11ClassInstance *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2253,7 +2209,7 @@ template bool WrappedID3D11Device::Serialise_CreateClassLinkage(SerialiserType &ser, ID3D11ClassLinkage **ppLinkage) { - SERIALISE_ELEMENT_LOCAL(pLinkage, GetIDForResource(*ppLinkage)) + SERIALISE_ELEMENT_LOCAL(pLinkage, GetIDForDeviceChild(*ppLinkage)) .TypedAs("ID3D11ClassLinkage *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2319,7 +2275,7 @@ bool WrappedID3D11Device::Serialise_CreateBlendState(SerialiserType &ser, ID3D11BlendState **ppBlendState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pBlendStateDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppBlendState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppBlendState)) .TypedAs("ID3D11BlendState *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2407,7 +2363,7 @@ HRESULT WrappedID3D11Device::CreateBlendState(const D3D11_BLEND_DESC *pBlendStat RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2425,7 +2381,7 @@ bool WrappedID3D11Device::Serialise_CreateDepthStencilState( ID3D11DepthStencilState **ppDepthStencilState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pDepthStencilDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppDepthStencilState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppDepthStencilState)) .TypedAs("ID3D11DepthStencilState *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2511,7 +2467,7 @@ HRESULT WrappedID3D11Device::CreateDepthStencilState(const D3D11_DEPTH_STENCIL_D RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2529,7 +2485,7 @@ bool WrappedID3D11Device::Serialise_CreateRasterizerState(SerialiserType &ser, ID3D11RasterizerState **ppRasterizerState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pRasterizerDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppRasterizerState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppRasterizerState)) .TypedAs("ID3D11RasterizerState *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2615,7 +2571,7 @@ HRESULT WrappedID3D11Device::CreateRasterizerState(const D3D11_RASTERIZER_DESC * RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2633,7 +2589,7 @@ bool WrappedID3D11Device::Serialise_CreateSamplerState(SerialiserType &ser, ID3D11SamplerState **ppSamplerState) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pSamplerDesc); - SERIALISE_ELEMENT_LOCAL(pState, GetIDForResource(*ppSamplerState)) + SERIALISE_ELEMENT_LOCAL(pState, GetIDForDeviceChild(*ppSamplerState)) .TypedAs("ID3D11SamplerState *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2719,7 +2675,7 @@ HRESULT WrappedID3D11Device::CreateSamplerState(const D3D11_SAMPLER_DESC *pSampl RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2737,7 +2693,7 @@ bool WrappedID3D11Device::Serialise_CreateQuery(SerialiserType &ser, ID3D11Query **ppQuery) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pQueryDesc); - SERIALISE_ELEMENT_LOCAL(pQuery, GetIDForResource(*ppQuery)).TypedAs("ID3D11Query *"_lit); + SERIALISE_ELEMENT_LOCAL(pQuery, GetIDForDeviceChild(*ppQuery)).TypedAs("ID3D11Query *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2794,7 +2750,7 @@ HRESULT WrappedID3D11Device::CreateQuery(const D3D11_QUERY_DESC *pQueryDesc, ID3 RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2812,7 +2768,7 @@ bool WrappedID3D11Device::Serialise_CreatePredicate(SerialiserType &ser, ID3D11Predicate **ppPredicate) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pPredicateDesc); - SERIALISE_ELEMENT_LOCAL(pPredicate, GetIDForResource(*ppPredicate)) + SERIALISE_ELEMENT_LOCAL(pPredicate, GetIDForDeviceChild(*ppPredicate)) .TypedAs("ID3D11Predicate *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2881,7 +2837,7 @@ HRESULT WrappedID3D11Device::CreatePredicate(const D3D11_QUERY_DESC *pPredicateD RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -2899,7 +2855,7 @@ bool WrappedID3D11Device::Serialise_CreateCounter(SerialiserType &ser, ID3D11Counter **ppCounter) { SERIALISE_ELEMENT_LOCAL(Descriptor, *pCounterDesc); - SERIALISE_ELEMENT_LOCAL(pCounter, GetIDForResource(*ppCounter)).TypedAs("ID3D11Counter *"_lit); + SERIALISE_ELEMENT_LOCAL(pCounter, GetIDForDeviceChild(*ppCounter)).TypedAs("ID3D11Counter *"_lit); SERIALISE_CHECK_READ_ERRORS(); @@ -2963,7 +2919,7 @@ HRESULT WrappedID3D11Device::CreateCounter(const D3D11_COUNTER_DESC *pCounterDes RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - record->ResType = IdentifyTypeByPtr(wrapped); + record->Length = 0; record->AddChunk(scope.Get()); @@ -3061,7 +3017,7 @@ bool WrappedID3D11Device::Serialise_OpenSharedResource(SerialiserType &ser, HAND ID3D11DeviceChild *res = ser.IsWriting() ? (ID3D11DeviceChild *)*ppResource : NULL; SERIALISE_ELEMENT_LOCAL(Type, IdentifyTypeByPtr(res)); - SERIALISE_ELEMENT_LOCAL(pResource, GetIDForResource(res)).TypedAs("ID3D11DeviceChild *"_lit); + SERIALISE_ELEMENT_LOCAL(pResource, GetIDForDeviceChild(res)).TypedAs("ID3D11DeviceChild *"_lit); if(Type == Resource_Buffer) { @@ -3093,7 +3049,6 @@ bool WrappedID3D11Device::Serialise_OpenSharedResource(SerialiserType &ser, HAND RDCASSERT(GetResourceManager()->GetResourceRecord(pResource) == NULL); D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(pResource); - record->ResType = Type; record->SetDataOffset(offs); record->DataInSerialiser = true; record->Length = Descriptor.ByteWidth; diff --git a/renderdoc/driver/d3d11/d3d11_initstate.cpp b/renderdoc/driver/d3d11/d3d11_initstate.cpp index efc1c71fd..1cfcd3875 100644 --- a/renderdoc/driver/d3d11/d3d11_initstate.cpp +++ b/renderdoc/driver/d3d11/d3d11_initstate.cpp @@ -30,7 +30,7 @@ bool WrappedID3D11Device::Prepare_InitialState(ID3D11DeviceChild *res) { D3D11ResourceType type = IdentifyTypeByPtr(res); - ResourceId Id = GetIDForResource(res); + ResourceId Id = GetIDForDeviceChild(res); RDCASSERT(IsCaptureMode(m_State)); @@ -381,7 +381,7 @@ bool WrappedID3D11Device::Serialise_InitialState(SerialiserType &ser, ResourceId D3D11ResourceType type = Resource_Unknown; if(IsCaptureMode(m_State)) - type = record->ResType; + type = initial->resourceType; bool ret = true; @@ -1303,7 +1303,7 @@ void WrappedID3D11Device::Apply_InitialState(ID3D11DeviceChild *live, } else if(initial.tag == D3D11InitialContents::Copy) { - ID3D11Resource *liveResource = (ID3D11Resource *)m_ResourceManager->UnwrapResource(live); + ID3D11Resource *liveResource = (ID3D11Resource *)UnwrapResource(live); ID3D11Resource *initialResource = (ID3D11Resource *)initial.resource; m_pImmediateContext->GetReal()->CopyResource(liveResource, initialResource); diff --git a/renderdoc/driver/d3d11/d3d11_manager.cpp b/renderdoc/driver/d3d11/d3d11_manager.cpp index 05caf415f..1c9793e07 100644 --- a/renderdoc/driver/d3d11/d3d11_manager.cpp +++ b/renderdoc/driver/d3d11/d3d11_manager.cpp @@ -31,29 +31,11 @@ byte D3D11ResourceRecord::ShadowPointerData::markerValue[32] = { 0xaa, 0xbb, 0xcc, 0xdd, 0x88, 0x77, 0x66, 0x55, 0x01, 0x23, 0x45, 0x67, 0x98, 0x76, 0x54, 0x32, }; -ID3D11DeviceChild *D3D11ResourceManager::UnwrapResource(ID3D11DeviceChild *res) -{ - if(res == NULL) - return res; - - if(WrappedID3D11Buffer::IsAlloc(res)) - return UNWRAP(WrappedID3D11Buffer, res); - else if(WrappedID3D11Texture1D::IsAlloc(res)) - return UNWRAP(WrappedID3D11Texture1D, res); - else if(WrappedID3D11Texture2D1::IsAlloc(res)) - return UNWRAP(WrappedID3D11Texture2D1, res); - else if(WrappedID3D11Texture3D1::IsAlloc(res)) - return UNWRAP(WrappedID3D11Texture3D1, res); - - RDCERR("UnwrapResource(): Unexpected non-wrapped resource"); - return res; -} - void D3D11ResourceManager::SetInternalResource(ID3D11DeviceChild *res) { if(res && !RenderDoc::Inst().IsReplayApp()) { - D3D11ResourceRecord *record = GetResourceRecord(GetIDForResource(res)); + D3D11ResourceRecord *record = GetResourceRecord(GetIDForDeviceChild(res)); if(record) record->InternalResource = true; } @@ -74,7 +56,7 @@ void D3D11ResourceManager::FreeCaptureData() ResourceId D3D11ResourceManager::GetID(ID3D11DeviceChild *res) { - return GetIDForResource(res); + return GetIDForDeviceChild(res); } bool D3D11ResourceManager::ResourceTypeRelease(ID3D11DeviceChild *res) diff --git a/renderdoc/driver/d3d11/d3d11_manager.h b/renderdoc/driver/d3d11/d3d11_manager.h index bc4b2dd6f..c94c4dab8 100644 --- a/renderdoc/driver/d3d11/d3d11_manager.h +++ b/renderdoc/driver/d3d11/d3d11_manager.h @@ -70,7 +70,7 @@ struct D3D11ResourceRecord : public ResourceRecord }; D3D11ResourceRecord(ResourceId id) - : ResourceRecord(id, true), ResType(Resource_Unknown), NumSubResources(0), SubResources(NULL) + : ResourceRecord(id, true), NumSubResources(0), SubResources(NULL) { RDCEraseEl(ImmediateShadow); } @@ -194,7 +194,6 @@ struct D3D11ResourceRecord : public ResourceRecord } } - D3D11ResourceType ResType; int NumSubResources; D3D11ResourceRecord **SubResources; @@ -308,11 +307,6 @@ public: : ResourceManager(state), m_Device(dev) { } - ID3D11DeviceChild *UnwrapResource(ID3D11DeviceChild *res); - ID3D11Resource *UnwrapResource(ID3D11Resource *res) - { - return (ID3D11Resource *)UnwrapResource((ID3D11DeviceChild *)res); - } void SetInternalResource(ID3D11DeviceChild *res); void FreeCaptureData(); @@ -333,10 +327,12 @@ private: WrappedID3D11Device *m_Device; }; +#define WRAPPING_DEBUG OPTION_OFF + template typename Dest::InnerType *Unwrap(typename Dest::InnerType *obj) { -#if ENABLED(RDOC_DEVEL) +#if ENABLED(WRAPPING_DEBUG) if(obj && !Dest::IsAlloc(obj)) { RDCERR("Trying to unwrap invalid type"); diff --git a/renderdoc/driver/d3d11/d3d11_renderstate.cpp b/renderdoc/driver/d3d11/d3d11_renderstate.cpp index 46e50bf39..328a5ca33 100644 --- a/renderdoc/driver/d3d11/d3d11_renderstate.cpp +++ b/renderdoc/driver/d3d11/d3d11_renderstate.cpp @@ -165,13 +165,14 @@ void D3D11RenderState::ReleaseRefs() void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool initial) const { - ctx->MarkResourceReferenced(GetIDForResource(IA.Layout), initial ? eFrameRef_None : eFrameRef_Read); + ctx->MarkResourceReferenced(GetIDForDeviceChild(IA.Layout), + initial ? eFrameRef_None : eFrameRef_Read); - ctx->MarkResourceReferenced(GetIDForResource(IA.IndexBuffer), + ctx->MarkResourceReferenced(GetIDForDeviceChild(IA.IndexBuffer), initial ? eFrameRef_None : eFrameRef_Read); for(UINT i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) - ctx->MarkResourceReferenced(GetIDForResource(IA.VBs[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(IA.VBs[i]), initial ? eFrameRef_None : eFrameRef_Read); const Shader *stages[] = {&VS, &HS, &DS, &GS, &PS, &CS}; @@ -179,22 +180,22 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init { const Shader *sh = stages[s]; - ctx->MarkResourceReferenced(GetIDForResource(sh->Object), + ctx->MarkResourceReferenced(GetIDForDeviceChild(sh->Object), initial ? eFrameRef_None : eFrameRef_Read); for(UINT i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++) - ctx->MarkResourceReferenced(GetIDForResource(sh->ConstantBuffers[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(sh->ConstantBuffers[i]), initial ? eFrameRef_None : eFrameRef_Read); for(UINT i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; i++) - ctx->MarkResourceReferenced(GetIDForResource(sh->Samplers[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(sh->Samplers[i]), initial ? eFrameRef_None : eFrameRef_Read); for(UINT i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; i++) { if(sh->SRVs[i]) { - ctx->MarkResourceReferenced(GetIDForResource(sh->SRVs[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(sh->SRVs[i]), initial ? eFrameRef_None : eFrameRef_Read); ctx->MarkResourceReferenced(GetViewResourceResID(sh->SRVs[i]), initial ? eFrameRef_None : eFrameRef_Read); @@ -209,9 +210,9 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init if(CSUAVs[i]) { // UAVs we always assume to be partial updates - ctx->MarkResourceReferenced(GetIDForResource(CSUAVs[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(CSUAVs[i]), initial ? eFrameRef_None : eFrameRef_Read); - ctx->MarkResourceReferenced(GetIDForResource(CSUAVs[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(CSUAVs[i]), initial ? eFrameRef_None : eFrameRef_PartialWrite); ctx->MarkResourceReferenced(GetViewResourceResID(CSUAVs[i]), initial ? eFrameRef_None : eFrameRef_Read); @@ -221,22 +222,23 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init } for(UINT i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) - ctx->MarkResourceReferenced(GetIDForResource(SO.Buffers[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(SO.Buffers[i]), initial ? eFrameRef_None : eFrameRef_PartialWrite); - ctx->MarkResourceReferenced(GetIDForResource(RS.State), initial ? eFrameRef_None : eFrameRef_Read); - - ctx->MarkResourceReferenced(GetIDForResource(OM.BlendState), + ctx->MarkResourceReferenced(GetIDForDeviceChild(RS.State), initial ? eFrameRef_None : eFrameRef_Read); - ctx->MarkResourceReferenced(GetIDForResource(OM.DepthStencilState), + ctx->MarkResourceReferenced(GetIDForDeviceChild(OM.BlendState), + initial ? eFrameRef_None : eFrameRef_Read); + + ctx->MarkResourceReferenced(GetIDForDeviceChild(OM.DepthStencilState), initial ? eFrameRef_None : eFrameRef_Read); for(UINT i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) { if(OM.RenderTargets[i]) { - ctx->MarkResourceReferenced(GetIDForResource(OM.RenderTargets[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(OM.RenderTargets[i]), initial ? eFrameRef_None : eFrameRef_Read); ctx->MarkResourceReferenced(GetViewResourceResID(OM.RenderTargets[i]), initial ? eFrameRef_None : eFrameRef_PartialWrite); @@ -248,9 +250,9 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init if(OM.UAVs[i]) { // UAVs we always assume to be partial updates - ctx->MarkResourceReferenced(GetIDForResource(OM.UAVs[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(OM.UAVs[i]), initial ? eFrameRef_None : eFrameRef_Read); - ctx->MarkResourceReferenced(GetIDForResource(OM.UAVs[i]), + ctx->MarkResourceReferenced(GetIDForDeviceChild(OM.UAVs[i]), initial ? eFrameRef_None : eFrameRef_PartialWrite); ctx->MarkResourceReferenced(GetViewResourceResID(OM.UAVs[i]), initial ? eFrameRef_None : eFrameRef_Read); @@ -261,7 +263,7 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init if(OM.DepthView) { - ctx->MarkResourceReferenced(GetIDForResource(OM.DepthView), + ctx->MarkResourceReferenced(GetIDForDeviceChild(OM.DepthView), initial ? eFrameRef_None : eFrameRef_Read); ctx->MarkResourceReferenced(GetViewResourceResID(OM.DepthView), initial ? eFrameRef_None : eFrameRef_PartialWrite); @@ -269,7 +271,7 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init if(Predicate) { - ctx->MarkResourceReferenced(GetIDForResource(Predicate), + ctx->MarkResourceReferenced(GetIDForDeviceChild(Predicate), initial ? eFrameRef_None : eFrameRef_Read); } } diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index 0b8528971..0537d8493 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -704,7 +704,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { const rdcarray &vec = m_pDevice->GetLayoutDesc(rs->IA.Layout); - ResourceId layoutId = GetIDForResource(rs->IA.Layout); + ResourceId layoutId = GetIDForDeviceChild(rs->IA.Layout); ret.inputAssembly.resourceId = rm->GetOriginalID(layoutId); ret.inputAssembly.bytecode = GetShader(ResourceId(), layoutId, ShaderEntryPoint()); @@ -729,12 +729,13 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::VertexBuffer &vb = ret.inputAssembly.vertexBuffers[i]; - vb.resourceId = rm->GetOriginalID(GetIDForResource(rs->IA.VBs[i])); + vb.resourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->IA.VBs[i])); vb.byteOffset = rs->IA.Offsets[i]; vb.byteStride = rs->IA.Strides[i]; } - ret.inputAssembly.indexBuffer.resourceId = rm->GetOriginalID(GetIDForResource(rs->IA.IndexBuffer)); + ret.inputAssembly.indexBuffer.resourceId = + rm->GetOriginalID(GetIDForDeviceChild(rs->IA.IndexBuffer)); ret.inputAssembly.indexBuffer.byteOffset = rs->IA.IndexOffset; ///////////////////////////////////////////////// @@ -754,7 +755,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) dst.stage = (ShaderStage)stage; - ResourceId id = GetIDForResource(src.Object); + ResourceId id = GetIDForDeviceChild(src.Object); WrappedShader *shad = (WrappedShader *)(WrappedID3D11Shader *)src.Object; @@ -777,7 +778,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) for(size_t s = 0; s < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; s++) { dst.constantBuffers[s].resourceId = - rm->GetOriginalID(GetIDForResource(src.ConstantBuffers[s])); + rm->GetOriginalID(GetIDForDeviceChild(src.ConstantBuffers[s])); dst.constantBuffers[s].vecOffset = src.CBOffsets[s]; dst.constantBuffers[s].vecCount = src.CBCounts[s]; } @@ -787,7 +788,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::Sampler &samp = dst.samplers[s]; - samp.resourceId = rm->GetOriginalID(GetIDForResource(src.Samplers[s])); + samp.resourceId = rm->GetOriginalID(GetIDForDeviceChild(src.Samplers[s])); if(samp.resourceId != ResourceId()) { @@ -816,7 +817,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::View &view = dst.srvs[s]; - view.viewResourceId = rm->GetOriginalID(GetIDForResource(src.SRVs[s])); + view.viewResourceId = rm->GetOriginalID(GetIDForDeviceChild(src.SRVs[s])); if(view.viewResourceId != ResourceId()) { @@ -834,7 +835,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) view.elementByteSize = desc.Format == DXGI_FORMAT_UNKNOWN ? 1 : GetByteSize(1, 1, 1, desc.Format, 0); - view.resourceResourceId = rm->GetOriginalID(GetIDForResource(res)); + view.resourceResourceId = rm->GetOriginalID(GetIDForDeviceChild(res)); view.type = MakeTextureDim(desc.ViewDimension); @@ -942,7 +943,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::View &view = dst.uavs[s]; - view.viewResourceId = rm->GetOriginalID(GetIDForResource(rs->CSUAVs[s])); + view.viewResourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->CSUAVs[s])); if(view.viewResourceId != ResourceId()) { @@ -968,7 +969,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) view.counterResourceId = GetDebugManager()->GetCounterBufferID(rs->CSUAVs[s]); } - view.resourceResourceId = rm->GetOriginalID(GetIDForResource(res)); + view.resourceResourceId = rm->GetOriginalID(GetIDForDeviceChild(res)); view.viewFormat = MakeResourceFormat(desc.Format); view.type = MakeTextureDim(desc.ViewDimension); @@ -1054,7 +1055,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) ret.streamOut.outputs.resize(D3D11_SO_BUFFER_SLOT_COUNT); for(size_t s = 0; s < D3D11_SO_BUFFER_SLOT_COUNT; s++) { - ret.streamOut.outputs[s].resourceId = rm->GetOriginalID(GetIDForResource(rs->SO.Buffers[s])); + ret.streamOut.outputs[s].resourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->SO.Buffers[s])); ret.streamOut.outputs[s].byteOffset = rs->SO.Offsets[s]; } } @@ -1115,7 +1116,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) : ConservativeRaster::Disabled; } - ret.rasterizer.state.resourceId = rm->GetOriginalID(GetIDForResource(rs->RS.State)); + ret.rasterizer.state.resourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->RS.State)); } else { @@ -1164,7 +1165,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::View &view = ret.outputMerger.renderTargets[i]; - view.viewResourceId = rm->GetOriginalID(GetIDForResource(rs->OM.RenderTargets[i])); + view.viewResourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->OM.RenderTargets[i])); if(view.viewResourceId != ResourceId()) { @@ -1179,7 +1180,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) view.elementByteSize = desc.Format == DXGI_FORMAT_UNKNOWN ? 1 : GetByteSize(1, 1, 1, desc.Format, 0); - view.resourceResourceId = rm->GetOriginalID(GetIDForResource(res)); + view.resourceResourceId = rm->GetOriginalID(GetIDForDeviceChild(res)); view.viewFormat = MakeResourceFormat(desc.Format); view.type = MakeTextureDim(desc.ViewDimension); @@ -1241,7 +1242,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::View view; - view.viewResourceId = rm->GetOriginalID(GetIDForResource(rs->OM.UAVs[s])); + view.viewResourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->OM.UAVs[s])); if(view.viewResourceId != ResourceId()) { @@ -1264,7 +1265,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) view.counterResourceId = GetDebugManager()->GetCounterBufferID(rs->OM.UAVs[s]); } - view.resourceResourceId = rm->GetOriginalID(GetIDForResource(res)); + view.resourceResourceId = rm->GetOriginalID(GetIDForDeviceChild(res)); view.viewFormat = MakeResourceFormat(desc.Format); view.type = MakeTextureDim(desc.ViewDimension); @@ -1328,7 +1329,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) { D3D11Pipe::View &view = ret.outputMerger.depthTarget; - view.viewResourceId = rm->GetOriginalID(GetIDForResource(rs->OM.DepthView)); + view.viewResourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->OM.DepthView)); if(view.viewResourceId != ResourceId()) { @@ -1351,7 +1352,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) if(desc.Flags & D3D11_DSV_READ_ONLY_STENCIL) ret.outputMerger.stencilReadOnly = true; - view.resourceResourceId = rm->GetOriginalID(GetIDForResource(res)); + view.resourceResourceId = rm->GetOriginalID(GetIDForDeviceChild(res)); view.viewFormat = MakeResourceFormat(desc.Format); view.type = MakeTextureDim(desc.ViewDimension); @@ -1403,7 +1404,8 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) D3D11_BLEND_DESC desc; rs->OM.BlendState->GetDesc(&desc); - ret.outputMerger.blendState.resourceId = rm->GetOriginalID(GetIDForResource(rs->OM.BlendState)); + ret.outputMerger.blendState.resourceId = + rm->GetOriginalID(GetIDForDeviceChild(rs->OM.BlendState)); ret.outputMerger.blendState.alphaToCoverage = desc.AlphaToCoverageEnable == TRUE; ret.outputMerger.blendState.independentBlend = desc.IndependentBlendEnable == TRUE; @@ -1481,7 +1483,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) desc.DepthWriteMask == D3D11_DEPTH_WRITE_MASK_ALL; ret.outputMerger.depthStencilState.stencilEnable = desc.StencilEnable == TRUE; ret.outputMerger.depthStencilState.resourceId = - rm->GetOriginalID(GetIDForResource(rs->OM.DepthStencilState)); + rm->GetOriginalID(GetIDForDeviceChild(rs->OM.DepthStencilState)); ret.outputMerger.depthStencilState.frontFace.function = MakeCompareFunc(desc.FrontFace.StencilFunc); @@ -1543,7 +1545,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) // Predication ///////////////////////////////////////////////// - ret.predication.resourceId = rm->GetOriginalID(GetIDForResource(rs->Predicate)); + ret.predication.resourceId = rm->GetOriginalID(GetIDForDeviceChild(rs->Predicate)); ret.predication.value = rs->PredicateValue == TRUE ? true : false; ret.predication.isPassing = rs->PredicationWouldPass(); } @@ -3308,7 +3310,7 @@ void D3D11Replay::CreateCustomShaderTex(uint32_t w, uint32_t h) } else { - m_CustomShaderResourceId = GetIDForResource(m_CustomShaderTex); + m_CustomShaderResourceId = GetIDForDeviceChild(m_CustomShaderTex); } } diff --git a/renderdoc/driver/d3d11/d3d11_resources.cpp b/renderdoc/driver/d3d11/d3d11_resources.cpp index 57dfc839b..7e1c205e1 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.cpp +++ b/renderdoc/driver/d3d11/d3d11_resources.cpp @@ -90,17 +90,7 @@ void WrappedShader::ShaderEntry::BuildReflection() UINT GetSubresourceCount(ID3D11Resource *res) { D3D11_RESOURCE_DIMENSION dim; - - // check for wrapped types first as they will be most common and don't - // require a virtual call - if(WrappedID3D11Texture1D::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE1D; - else if(WrappedID3D11Texture2D1::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE2D; - else if(WrappedID3D11Texture3D1::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE3D; - else - res->GetType(&dim); + res->GetType(&dim); if(dim == D3D11_RESOURCE_DIMENSION_BUFFER) return 1; @@ -152,19 +142,7 @@ UINT GetSubresourceCount(ID3D11Resource *res) UINT GetMipForSubresource(ID3D11Resource *res, int Subresource) { D3D11_RESOURCE_DIMENSION dim; - - // check for wrapped types first as they will be most common and don't - // require a virtual call - if(WrappedID3D11Texture1D::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE1D; - else if(WrappedID3D11Texture2D1::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE2D; - else if(WrappedID3D11Texture3D1::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE3D; - else if(WrappedID3D11Buffer::IsAlloc(res)) - return 0; - else - res->GetType(&dim); + res->GetType(&dim); if(dim == D3D11_RESOURCE_DIMENSION_BUFFER) return 0; @@ -220,17 +198,7 @@ UINT GetMipForSubresource(ID3D11Resource *res, int Subresource) UINT GetSliceForSubresource(ID3D11Resource *res, int Subresource) { D3D11_RESOURCE_DIMENSION dim; - - // check for wrapped types first as they will be most common and don't - // require a virtual call - if(WrappedID3D11Texture1D::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE1D; - else if(WrappedID3D11Texture2D1::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE2D; - else if(WrappedID3D11Texture3D1::IsAlloc(res)) - dim = D3D11_RESOURCE_DIMENSION_TEXTURE3D; - else - res->GetType(&dim); + res->GetType(&dim); if(dim == D3D11_RESOURCE_DIMENSION_BUFFER) return 0; @@ -423,80 +391,6 @@ UINT GetByteSize(ID3D11Texture3D *tex, int SubResource) return GetByteSize(desc.Width, desc.Height, desc.Depth, desc.Format, SubResource); } -ResourceId GetIDForDeviceChild(ID3D11DeviceChild *ptr) -{ - if(ptr == NULL) - return ResourceId(); - - if(WrappedID3D11Buffer::IsAlloc(ptr)) - return ((WrappedID3D11Buffer *)ptr)->GetResourceID(); - if(WrappedID3D11Texture2D1::IsAlloc(ptr)) - return ((WrappedID3D11Texture2D1 *)ptr)->GetResourceID(); - if(WrappedID3D11Texture3D1::IsAlloc(ptr)) - return ((WrappedID3D11Texture3D1 *)ptr)->GetResourceID(); - if(WrappedID3D11Texture1D::IsAlloc(ptr)) - return ((WrappedID3D11Texture1D *)ptr)->GetResourceID(); - - if(WrappedID3D11InputLayout::IsAlloc(ptr)) - return ((WrappedID3D11InputLayout *)ptr)->GetResourceID(); - - if(WrappedID3D11Shader::IsAlloc(ptr)) - return ((WrappedID3D11Shader *)ptr)->GetResourceID(); - if(WrappedID3D11Shader::IsAlloc(ptr)) - return ((WrappedID3D11Shader *)ptr)->GetResourceID(); - if(WrappedID3D11Shader::IsAlloc(ptr)) - return ((WrappedID3D11Shader *)ptr)->GetResourceID(); - if(WrappedID3D11Shader::IsAlloc(ptr)) - return ((WrappedID3D11Shader *)ptr)->GetResourceID(); - if(WrappedID3D11Shader::IsAlloc(ptr)) - return ((WrappedID3D11Shader *)ptr)->GetResourceID(); - if(WrappedID3D11Shader::IsAlloc(ptr)) - return ((WrappedID3D11Shader *)ptr)->GetResourceID(); - - if(WrappedID3D11RasterizerState2::IsAlloc(ptr)) - return ((WrappedID3D11RasterizerState2 *)ptr)->GetResourceID(); - if(WrappedID3D11BlendState1::IsAlloc(ptr)) - return ((WrappedID3D11BlendState1 *)ptr)->GetResourceID(); - if(WrappedID3D11DepthStencilState::IsAlloc(ptr)) - return ((WrappedID3D11DepthStencilState *)ptr)->GetResourceID(); - if(WrappedID3D11SamplerState::IsAlloc(ptr)) - return ((WrappedID3D11SamplerState *)ptr)->GetResourceID(); - - if(WrappedID3D11RenderTargetView1::IsAlloc(ptr)) - return ((WrappedID3D11RenderTargetView1 *)ptr)->GetResourceID(); - if(WrappedID3D11ShaderResourceView1::IsAlloc(ptr)) - return ((WrappedID3D11ShaderResourceView1 *)ptr)->GetResourceID(); - if(WrappedID3D11DepthStencilView::IsAlloc(ptr)) - return ((WrappedID3D11DepthStencilView *)ptr)->GetResourceID(); - if(WrappedID3D11UnorderedAccessView1::IsAlloc(ptr)) - return ((WrappedID3D11UnorderedAccessView1 *)ptr)->GetResourceID(); - - if(WrappedID3D11Counter::IsAlloc(ptr)) - return ((WrappedID3D11Counter *)ptr)->GetResourceID(); - if(WrappedID3D11Query1::IsAlloc(ptr)) - return ((WrappedID3D11Query1 *)ptr)->GetResourceID(); - if(WrappedID3D11Predicate::IsAlloc(ptr)) - return ((WrappedID3D11Predicate *)ptr)->GetResourceID(); - - if(WrappedID3D11ClassInstance::IsAlloc(ptr)) - return ((WrappedID3D11ClassInstance *)ptr)->GetResourceID(); - if(WrappedID3D11ClassLinkage::IsAlloc(ptr)) - return ((WrappedID3D11ClassLinkage *)ptr)->GetResourceID(); - - if(WrappedID3D11DeviceContext::IsAlloc(ptr)) - return ((WrappedID3D11DeviceContext *)ptr)->GetResourceID(); - if(WrappedID3D11CommandList::IsAlloc(ptr)) - return ((WrappedID3D11CommandList *)ptr)->GetResourceID(); - if(WrappedID3DDeviceContextState::IsAlloc(ptr)) - return ((WrappedID3DDeviceContextState *)ptr)->GetResourceID(); - if(WrappedID3D11Fence::IsAlloc(ptr)) - return ((WrappedID3D11Fence *)ptr)->GetResourceID(); - - RDCERR("Unknown type for ptr 0x%p", ptr); - - return ResourceId(); -} - D3D11ResourceType IdentifyTypeByPtr(IUnknown *ptr) { if(WrappedID3D11InputLayout::IsAlloc(ptr)) diff --git a/renderdoc/driver/d3d11/d3d11_resources.h b/renderdoc/driver/d3d11/d3d11_resources.h index e6aef9869..e1decf276 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.h +++ b/renderdoc/driver/d3d11/d3d11_resources.h @@ -30,9 +30,6 @@ #include "d3d11_manager.h" D3D11ResourceType IdentifyTypeByPtr(IUnknown *ptr); -ResourceId GetIDForDeviceChild(ID3D11DeviceChild *ptr); -template -inline ResourceId GetIDForResource(T *ptr); template inline ResourceId GetViewResourceResID(T *); @@ -398,6 +395,27 @@ public: } }; +inline ID3D11DeviceChild *UnwrapResource(ID3D11DeviceChild *child) +{ + if(child) + return ((WrappedDeviceChild11 *)child)->GetReal(); + return NULL; +} + +inline ID3D11Resource *UnwrapResource(ID3D11Resource *child) +{ + if(child) + return ((WrappedDeviceChild11 *)child)->GetReal(); + return NULL; +} + +inline ResourceId GetIDForDeviceChild(ID3D11DeviceChild *child) +{ + if(child) + return ((WrappedDeviceChild11 *)child)->GetResourceID(); + return ResourceId(); +} + inline void IntAddRef(ID3D11DeviceChild *child) { // assume it's wrapped, do a default cast with template parameters (the exact type doesn't matter) @@ -806,7 +824,7 @@ protected: WrappedView1(NestedType *real, WrappedID3D11Device *device, ID3D11Resource *res) : WrappedDeviceChild11(real, device), m_pResource(res), m_ResourceRange(this) { - m_ResourceResID = GetIDForResource(m_pResource); + m_ResourceResID = GetIDForDeviceChild(m_pResource); ::IntAddRef(m_pResource); } @@ -1426,6 +1444,7 @@ GET_RANGE(WrappedID3D11UnorderedAccessView1, ID3D11UnorderedAccessView1); GET_RANGE(WrappedID3D11ShaderResourceView1, ID3D11ShaderResourceView); GET_RANGE(WrappedID3D11ShaderResourceView1, ID3D11ShaderResourceView1); GET_RANGE(WrappedID3D11DepthStencilView, ID3D11DepthStencilView); +GET_RANGE(WrappedID3D11ShaderResourceView1, ID3D11View); #define GET_VIEW_RESOURCE_RES_ID(wrapped, unwrapped) \ template <> \ @@ -1440,96 +1459,4 @@ GET_VIEW_RESOURCE_RES_ID(WrappedID3D11UnorderedAccessView1, ID3D11UnorderedAcces GET_VIEW_RESOURCE_RES_ID(WrappedID3D11ShaderResourceView1, ID3D11ShaderResourceView); GET_VIEW_RESOURCE_RES_ID(WrappedID3D11ShaderResourceView1, ID3D11ShaderResourceView1); GET_VIEW_RESOURCE_RES_ID(WrappedID3D11DepthStencilView, ID3D11DepthStencilView); - -// macro that only handles non-revisioned interfaces, 1:1 with its parent -#define GET_RES_ID(wrapped) \ - template <> \ - inline ResourceId GetIDForResource(wrapped::InnerType *v) \ - { \ - return v ? ((wrapped *)v)->GetResourceID() : ResourceId(); \ - } - -// macro for interfaces with a '1' version that has two parents -#define GET_RES_ID1(wrapped) \ - template <> \ - inline ResourceId GetIDForResource(wrapped::InnerType *v) \ - { \ - return v ? ((wrapped *)v)->GetResourceID() : ResourceId(); \ - } \ - template <> \ - inline ResourceId GetIDForResource(wrapped::InnerType1 *v) \ - { \ - return v ? ((wrapped *)v)->GetResourceID() : ResourceId(); \ - } - -// macro for '2' interfaces with three parents -#define GET_RES_ID2(wrapped) \ - template <> \ - inline ResourceId GetIDForResource(wrapped::InnerType *v) \ - { \ - return v ? ((wrapped *)v)->GetResourceID() : ResourceId(); \ - } \ - template <> \ - inline ResourceId GetIDForResource(wrapped::InnerType1 *v) \ - { \ - return v ? ((wrapped *)v)->GetResourceID() : ResourceId(); \ - } \ - template <> \ - inline ResourceId GetIDForResource(wrapped::InnerType2 *v) \ - { \ - return v ? ((wrapped *)v)->GetResourceID() : ResourceId(); \ - } -GET_RES_ID(WrappedID3D11Buffer); -GET_RES_ID(WrappedID3D11Texture1D); -GET_RES_ID1(WrappedID3D11Texture2D1); -GET_RES_ID1(WrappedID3D11Texture3D1); -GET_RES_ID(WrappedID3D11InputLayout); -GET_RES_ID(WrappedID3D11SamplerState); -GET_RES_ID2(WrappedID3D11RasterizerState2); -GET_RES_ID(WrappedID3D11DepthStencilState); -GET_RES_ID1(WrappedID3D11BlendState1); -GET_RES_ID1(WrappedID3D11ShaderResourceView1); -GET_RES_ID1(WrappedID3D11UnorderedAccessView1); -GET_RES_ID1(WrappedID3D11RenderTargetView1); -GET_RES_ID(WrappedID3D11DepthStencilView); -GET_RES_ID(WrappedID3D11Shader); -GET_RES_ID(WrappedID3D11Shader); -GET_RES_ID(WrappedID3D11Shader); -GET_RES_ID(WrappedID3D11Shader); -GET_RES_ID(WrappedID3D11Shader); -GET_RES_ID(WrappedID3D11Shader); -GET_RES_ID(WrappedID3D11Counter); -GET_RES_ID1(WrappedID3D11Query1); -GET_RES_ID(WrappedID3D11Predicate); -GET_RES_ID(WrappedID3D11ClassInstance); -GET_RES_ID(WrappedID3D11ClassLinkage); -GET_RES_ID(WrappedID3DDeviceContextState); -GET_RES_ID(WrappedID3D11CommandList); -GET_RES_ID(WrappedID3D11Fence); - -// generic version that checks all the wrapped pools. We can use this for resource since it checks -// buffer and textures first, and also for purely virtual interfaces like asynchronous even though -// it's a little less efficient as we know we could narrow the set of types to search. -template <> -inline ResourceId GetIDForResource(ID3D11DeviceChild *v) -{ - return GetIDForDeviceChild(v); -} - -template <> -inline ResourceId GetIDForResource(ID3D11Resource *v) -{ - return GetIDForDeviceChild(v); -} - -template <> -inline ResourceId GetIDForResource(ID3D11Asynchronous *v) -{ - return GetIDForDeviceChild(v); -} - -template <> -inline ResourceId GetIDForResource(ID3D11View *v) -{ - return GetIDForDeviceChild(v); -} +GET_VIEW_RESOURCE_RES_ID(WrappedID3D11ShaderResourceView1, ID3D11View); diff --git a/renderdoc/driver/d3d11/d3d11_serialise.cpp b/renderdoc/driver/d3d11/d3d11_serialise.cpp index ab6776610..8997d42b0 100644 --- a/renderdoc/driver/d3d11/d3d11_serialise.cpp +++ b/renderdoc/driver/d3d11/d3d11_serialise.cpp @@ -37,7 +37,7 @@ void DoSerialiseViaResourceId(SerialiserType &ser, Interface *&el) ResourceId id; if(ser.IsWriting() && rm) - id = GetIDForResource(el); + id = GetIDForDeviceChild(el); DoSerialise(ser, id); diff --git a/renderdoc/driver/d3d11/d3d11_video.cpp b/renderdoc/driver/d3d11/d3d11_video.cpp index cce2cfbe3..d2996679e 100644 --- a/renderdoc/driver/d3d11/d3d11_video.cpp +++ b/renderdoc/driver/d3d11/d3d11_video.cpp @@ -31,32 +31,6 @@ WRAPPED_POOL_INST(WrappedID3D11VideoDecoderOutputView); WRAPPED_POOL_INST(WrappedID3D11VideoProcessorInputView); WRAPPED_POOL_INST(WrappedID3D11VideoProcessorOutputView); -ID3D11Resource *UnwrapD3D11Resource(ID3D11Resource *dxObject) -{ - if(WrappedID3D11Buffer::IsAlloc(dxObject)) - { - WrappedID3D11Buffer *w = (WrappedID3D11Buffer *)dxObject; - return w->GetReal(); - } - else if(WrappedID3D11Texture1D::IsAlloc(dxObject)) - { - WrappedID3D11Texture1D *w = (WrappedID3D11Texture1D *)dxObject; - return w->GetReal(); - } - else if(WrappedID3D11Texture2D1::IsAlloc(dxObject)) - { - WrappedID3D11Texture2D1 *w = (WrappedID3D11Texture2D1 *)dxObject; - return w->GetReal(); - } - else if(WrappedID3D11Texture3D1::IsAlloc(dxObject)) - { - WrappedID3D11Texture3D1 *w = (WrappedID3D11Texture3D1 *)dxObject; - return w->GetReal(); - } - - return NULL; -} - ULONG STDMETHODCALLTYPE WrappedID3D11VideoDevice2::AddRef() { return m_pDevice->AddRef(); @@ -217,17 +191,17 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11VideoDevice2::CreateVideoDecoderOutputVie /* [annotation] */ _COM_Outptr_opt_ ID3D11VideoDecoderOutputView **ppVDOVView) { if(ppVDOVView == NULL) - return m_pReal->CreateVideoDecoderOutputView(UnwrapD3D11Resource(pResource), pDesc, NULL); + return m_pReal->CreateVideoDecoderOutputView(UnwrapResource(pResource), pDesc, NULL); ID3D11VideoDecoderOutputView *real = NULL; - HRESULT hr = m_pReal->CreateVideoDecoderOutputView(UnwrapD3D11Resource(pResource), pDesc, &real); + HRESULT hr = m_pReal->CreateVideoDecoderOutputView(UnwrapResource(pResource), pDesc, &real); if(SUCCEEDED(hr)) { *ppVDOVView = new WrappedID3D11VideoDecoderOutputView(real, m_pDevice); - m_pDevice->GetResourceManager()->MarkDirtyResource(GetIDForResource(pResource)); + m_pDevice->GetResourceManager()->MarkDirtyResource(GetIDForDeviceChild(pResource)); } else { @@ -245,20 +219,20 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11VideoDevice2::CreateVideoProcessorInputVi { if(ppVPIView == NULL) return m_pReal->CreateVideoProcessorInputView( - UnwrapD3D11Resource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), + UnwrapResource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), pDesc, NULL); ID3D11VideoProcessorInputView *real = NULL; HRESULT hr = m_pReal->CreateVideoProcessorInputView( - UnwrapD3D11Resource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), - pDesc, &real); + UnwrapResource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), pDesc, + &real); if(SUCCEEDED(hr)) { *ppVPIView = new WrappedID3D11VideoProcessorInputView(real, m_pDevice); - m_pDevice->GetResourceManager()->MarkDirtyResource(GetIDForResource(pResource)); + m_pDevice->GetResourceManager()->MarkDirtyResource(GetIDForDeviceChild(pResource)); } else { @@ -276,20 +250,20 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11VideoDevice2::CreateVideoProcessorOutputV { if(ppVPOView == NULL) return m_pReal->CreateVideoProcessorOutputView( - UnwrapD3D11Resource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), + UnwrapResource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), pDesc, NULL); ID3D11VideoProcessorOutputView *real = NULL; HRESULT hr = m_pReal->CreateVideoProcessorOutputView( - UnwrapD3D11Resource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), - pDesc, &real); + UnwrapResource(pResource), VIDEO_UNWRAP(WrappedID3D11VideoProcessorEnumerator1, pEnum), pDesc, + &real); if(SUCCEEDED(hr)) { *ppVPOView = new WrappedID3D11VideoProcessorOutputView(real, m_pDevice); - m_pDevice->GetResourceManager()->MarkDirtyResource(GetIDForResource(pResource)); + m_pDevice->GetResourceManager()->MarkDirtyResource(GetIDForDeviceChild(pResource)); } else { @@ -559,7 +533,7 @@ APP_DEPRECATED_HRESULT STDMETHODCALLTYPE WrappedID3D11VideoContext2::DecoderExte unwrappedRes.resize(unwrappedExt.ResourceCount); for(UINT i = 0; i < unwrappedExt.ResourceCount; i++) - unwrappedRes[i] = UnwrapD3D11Resource(unwrappedExt.ppResourceList[i]); + unwrappedRes[i] = UnwrapResource(unwrappedExt.ppResourceList[i]); unwrappedExt.ppResourceList = unwrappedRes.data();