DiligentGraphics/DiligentCore

Support Renderdoc in D3D12 backend.

DarlingZeroX opened this issue · 3 comments

it seems Renderdoc works fine in D3D11, OpenGL, Vulkan backend.
but main problem is CreateGraphicsPipelineState in d3d12 backend return E_NOINTERFACE (No such interface supported) and throw Failed to create pipeline state.
It would be better to get it also working. or any suggestion use other debugger?

renderdoc used to work in D3D12 mode - I don't know why it is not working now. Could be a renderdoc issue.

I think i found problem
Here is the hook code of renderdoc

HRESULT WrappedID3D12Device::CreateGraphicsPipelineState(const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc,
                                                         REFIID riid, void **ppPipelineState)
{
  D3D12_GRAPHICS_PIPELINE_STATE_DESC unwrappedDesc = *pDesc;
  unwrappedDesc.pRootSignature = Unwrap(unwrappedDesc.pRootSignature);

  if(ppPipelineState == NULL)
    return m_pDevice->CreateGraphicsPipelineState(&unwrappedDesc, riid, NULL);

 ////////////////// [  The reason is renderdoc check uuid   ] ////////////////// 
  if(riid != __uuidof(ID3D12PipelineState))
    return E_NOINTERFACE;

  ID3D12PipelineState *real = NULL;
  HRESULT ret;
  SERIALISE_TIME_CALL(
      ret = m_pDevice->CreateGraphicsPipelineState(&unwrappedDesc, riid, (void **)&real));

  if(SUCCEEDED(ret))
  {
    // use implicit register/space
    uint32_t reg = ~0U, space = ~0U;
    if(m_VendorEXT != GPUVendor::Unknown)
      GetShaderExtUAV(reg, space);

    ProcessCreatedGraphicsPSO(real, reg, space, pDesc, riid, ppPipelineState);
  }
  else
  {
    CheckHRESULT(ret);
  }

  return ret;
}

Here is the code in PipelineStateD3D12Impl.cpp of DiligentCore

if (!m_pd3d12PSO)
{
////////// Original code
////    uuid of m_pd3d12PSO is ID3D12DeviceChild, the base class of ID3D12PipelineState, renderdoc only check ID3D12PipelineState uuid equality 
    HRESULT hr = pd3d12Device->CreateGraphicsPipelineState(&d3d12PSODesc, IID_PPV_ARGS(&m_pd3d12PSO));

////////// Fixed code
////   Just appoint uuid of ID3D12PipelineState rather than ID3D12DeviceChild
    HRESULT hr = pd3d12Device->CreateGraphicsPipelineState(&d3d12PSODesc, __uuidof(ID3D12PipelineState), IID_PPV_ARGS_Helper(&m_pd3d12PSO));

    if (FAILED(hr))
        LOG_ERROR_AND_THROW("Failed to create pipeline state");

    // Add to the cache
    if (pPSOCacheD3D12 != nullptr && !WName.empty())
        pPSOCacheD3D12->StorePipeline(WName.c_str(), m_pd3d12PSO);
}

Same problem with CreateComputePipelineState .....

Thanks for finding this out - will fix this soon.