diff --git a/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp b/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp index 97ab915f5..299231657 100644 --- a/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp @@ -680,104 +680,6 @@ void D3D12APIWrapper::FetchSRV(const BindingSlot &slot) slot.registerSpace); } -bool D3D12APIWrapper::IsSRVBound(const BindingSlot &slot) -{ - const D3D12RenderState &rs = m_Device->GetQueue()->GetCommandData()->m_RenderState; - D3D12ResourceManager *rm = m_Device->GetResourceManager(); - - // Get the root signature - const D3D12RenderState::RootSignature *pRootSignature = NULL; - if(m_ShaderType == DXBC::ShaderType::Compute) - { - if(rs.compute.rootsig != ResourceId()) - { - pRootSignature = &rs.compute; - } - } - else if(rs.graphics.rootsig != ResourceId()) - { - pRootSignature = &rs.graphics; - } - - if(pRootSignature) - { - WrappedID3D12RootSignature *pD3D12RootSig = - rm->GetCurrentAs(pRootSignature->rootsig); - - size_t numParams = RDCMIN(pD3D12RootSig->sig.Parameters.size(), pRootSignature->sigelems.size()); - for(size_t i = 0; i < numParams; ++i) - { - const D3D12RootSignatureParameter ¶m = pD3D12RootSig->sig.Parameters[i]; - const D3D12RenderState::SignatureElement &element = pRootSignature->sigelems[i]; - if(IsShaderParameterVisible(m_ShaderType, param.ShaderVisibility)) - { - if(param.ParameterType == D3D12_ROOT_PARAMETER_TYPE_SRV && element.type == eRootSRV) - { - if(param.Descriptor.ShaderRegister == slot.shaderRegister && - param.Descriptor.RegisterSpace == slot.registerSpace) - { - // Found the requested SRV - ID3D12Resource *pResource = rm->GetCurrentAs(element.id); - return pResource != NULL; - } - } - else if(param.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE && - element.type == eRootTable) - { - UINT prevTableOffset = 0; - WrappedID3D12DescriptorHeap *heap = - rm->GetCurrentAs(element.id); - - size_t numRanges = param.ranges.size(); - for(size_t r = 0; r < numRanges; ++r) - { - const D3D12_DESCRIPTOR_RANGE1 &range = param.ranges[r]; - - // For every range, check the number of descriptors so that we are accessing the - // correct data for append descriptor tables, even if the range type doesn't match - // what we need to fetch - UINT offset = range.OffsetInDescriptorsFromTableStart; - if(range.OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) - offset = prevTableOffset; - - D3D12Descriptor *desc = (D3D12Descriptor *)heap->GetCPUDescriptorHandleForHeapStart().ptr; - desc += element.offset; - desc += offset; - - UINT numDescriptors = range.NumDescriptors; - if(numDescriptors == UINT_MAX) - { - // Find out how many descriptors are left after - numDescriptors = heap->GetNumDescriptors() - offset - (UINT)element.offset; - - // TODO: Should we look up the bind point in the D3D12 state to try to get - // a better guess at the number of descriptors? - } - - prevTableOffset = offset + numDescriptors; - - // Check if the range is for SRVs and the slot we want is contained - if(range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV && - slot.shaderRegister >= range.BaseShaderRegister && - slot.shaderRegister < range.BaseShaderRegister + numDescriptors && - range.RegisterSpace == slot.registerSpace) - { - desc += slot.shaderRegister - range.BaseShaderRegister; - if(desc) - { - ResourceId srvId = desc->GetResResourceId(); - ID3D12Resource *pResource = rm->GetCurrentAs(srvId); - return pResource != NULL; - } - } - } - } - } - } - } - return false; -} - void D3D12APIWrapper::FetchUAV(const BindingSlot &slot) { // if the UAV might be dirty from side-effects from the action, replay back to right @@ -966,104 +868,6 @@ void D3D12APIWrapper::FetchUAV(const BindingSlot &slot) slot.registerSpace); } -bool D3D12APIWrapper::IsUAVBound(const BindingSlot &slot) -{ - const D3D12RenderState &rs = m_Device->GetQueue()->GetCommandData()->m_RenderState; - D3D12ResourceManager *rm = m_Device->GetResourceManager(); - - // Get the root signature - const D3D12RenderState::RootSignature *pRootSignature = NULL; - if(m_ShaderType == DXBC::ShaderType::Compute) - { - if(rs.compute.rootsig != ResourceId()) - { - pRootSignature = &rs.compute; - } - } - else if(rs.graphics.rootsig != ResourceId()) - { - pRootSignature = &rs.graphics; - } - - if(pRootSignature) - { - WrappedID3D12RootSignature *pD3D12RootSig = - rm->GetCurrentAs(pRootSignature->rootsig); - - size_t numParams = RDCMIN(pD3D12RootSig->sig.Parameters.size(), pRootSignature->sigelems.size()); - for(size_t i = 0; i < numParams; ++i) - { - const D3D12RootSignatureParameter ¶m = pD3D12RootSig->sig.Parameters[i]; - const D3D12RenderState::SignatureElement &element = pRootSignature->sigelems[i]; - if(IsShaderParameterVisible(m_ShaderType, param.ShaderVisibility)) - { - if(param.ParameterType == D3D12_ROOT_PARAMETER_TYPE_UAV && element.type == eRootUAV) - { - if(param.Descriptor.ShaderRegister == slot.shaderRegister && - param.Descriptor.RegisterSpace == slot.registerSpace) - { - // Found the requested UAV - ID3D12Resource *pResource = rm->GetCurrentAs(element.id); - return pResource != NULL; - } - } - else if(param.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE && - element.type == eRootTable) - { - UINT prevTableOffset = 0; - WrappedID3D12DescriptorHeap *heap = - rm->GetCurrentAs(element.id); - - size_t numRanges = param.ranges.size(); - for(size_t r = 0; r < numRanges; ++r) - { - const D3D12_DESCRIPTOR_RANGE1 &range = param.ranges[r]; - - // For every range, check the number of descriptors so that we are accessing the - // correct data for append descriptor tables, even if the range type doesn't match - // what we need to fetch - UINT offset = range.OffsetInDescriptorsFromTableStart; - if(range.OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) - offset = prevTableOffset; - - D3D12Descriptor *desc = (D3D12Descriptor *)heap->GetCPUDescriptorHandleForHeapStart().ptr; - desc += element.offset; - desc += offset; - - UINT numDescriptors = range.NumDescriptors; - if(numDescriptors == UINT_MAX) - { - // Find out how many descriptors are left after - numDescriptors = heap->GetNumDescriptors() - offset - (UINT)element.offset; - - // TODO: Should we look up the bind point in the D3D12 state to try to get - // a better guess at the number of descriptors? - } - - prevTableOffset = offset + numDescriptors; - - // Check if the range is for UAVs and the slot we want is contained - if(range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV && - slot.shaderRegister >= range.BaseShaderRegister && - slot.shaderRegister < range.BaseShaderRegister + numDescriptors && - range.RegisterSpace == slot.registerSpace) - { - desc += slot.shaderRegister - range.BaseShaderRegister; - if(desc) - { - ResourceId uavId = desc->GetResResourceId(); - ID3D12Resource *pResource = rm->GetCurrentAs(uavId); - return pResource != NULL; - } - } - } - } - } - } - } - return false; -} - bool D3D12APIWrapper::CalculateMathIntrinsic(DXIL::DXOp dxOp, const ShaderVariable &input, ShaderVariable &output) { @@ -1180,26 +984,4 @@ ShaderVariable D3D12APIWrapper::GetRenderTargetSampleInfo(const DXBC::ShaderType return D3D12ShaderDebug::GetRenderTargetSampleInfo(m_Device, shaderType, opString); } -bool D3D12APIWrapper::IsResourceBound(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot) -{ - if(resClass == ResourceClass::SRV) - { - GlobalState::SRVIterator srvIter = m_GlobalState.srvs.find(slot); - if(srvIter != m_GlobalState.srvs.end()) - return true; - return IsSRVBound(slot); - } - else if(resClass == ResourceClass::UAV) - { - GlobalState::UAVIterator uavIter = m_GlobalState.uavs.find(slot); - if(uavIter != m_GlobalState.uavs.end()) - return true; - return IsUAVBound(slot); - } - else - { - RDCERR("Unhanded resource class %s", ToStr(resClass).c_str()); - } - return false; -} }; diff --git a/renderdoc/driver/d3d12/d3d12_dxil_debug.h b/renderdoc/driver/d3d12/d3d12_dxil_debug.h index 41ee8cbb7..22a1fdb83 100644 --- a/renderdoc/driver/d3d12/d3d12_dxil_debug.h +++ b/renderdoc/driver/d3d12/d3d12_dxil_debug.h @@ -60,12 +60,8 @@ public: ShaderVariable GetSampleInfo(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot, const DXBC::ShaderType shaderType, const char *opString); ShaderVariable GetRenderTargetSampleInfo(const DXBC::ShaderType shaderType, const char *opString); - bool IsResourceBound(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot); private: - bool IsSRVBound(const BindingSlot &slot); - bool IsUAVBound(const BindingSlot &slot); - WrappedID3D12Device *m_Device; const DXIL::EntryPointInterface *m_EntryPointInterface; GlobalState &m_GlobalState; diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.h b/renderdoc/driver/shaders/dxil/dxil_debug.h index e26ecd0ed..6313f2b66 100644 --- a/renderdoc/driver/shaders/dxil/dxil_debug.h +++ b/renderdoc/driver/shaders/dxil/dxil_debug.h @@ -133,7 +133,6 @@ public: const DXBC::ShaderType shaderType, const char *opString) = 0; virtual ShaderVariable GetRenderTargetSampleInfo(const DXBC::ShaderType shaderType, const char *opString) = 0; - virtual bool IsResourceBound(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot) = 0; }; struct MemoryTracking